]> Pileus Git - ~andy/sunrise/blob - sys-fs/aufs/aufs-20070402.ebuild
sunrise/ app-portage/elog-list/elog-list-0.0.6.ebuild: Update headers for 2010
[~andy/sunrise] / sys-fs / aufs / aufs-20070402.ebuild
1 # Copyright 1999-2010 Gentoo Foundation
2 # Distributed under the terms of the GNU General Public License v2
3 # $Header: $
4
5 EAPI="2"
6
7 inherit eutils linux-mod
8
9 DESCRIPTION="An entirely re-designed and re-implemented Unionfs."
10 HOMEPAGE="http://aufs.sourceforge.net/"
11 SRC_URI="http://www.fh-kl.de/~torsten.kockler/gentoo/${P}.tar.bz2"
12
13 LICENSE="GPL-2"
14 SLOT="0"
15 KEYWORDS="~amd64 ~x86"
16 IUSE="hinotify ksize nfs nfsexport"
17
18 MODULE_NAMES="aufs(addon/fs/${PN}:)"
19 BUILD_PARAMS="KDIR=${KV_DIR} -f local.mk"
20 BUILD_TARGETS="all"
21
22 check_patch() {
23         get_version
24
25         # Check if ksize Patch has to be applied
26         if use ksize ; then
27                 APPLY_KSIZE_PATCH="n"
28                 # If ksize patch is not applied
29                 if ! grep -qs "EXPORT_SYMBOL(ksize);" "${KV_DIR}/mm/slab.c" ; then
30                         APPLY_KSIZE_PATCH="y"
31                 fi
32         fi
33
34         # Check if lhash Patch has to be applied
35         if use nfs && kernel_is ge 2 6 19 ; then
36                 APPLY_LHASH_PATCH="n"
37                 # If lhash patch is not applied
38                 if ! grep -qs "EXPORT_SYMBOL(__lookup_hash);" "${KV_DIR}/fs/namei.c" \
39                 && ! grep -qs "struct dentry * __lookup_hash(struct qstr *name, struct dentry
40                 * base, struct nameidata *nd);" "${KV_DIR}/fs/namei.h" ; then
41                         APPLY_LHASH_PATCH="y"
42                 fi
43         fi
44 }
45
46 pkg_setup() {
47         # kernel version check
48         if kernel_is lt 2 6 16 ; then
49                 eerror "${PN} is being developed and tested on linux-2.6.16 and later."
50                 eerror "Make sure you have a proper kernel version!"
51                 die "Wrong kernel version"
52         fi
53
54         check_patch
55
56         # If a patch has to be applied
57         if [[ ${APPLY_KSIZE_PATCH} == "y" ]] || [[ ${APPLY_LHASH_PATCH} == "y" ]] ; then
58                 ewarn "Patching your kernel..."
59                 cd ${KV_DIR}
60         fi
61
62         # If the ksize patch has to be applied
63         if [[ ${APPLY_KSIZE_PATCH} == "y" ]] ; then
64                 epatch "${FILESDIR}"/${P}-ksize.patch
65         fi
66
67         # If the lhash patch has to be applied
68         if [[ ${APPLY_LHASH_PATCH} == "y" ]] ; then
69                 epatch "${FILESDIR}"/${P}-lhash.patch
70         fi
71
72         linux-mod_pkg_setup
73 }
74
75 src_unpack(){
76         unpack ${A}
77         cd "${S}"
78
79         # Enable ksize Patch in priv_def.mk
80         if use ksize ; then
81                 echo "CONFIG_AUFS_KSIZE_PATCH = y" >> priv_def.mk || die "setting ksize in priv_def.mk failed!"
82         fi
83
84         # Enable lhash Patch in priv_def.mk
85         if use nfs && kernel_is ge 2 6 19 ; then
86                 echo "CONFIG_AUFS_LHASH_PATCH = y" >> priv_def.mk || die "setting lhash in priv_def.mk failed!"
87         fi
88
89         # Enable hinotify in priv_def.mk
90         if use hinotify && kernel_is ge 2 6 18 ; then
91                 echo "CONFIG_AUFS_HINOTIFY = y" >> priv_def.mk || die "setting hinotify in priv_def.mk failed!"
92         fi
93
94         # Enable nfsexport in priv_def.mk
95         if use nfsexport && kernel_is ge 2 6 18 ; then
96                 echo "CONFIG_AUFS_EXPORT = y" >> priv_def.mk || die "setting nfsexport in priv_def.mk failed!"
97         fi
98
99         # Disable SYSAUFS for kernel less than 2.6.18
100         if kernel_is lt 2 6 18 ; then
101                 echo "CONFIG_AUFS_SYSAUFS = " >> priv_def.mk || die "unsetting sysaufs in priv_def.mk failed!"
102         fi
103
104         # Check if a vserver-kernel is installed
105         if [[ -e ${KV_DIR}/include/linux/vserver ]] ; then
106                 einfo "vserver kernel seems to be installed"
107                 einfo "using vserver patch"
108                 echo "AUFS_DEF_CONFIG = -DVSERVER" >> priv_def.mk || die "setting vserver in priv_def.mk failed!"
109         fi
110 }
111
112 src_install() {
113         exeinto /sbin
114         exeopts -m0500
115         doexe mount.aufs umount.aufs auplink aulchown || die
116         doman aufs.5 || die
117         linux-mod_src_install
118 }
119
120 pkg_postinst() {
121         elog "To be able to use aufs, you have to load the kernel module by typing:"
122         elog "modprobe aufs"
123         elog "For further information refer to the aufs man page"
124
125         # Tell the user to recompile his kernel
126         if [[ ${APPLY_KSIZE_PATCH} == "y" ]] || [[ ${APPLY_LHASH_PATCH} == "y" ]] ; then
127                 echo
128                 ewarn "Remember to re-compile your kernel to make the patch(es) work"
129                 ewarn
130         fi
131
132         linux-mod_pkg_postinst
133 }
134
135 pkg_prerm() {
136         [[ $(has_version "${CATEGORY}/${PF}"[ksize]) || $(has_version
137         "${CATEGORY}"/"${PF}"[nfs])  ]] && DO_CHECK="y"
138 }
139
140 pkg_postrm() {
141         # Tell the user that his kernel has already been patched
142         if [[ DO_CHECK == "y" ]] ; then
143                 check_patch
144                 if [[ ${APPLY_KSIZE_PATCH} == "n" ]] || [[ ${APPLY_LHASH_PATCH} == "n" ]] ; then
145                         ewarn "Your kernel has been patched previously by this ebuild."
146                         ewarn "You can undo the patches by executing the following:"
147                         echo
148                         ewarn "cd ${KV_DIR}; make mrproper, re-emerge and re-compile your kernel - ${KV_FULL}"
149                 fi
150         fi
151
152         linux-mod_pkg_postrm
153 }