1 # Copyright 1999-2015 Gentoo Foundation
2 # Distributed under the terms of the GNU General Public License v2
7 inherit eutils flag-o-matic linux-info linux-mod multilib readme.gentoo toolchain-funcs
9 AUFS_VERSION="${PV%%_p*}"
10 # highest branch version
12 # highest supported version
14 # lowest supported version
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/aufs4-standalone-${PV}.tar.xz"
23 KEYWORDS="~amd64 ~x86"
24 IUSE="debug doc fuse hfs inotify kernel-patch nfs pax_kernel ramfs"
35 S="${WORKDIR}"/${PN}-standalone
37 MODULE_NAMES="aufs(misc:${S})"
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"
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
51 kernel_is lt 4 ${KERN_MIN_VER} 0 && die "the kernel version isn't supported by upstream anymore. Please upgrade."
52 kernel_is gt 4 ${KERN_MAX_VER} 99 && die "kernel too new"
56 if [[ "${KV_MINOR}" -gt "${PATCH_MAX_VER}" ]]; then
59 PATCH_BRANCH="${KV_MINOR}"
64 elog "It seems you are using vanilla-sources with aufs4"
65 elog "Please use sys-kernel/aufs-sources with USE=vanilla"
66 elog "This will save you the nasty reemerge of sys-fs/aufs4 on every kernel upgrade"
69 elog "It seems you are using gentoo-sources with aufs4"
70 elog "Please use sys-kernel/aufs-sources"
71 elog "This will save you the nasty reemerge of sys-fs/aufs4 on every kernel upgrade"
75 pushd "${T}" &> /dev/null
77 cd ${PN}-standalone || die
78 local module_branch=origin/${PN}.${PATCH_BRANCH}
79 einfo "Using ${module_branch} as patch source"
80 git checkout -q -b local-${PN}.${PATCH_BRANCH} ${module_branch} || die
81 combinediff ${PN}-base.patch ${PN}-standalone.patch > "${T}"/combined-1.patch
82 combinediff "${T}"/combined-1.patch ${PN}-mmap.patch > ${PN}-standalone-base-mmap-combined.patch
83 if ! ( patch -p1 --dry-run --force -R -d ${KV_DIR} < ${PN}-standalone-base-mmap-combined.patch > /dev/null ); then
84 if use kernel-patch; then
86 ewarn "Patching your kernel..."
87 patch --no-backup-if-mismatch --force -p1 -R -d ${KV_DIR} < "${T}"/${PN}-standalone/${PN}-standalone-base-mmap-combined.patch >/dev/null
88 epatch "${T}"/${PN}-standalone/${PN}-standalone-base-mmap-combined.patch
89 ewarn "You need to compile your kernel with the applied patch"
90 ewarn "to be able to load and use the aufs kernel module"
92 eerror "You need to apply a patch to your kernel to compile and run the ${PN} module"
93 eerror "Either enable the kernel-patch useflag to do it with this ebuild"
94 eerror "or apply "${T}"/${PN}-standalone/${PN}-standalone-base-mmap-combined.patch by hand"
95 die "missing kernel patch, please apply it first"
99 export PKG_SETUP_HAS_BEEN_RAN=1
104 grep -q "^CONFIG_AUFS_${option} =" config.mk || die "${option} is not a valid config option"
105 sed "/^CONFIG_AUFS_${option}/s:=:= y:g" -i config.mk || die
110 local module_branch=origin/${PN}.${PATCH_BRANCH}
112 einfo "Using for module creation branch ${module_branch}"
113 git checkout -q -b local-gentoo ${module_branch} || die
115 # All config options to off
116 sed "s:= y:=:g" -i config.mk || die
118 set_config RDU BRANCH_MAX_127 SBILIST
120 use debug && set_config DEBUG
121 use fuse && set_config BR_FUSE POLL
122 use hfs && set_config BR_HFSPLUS
123 use inotify && set_config HNOTIFY HFSNOTIFY
124 use nfs && set_config EXPORT
125 use nfs && ( use amd64 || use ppc64 ) && set_config INO_T_64
126 use ramfs && set_config BR_RAMFS
128 if use pax_kernel; then
129 epatch "${FILESDIR}"/pax-4.patch
132 sed -i "s:aufs.ko usr/include/linux/aufs_type.h:aufs.ko:g" Makefile || die
141 LDFLAGS="$(raw-ldflags)" \
142 ARCH=$(tc-arch-kernel) \
148 linux-mod_src_install
150 insinto /usr/share/doc/${PF}
152 use doc && doins -r Documentation
154 use kernel-patch || doins "${T}"/${PN}-standalone/${PN}-standalone-base-mmap-combined.patch
156 dodoc Documentation/filesystems/aufs/README "${T}"/${PN}-standalone/{aufs4-loopback,vfs-ino,tmpfs-idr}.patch
158 readme.gentoo_create_doc
162 readme.gentoo_pkg_postinst
163 linux-mod_pkg_postinst