Use https by default
[gentoo.git] / sys-fs / aufs4 / aufs4-0_pre20150420.ebuild
1 # Copyright 1999-2015 Gentoo Foundation
2 # Distributed under the terms of the GNU General Public License v2
3 # $Id$
4
5 EAPI=5
6
7 inherit eutils flag-o-matic linux-info linux-mod multilib readme.gentoo toolchain-funcs
8
9 AUFS_VERSION="${PV%%_p*}"
10 # highest branch version
11 PATCH_MAX_VER=0
12 # highest supported version
13 KERN_MAX_VER=1
14 # lowest supported version
15 KERN_MIN_VER=0
16
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"
20
21 LICENSE="GPL-2"
22 SLOT="0"
23 KEYWORDS="~amd64 ~x86"
24 IUSE="debug doc fuse hfs inotify kernel-patch nfs pax_kernel ramfs"
25
26 DEPEND="
27         dev-util/patchutils
28         dev-vcs/git"
29 RDEPEND="
30         sys-fs/aufs-util
31         !sys-fs/aufs
32         !sys-fs/aufs2
33         !sys-fs/aufs3"
34
35 S="${WORKDIR}"/${PN}-standalone
36
37 MODULE_NAMES="aufs(misc:${S})"
38
39 pkg_setup() {
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"
46
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
49
50         get_version
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"
53
54         linux-mod_pkg_setup
55
56         if [[ "${KV_MINOR}" -gt "${PATCH_MAX_VER}" ]]; then
57                 PATCH_BRANCH="x-rcN"
58         else
59                 PATCH_BRANCH="${KV_MINOR}"
60         fi
61
62         case ${KV_EXTRA} in
63                         "")
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"
67                         ;;
68                         "-gentoo")
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"
72                         ;;
73         esac
74
75         pushd "${T}" &> /dev/null
76         unpack ${A}
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
85                         cd ${KV_DIR}
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"
91                 else
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"
96                 fi
97         fi
98         popd &> /dev/null
99         export PKG_SETUP_HAS_BEEN_RAN=1
100 }
101
102 set_config() {
103         for option in $*; do
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
106         done
107 }
108
109 src_prepare() {
110         local module_branch=origin/${PN}.${PATCH_BRANCH}
111
112         einfo "Using for module creation branch ${module_branch}"
113         git checkout -q -b local-gentoo ${module_branch} || die
114
115         # All config options to off
116         sed "s:= y:=:g" -i config.mk || die
117
118         set_config RDU BRANCH_MAX_127 SBILIST
119
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
127
128         if use pax_kernel; then
129                 epatch "${FILESDIR}"/pax-4.patch
130         fi
131
132         sed -i "s:aufs.ko usr/include/linux/aufs_type.h:aufs.ko:g" Makefile || die
133 }
134
135 src_compile() {
136         local ARCH=x86
137
138         emake \
139                 CC=$(tc-getCC) \
140                 LD=$(tc-getLD) \
141                 LDFLAGS="$(raw-ldflags)" \
142                 ARCH=$(tc-arch-kernel) \
143                 CONFIG_AUFS_FS=m \
144                 KDIR="${KV_OUT_DIR}"
145 }
146
147 src_install() {
148         linux-mod_src_install
149
150         insinto /usr/share/doc/${PF}
151
152         use doc && doins -r Documentation
153
154         use kernel-patch || doins "${T}"/${PN}-standalone/${PN}-standalone-base-mmap-combined.patch
155
156         dodoc Documentation/filesystems/aufs/README "${T}"/${PN}-standalone/{aufs4-loopback,vfs-ino,tmpfs-idr}.patch
157
158         readme.gentoo_create_doc
159 }
160
161 pkg_postinst() {
162         readme.gentoo_pkg_postinst
163         linux-mod_pkg_postinst
164 }