1 # Copyright 1999-2017 Gentoo Foundation
2 # Distributed under the terms of the GNU General Public License v2
6 inherit eutils flag-o-matic linux-info linux-mod multilib readme.gentoo-r1 toolchain-funcs
8 AUFS_VERSION="${PV%%_p*}"
9 # highest branch version
11 # highest supported version
13 # lowest supported version
16 DESCRIPTION="An entirely re-designed and re-implemented Unionfs"
17 HOMEPAGE="http://aufs.sourceforge.net/"
18 SRC_URI="https://dev.gentoo.org/~jlec/distfiles/aufs4-standalone-${PV}.tar.xz"
22 KEYWORDS="~amd64 ~x86"
23 IUSE="debug doc fuse hfs inotify kernel-patch nfs pax_kernel ramfs"
34 S="${WORKDIR}"/${PN}-standalone
36 MODULE_NAMES="aufs(misc:${S})"
39 CONFIG_CHECK+=" !AUFS_FS"
40 use inotify && CONFIG_CHECK+=" ~FSNOTIFY"
41 use nfs && CONFIG_CHECK+=" EXPORTFS"
42 use fuse && CONFIG_CHECK+=" ~FUSE_FS"
43 use hfs && CONFIG_CHECK+=" ~HFSPLUS_FS"
44 use pax_kernel && CONFIG_CHECK+=" PAX" \
45 && ERROR_PAX="Please use hardened sources"
47 # this is needed so merging a binpkg ${PN} is
48 # possible w/out a kernel unpacked on the system
49 [[ -n "$PKG_SETUP_HAS_BEEN_RAN" ]] && return
52 kernel_is lt 4 ${KERN_MIN_VER} 0 && \
53 die "the kernel version isn't supported by upstream anymore. Please upgrade."
54 kernel_is gt 4 ${KERN_MAX_VER} 99 && die "kernel too new"
58 if [[ "${KV_MINOR}" -gt "${PATCH_MAX_VER}" ]]; then
60 elif [[ "${KV_MINOR}" == "1" ]] && [[ "${KV_PATCH}" -ge "13" ]]; then
61 PATCH_BRANCH="${KV_MINOR}".13+
63 PATCH_BRANCH="${KV_MINOR}"
68 elog "It seems you are using vanilla-sources with aufs4"
69 elog "Please use sys-kernel/aufs-sources with USE=vanilla"
70 elog "This will save you the nasty reemerge of sys-fs/aufs4 on every kernel upgrade"
73 elog "It seems you are using gentoo-sources with aufs4"
74 elog "Please use sys-kernel/aufs-sources"
75 elog "This will save you the nasty reemerge of sys-fs/aufs4 on every kernel upgrade"
79 pushd "${T}" &> /dev/null || die
82 cd ${PN}-standalone || die
84 local module_branch=origin/${PN}.${PATCH_BRANCH}
86 einfo "Using ${module_branch} as patch source"
87 git checkout -q -b local-${PN}.${PATCH_BRANCH} ${module_branch} || die
90 ${PN}-base.patch ${PN}-standalone.patch > "${T}"/combined-1.patch
92 "${T}"/combined-1.patch ${PN}-mmap.patch \
93 > ${PN}-standalone-base-mmap-combined.patch
95 if ! ( patch -p1 --dry-run --force -R -d ${KV_DIR} < ${PN}-standalone-base-mmap-combined.patch > /dev/null ); then
96 if use kernel-patch; then
98 ewarn "Patching your kernel..."
100 --no-backup-if-mismatch --force -p1 -R -d ${KV_DIR} \
101 < "${T}"/${PN}-standalone/${PN}-standalone-base-mmap-combined.patch \
103 epatch "${T}"/${PN}-standalone/${PN}-standalone-base-mmap-combined.patch
104 ewarn "You need to compile your kernel with the applied patch"
105 ewarn "to be able to load and use the aufs kernel module"
107 eerror "You need to apply a patch to your kernel to compile and run the ${PN} module"
108 eerror "Either enable the kernel-patch useflag to do it with this ebuild"
109 eerror "or apply "${T}"/${PN}-standalone/${PN}-standalone-base-mmap-combined.patch by hand"
110 die "missing kernel patch, please apply it first"
115 export PKG_SETUP_HAS_BEEN_RAN=1
120 grep -q "^CONFIG_AUFS_${option} =" config.mk || \
121 die "${option} is not a valid config option"
122 sed "/^CONFIG_AUFS_${option}/s:=:= y:g" -i config.mk || die
127 local module_branch=origin/${PN}.${PATCH_BRANCH}
129 einfo "Using for module creation branch ${module_branch}"
130 git checkout -q -b local-gentoo ${module_branch} || die
132 # All config options to off
133 sed "s:= y:=:g" -i config.mk || die
135 set_config RDU BRANCH_MAX_127 SBILIST
137 use debug && set_config DEBUG
138 use fuse && set_config BR_FUSE POLL
139 use hfs && set_config BR_HFSPLUS
140 use inotify && set_config HNOTIFY HFSNOTIFY
141 use nfs && set_config EXPORT
142 use nfs && ( use amd64 || use ppc64 ) && set_config INO_T_64
143 use ramfs && set_config BR_RAMFS
145 use pax_kernel && epatch "${FILESDIR}"/pax-4.patch
148 -e "s:aufs.ko usr/include/linux/aufs_type.h:aufs.ko:g" \
160 LDFLAGS="$(raw-ldflags)" \
161 ARCH=$(tc-arch-kernel) \
167 linux-mod_src_install
169 use doc && dodoc -r Documentation
171 use kernel-patch || \
172 doins "${T}"/${PN}-standalone/${PN}-standalone-base-mmap-combined.patch
175 Documentation/filesystems/aufs/README \
176 "${T}"/${PN}-standalone/{aufs4-loopback,vfs-ino,tmpfs-idr}.patch
178 readme.gentoo_create_doc
182 readme.gentoo_print_elog
183 linux-mod_pkg_postinst