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/aufs3-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 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"
56 if [[ "${KV_MINOR}" -gt "${PATCH_MAX_VER}" ]]; then
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+
63 PATCH_BRANCH="${KV_MINOR}"
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"
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"
79 pushd "${T}" &> /dev/null
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
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"
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"
103 export PKG_SETUP_HAS_BEEN_RAN=1
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
114 local module_branch=origin/${PN}.${PATCH_BRANCH}
116 einfo "Using for module creation branch ${module_branch}"
117 git checkout -q -b local-gentoo ${module_branch} || die
119 # All config options to off
120 sed "s:= y:=:g" -i config.mk || die
122 set_config RDU BRANCH_MAX_127 SBILIST
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
132 if use pax_kernel; then
133 if kernel_is ge 3 11; then
134 epatch "${FILESDIR}"/pax-3.11.patch
136 epatch "${FILESDIR}"/pax-3.patch
140 sed -i "s:aufs.ko usr/include/linux/aufs_type.h:aufs.ko:g" Makefile || die
149 LDFLAGS="$(raw-ldflags)" \
150 ARCH=$(tc-arch-kernel) \
156 linux-mod_src_install
158 insinto /usr/share/doc/${PF}
160 use doc && doins -r Documentation
162 use kernel-patch || doins "${T}"/${PN}-standalone/${PN}-standalone-base-mmap-combined.patch
164 dodoc Documentation/filesystems/aufs/README "${T}"/${PN}-standalone/{aufs3-loopback,vfs-ino,tmpfs-idr}.patch
166 readme.gentoo_create_doc
170 readme.gentoo_pkg_postinst
171 linux-mod_pkg_postinst