Use https by default
[gentoo.git] / sys-fs / aufs3 / aufs3-3_p20150504.ebuild
1 # Copyright 1999-2015 Gentoo Foundation
2 # Distributed under the terms of the GNU General Public License v2
3 # $Id$
4
5 EAPI=5
6
7 inherit eutils flag-o-matic linux-info linux-mod multilib readme.gentoo toolchain-funcs
8
9 AUFS_VERSION="${PV%%_p*}"
10 # highest branch version
11 PATCH_MAX_VER=19
12 # highest supported version
13 KERN_MAX_VER=20
14 # lowest supported version
15 KERN_MIN_VER=14
16
17 DESCRIPTION="An entirely re-designed and re-implemented Unionfs"
18 HOMEPAGE="http://aufs.sourceforge.net/"
19 SRC_URI="https://dev.gentoo.org/~jlec/distfiles/aufs3-standalone-${PV}.tar.xz"
20
21 LICENSE="GPL-2"
22 SLOT="0"
23 KEYWORDS="~amd64 ~x86"
24 IUSE="debug doc fuse hfs inotify kernel-patch nfs pax_kernel ramfs"
25
26 DEPEND="
27         dev-util/patchutils
28         dev-vcs/git"
29 RDEPEND="
30         sys-fs/aufs-util
31         !sys-fs/aufs
32         !sys-fs/aufs2
33         !sys-fs/aufs4"
34
35 S="${WORKDIR}"/${PN}-standalone
36
37 MODULE_NAMES="aufs(misc:${S})"
38
39 pkg_setup() {
40         CONFIG_CHECK+=" !AUFS_FS"
41         use inotify && CONFIG_CHECK+=" ~FSNOTIFY"
42         use nfs && CONFIG_CHECK+=" EXPORTFS"
43         use fuse && CONFIG_CHECK+=" ~FUSE_FS"
44         use hfs && CONFIG_CHECK+=" ~HFSPLUS_FS"
45         use pax_kernel && CONFIG_CHECK+=" PAX" && ERROR_PAX="Please use hardened sources"
46
47         # this is needed so merging a binpkg ${PN} is possible w/out a kernel unpacked on the system
48         [ -n "$PKG_SETUP_HAS_BEEN_RAN" ] && return
49
50         get_version
51         kernel_is lt 3 ${KERN_MIN_VER} 0 && die "the kernel version isn't supported by upstream anymore. Please upgrade."
52         kernel_is gt 3 ${KERN_MAX_VER} 99 && die "kernel too new"
53
54         linux-mod_pkg_setup
55
56         if [[ "${KV_MINOR}" -gt "${PATCH_MAX_VER}" ]]; then
57                 PATCH_BRANCH="x-rcN"
58         elif [[ "${KV_MINOR}" == "14" ]] && [[ "${KV_PATCH}" -ge "21" ]]; then
59                 PATCH_BRANCH="${KV_MINOR}".21+
60         elif [[ "${KV_MINOR}" == "18" ]] && [[ "${KV_PATCH}" -ge "1" ]]; then
61                 PATCH_BRANCH="${KV_MINOR}".1+
62         else
63                 PATCH_BRANCH="${KV_MINOR}"
64         fi
65
66         case ${KV_EXTRA} in
67                         "")
68                                 elog "It seems you are using vanilla-sources with aufs3"
69                                 elog "Please use sys-kernel/aufs-sources with USE=vanilla"
70                                 elog "This will save you the nasty reemerge of sys-fs/aufs3 on every kernel upgrade"
71                         ;;
72                         "-gentoo")
73                                 elog "It seems you are using gentoo-sources with aufs3"
74                                 elog "Please use sys-kernel/aufs-sources"
75                                 elog "This will save you the nasty reemerge of sys-fs/aufs3 on every kernel upgrade"
76                         ;;
77         esac
78
79         pushd "${T}" &> /dev/null
80         unpack ${A}
81         cd ${PN}-standalone || die
82         local module_branch=origin/${PN}.${PATCH_BRANCH}
83         einfo "Using ${module_branch} as patch source"
84         git checkout -q -b local-${PN}.${PATCH_BRANCH} ${module_branch} || die
85         combinediff ${PN}-base.patch ${PN}-standalone.patch  > "${T}"/combined-1.patch
86         combinediff "${T}"/combined-1.patch ${PN}-mmap.patch > ${PN}-standalone-base-mmap-combined.patch
87         if ! ( patch -p1 --dry-run --force -R -d ${KV_DIR} < ${PN}-standalone-base-mmap-combined.patch > /dev/null ); then
88                 if use kernel-patch; then
89                         cd ${KV_DIR}
90                         ewarn "Patching your kernel..."
91                         patch --no-backup-if-mismatch --force -p1 -R -d ${KV_DIR} < "${T}"/${PN}-standalone/${PN}-standalone-base-mmap-combined.patch >/dev/null
92                         epatch "${T}"/${PN}-standalone/${PN}-standalone-base-mmap-combined.patch
93                         ewarn "You need to compile your kernel with the applied patch"
94                         ewarn "to be able to load and use the aufs kernel module"
95                 else
96                         eerror "You need to apply a patch to your kernel to compile and run the ${PN} module"
97                         eerror "Either enable the kernel-patch useflag to do it with this ebuild"
98                         eerror "or apply "${T}"/${PN}-standalone/${PN}-standalone-base-mmap-combined.patch by hand"
99                         die "missing kernel patch, please apply it first"
100                 fi
101         fi
102         popd &> /dev/null
103         export PKG_SETUP_HAS_BEEN_RAN=1
104 }
105
106 set_config() {
107         for option in $*; do
108                 grep -q "^CONFIG_AUFS_${option} =" config.mk || die "${option} is not a valid config option"
109                 sed "/^CONFIG_AUFS_${option}/s:=:= y:g" -i config.mk || die
110         done
111 }
112
113 src_prepare() {
114         local module_branch=origin/${PN}.${PATCH_BRANCH}
115
116         einfo "Using for module creation branch ${module_branch}"
117         git checkout -q -b local-gentoo ${module_branch} || die
118
119         # All config options to off
120         sed "s:= y:=:g" -i config.mk || die
121
122         set_config RDU BRANCH_MAX_127 SBILIST
123
124         use debug && set_config DEBUG
125         use fuse && set_config BR_FUSE POLL
126         use hfs && set_config BR_HFSPLUS
127         use inotify && set_config HNOTIFY HFSNOTIFY
128         use nfs && set_config EXPORT
129         use nfs && ( use amd64 || use ppc64 ) && set_config INO_T_64
130         use ramfs && set_config BR_RAMFS
131
132         if use pax_kernel; then
133                 if kernel_is ge 3 11; then
134                         epatch "${FILESDIR}"/pax-3.11.patch
135                 else
136                         epatch "${FILESDIR}"/pax-3.patch
137                 fi
138         fi
139
140         sed -i "s:aufs.ko usr/include/linux/aufs_type.h:aufs.ko:g" Makefile || die
141 }
142
143 src_compile() {
144         local ARCH=x86
145
146         emake \
147                 CC=$(tc-getCC) \
148                 LD=$(tc-getLD) \
149                 LDFLAGS="$(raw-ldflags)" \
150                 ARCH=$(tc-arch-kernel) \
151                 CONFIG_AUFS_FS=m \
152                 KDIR="${KV_OUT_DIR}"
153 }
154
155 src_install() {
156         linux-mod_src_install
157
158         insinto /usr/share/doc/${PF}
159
160         use doc && doins -r Documentation
161
162         use kernel-patch || doins "${T}"/${PN}-standalone/${PN}-standalone-base-mmap-combined.patch
163
164         dodoc Documentation/filesystems/aufs/README "${T}"/${PN}-standalone/{aufs3-loopback,vfs-ino,tmpfs-idr}.patch
165
166         readme.gentoo_create_doc
167 }
168
169 pkg_postinst() {
170         readme.gentoo_pkg_postinst
171         linux-mod_pkg_postinst
172 }