]> Pileus Git - ~andy/sunrise/blob - sys-fs/aufs/aufs-20090126.ebuild
sys-fs/fuseiso: in gentoo-x86.
[~andy/sunrise] / sys-fs / aufs / aufs-20090126.ebuild
1 # Copyright 1999-2009 Gentoo Foundation
2 # Distributed under the terms of the GNU General Public License v2
3 # $Header: $
4
5 inherit eutils linux-mod
6
7 DESCRIPTION="An entirely re-designed and re-implemented Unionfs."
8 HOMEPAGE="http://aufs.sourceforge.net/"
9 SRC_URI="http://dev.gentooexperimental.org/~tommy/distfiles/${P}.tar.bz2"
10
11 LICENSE="GPL-2"
12 SLOT="0"
13 KEYWORDS="~amd64 ~x86"
14 IUSE="debug fuse hinotify nfs nfsexport robr sec_perm"
15
16 S="${WORKDIR}"/aufs
17
18 MODULE_NAMES="aufs(misc:${S})"
19
20 pkg_setup() {
21         # kernel version check
22         if kernel_is lt 2 6 16 ; then
23                 eerror "${PN} is being developed and tested on linux-2.6.16 and later."
24                 eerror "Make sure you have a proper kernel version!"
25                 die "Wrong kernel version"
26         fi
27
28         get_version
29
30         # assume no kernel patches will be applied today
31         APPLY_KERNEL_PATCH="n"
32
33         # Check if sec_perm patch needs to be applied
34         if kernel_is ge 2 6 24 && linux_chkconfig_present "SECURITY" ; then
35                 APPLY_SEC_PERM_PATCH="n"
36                 if ! grep -qs "EXPORT_SYMBOL(security_inode_permission);" "${KV_DIR}/security/security.c" ; then
37                         APPLY_SEC_PERM_PATCH="y"
38                         APPLY_KERNEL_PATCH="y"
39                 fi
40
41                 # make sure the user is allowing this to happen
42                 if [[ APPLY_SEC_PERM_PATCH = "y" ]] && ! use sec_perm; then
43                         eerror "${PN} requires that all kernels with CONFIG_SECURITY enabled >= 2.6.24"
44                         eerror "be patched.  Please enable USE=\"sec_perm\" to allow this patch to be"
45                         eerror "applied."
46                         die "Invalid configuration"
47                 fi
48         # Also check to make sure they aren't enabling it when they don't need to
49         else
50                 if use sec_perm ; then
51                         eerror "${PN} does not require the sec_perm patch to be applied to your kernel."
52                         eerror "Please disabe the sec_perm USE flag: USE=\"-sec_perm\"."
53                         die "Invalid configuration"
54                 fi
55         fi
56
57         # Check for applicability of lhash patch for NFS branch support
58         # Check if lhash Patch has to be applied
59         if use nfs && kernel_is ge 2 6 19 ; then
60                 APPLY_LHASH_PATCH="n"
61                 # If lhash patch is not applied
62                 if ! grep -qs "EXPORT_SYMBOL(__lookup_hash);" "${KV_DIR}/fs/namei.c" \
63                 && ! grep -qs "struct dentry * __lookup_hash(struct qstr *name, struct dentry * base, struct nameidata *nd);" "${KV_DIR}/fs/namei.h" ; then
64                         APPLY_LHASH_PATCH="y"
65                         APPLY_KERNEL_PATCH="y"
66                 fi
67         fi
68
69         # If a patch has to be applied
70         if [[ ${APPLY_KERNEL_PATCH} == "y" ]] ; then
71                 ewarn "Patching your kernel..."
72                 cd ${KV_DIR}
73
74                 # If the sec_perm patch has to be applied
75                 if [[ ${APPLY_SEC_PERM_PATCH} == "y" ]] ; then
76                         epatch "${FILESDIR}"/${PN}-20081208-sec_perm-2.6.24.patch
77                 fi
78
79                 # if the lhash patch has to be applied
80                 if [[ ${APPLY_LHASH_PATCH} == "y" ]] ; then
81                         if kernel_is ge 2 6 24 ; then
82                                 epatch "${FILESDIR}"/${PN}-lhash-2.6.24.patch
83                         else
84                                 if kernel_is ge 2 6 22 ; then
85                                         epatch "${FILESDIR}"/${PN}-lhash-2.6.22.patch
86                                 else
87                                         epatch "${FILESDIR}"/${PN}-lhash-2.6.19.patch
88                                 fi
89                         fi
90                 fi
91         fi
92
93         linux-mod_pkg_setup
94 }
95
96 src_unpack(){
97         unpack ${A}
98         cd "${S}"
99
100         # Enable hinotify in priv_def.mk
101         if use hinotify && kernel_is ge 2 6 18 ; then
102                 echo "CONFIG_AUFS_HINOTIFY = y" >> priv_def.mk || die "setting hinotify in priv_def.mk failed!"
103         fi
104
105         # Disable SYSAUFS for kernel less than 2.6.18
106         if kernel_is lt 2 6 18 ; then
107                 echo "CONFIG_AUFS_SYSAUFS = " >> priv_def.mk || die "unsetting sysaufs in priv_def.mk failed!"
108         fi
109
110         # Enable nfsexport in priv_def.mk
111         if use nfsexport && kernel_is ge 2 6 18 ; then
112                 echo "CONFIG_AUFS_EXPORT = y" >> priv_def.mk || die "setting export in priv_def.mk failed!"
113         fi
114
115         # Enable lhash Patch in priv_def.mk
116         if use nfs && kernel_is ge 2 6 19 ; then
117                 echo "CONFIG_AUFS_LHASH_PATCH = y" >> priv_def.mk || die "setting lhash in priv_def.mk failed!"
118         fi
119
120         # Enable aufs readonly-branch in priv_def.mk
121         if use robr ; then
122                 echo "CONFIG_AUFS_ROBR = y" >> priv_def.mk || die "setting robr in priv_def.mk failed!"
123         fi
124
125         # Enable FUSE workaround for AUFS
126         if use fuse ; then
127                 echo "CONFIG_AUFS_WORKAROUND_FUSE = y" >> priv_def.mk || die "setting workaround_fuse in priv_def.mk failed!"
128         fi
129
130         # Enable / Disable debugging
131         if use debug ; then
132                 echo "CONFIG_AUFS_DEBUG = y" >> priv_def.mk || die "setting debug in priv_dev.mk failed!"
133         else
134                 echo "CONFIG_AUFS_DEBUG = " >> priv_def.mk || die "setting debug in priv_dev.mk failed!"
135         fi
136
137         # Check if a vserver-kernel is installed
138         if [[ -e ${KV_DIR}/include/linux/vserver ]] ; then
139                 einfo "vserver kernel seems to be installed"
140                 einfo "using vserver patch"
141                 echo "AUFS_DEF_CONFIG = -DVSERVER" >> priv_def.mk || die "setting vserver in priv_def.mk failed!"
142         fi
143 }
144
145 src_compile() {
146         use x86 && ARCH=i386
147         use amd64 && ARCH=x86_64
148         emake KDIR=${KV_DIR} SUBLEVEL=${KV_PATCH} -f local.mk || die "emake failed"
149 }
150
151 src_install() {
152         cd util
153         exeinto /sbin
154         exeopts -m0500
155         doexe mount.aufs umount.aufs auplink aulchown || die
156         doman aufs.5 || die
157         insinto /etc/default
158         newins etc_default_aufs aufs || die
159         linux-mod_src_install
160 }
161
162 pkg_postinst() {
163         elog "To be able to use aufs, you have to load the kernel module by typing:"
164         elog "modprobe aufs"
165         elog "For further information refer to the aufs man page"
166
167         if use sec_perm || use nfs ; then
168                 ewarn "Your kernel has been patched in order to export security"
169                 ewarn "permissions.  You will need to recompile your kernel with"
170                 ewarn "this new patch in order for ${PN} to function."
171         fi
172
173         linux-mod_pkg_postinst
174 }