Merge remote-tracking branch 'jirutka/lxc-grsec'
[gentoo.git] / sys-fs / zfs / zfs-0.6.5.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 PYTHON_COMPAT=( python{2_7,3_3,3_4} )
7
8 inherit python-r1
9
10 AT_M4DIR="config"
11 AUTOTOOLS_AUTORECONF="1"
12 AUTOTOOLS_IN_SOURCE_BUILD="1"
13
14 if [ ${PV} == "9999" ] ; then
15         inherit git-2 linux-mod
16         EGIT_REPO_URI="git://github.com/zfsonlinux/${PN}.git"
17 else
18         inherit eutils versionator
19         SRC_URI="https://github.com/zfsonlinux/${PN}/archive/${P}.tar.gz"
20         S="${WORKDIR}/${PN}-${P}"
21         KEYWORDS="~amd64 ~arm ~ppc ~ppc64"
22 fi
23
24 inherit bash-completion-r1 flag-o-matic toolchain-funcs autotools-utils udev systemd
25
26 DESCRIPTION="Userland utilities for ZFS Linux kernel module"
27 HOMEPAGE="http://zfsonlinux.org/"
28
29 LICENSE="BSD-2 CDDL bash-completion? ( MIT )"
30 SLOT="0"
31 IUSE="bash-completion custom-cflags debug kernel-builtin +rootfs test-suite static-libs"
32 RESTRICT="test"
33
34 COMMON_DEPEND="
35         sys-apps/util-linux[static-libs?]
36         sys-libs/zlib[static-libs(+)?]
37         virtual/awk
38 "
39 DEPEND="${COMMON_DEPEND}
40         virtual/pkgconfig
41 "
42
43 RDEPEND="${COMMON_DEPEND}
44         !=sys-apps/grep-2.13*
45         !kernel-builtin? ( =sys-fs/zfs-kmod-${PV}* )
46         !sys-fs/zfs-fuse
47         !prefix? ( virtual/udev )
48         test-suite? (
49                 sys-apps/util-linux
50                 sys-devel/bc
51                 sys-block/parted
52                 sys-fs/lsscsi
53                 sys-fs/mdadm
54                 sys-process/procps
55                 virtual/modutils
56                 )
57         rootfs? (
58                 app-arch/cpio
59                 app-misc/pax-utils
60                 !<sys-boot/grub-2.00-r2:2
61                 )
62         !>=sys-fs/udev-init-scripts-28
63 "
64
65 pkg_setup() {
66         :
67 }
68
69 src_prepare() {
70         # Update paths
71         sed -e "s|/sbin/lsmod|/bin/lsmod|" \
72                 -e "s|/usr/bin/scsi-rescan|/usr/sbin/rescan-scsi-bus|" \
73                 -e "s|/sbin/parted|/usr/sbin/parted|" \
74                 -i scripts/common.sh.in
75
76         autotools-utils_src_prepare
77 }
78
79 src_configure() {
80         use custom-cflags || strip-flags
81         local myeconfargs=(
82                 --bindir="${EPREFIX}/bin"
83                 --sbindir="${EPREFIX}/sbin"
84                 --with-config=user
85                 --with-linux="${KV_DIR}"
86                 --with-linux-obj="${KV_OUT_DIR}"
87                 --with-udevdir="$(get_udevdir)"
88                 --with-blkid
89                 $(use_enable debug)
90         )
91         autotools-utils_src_configure
92
93         # prepare systemd unit and helper script
94         cat "${FILESDIR}/zfs.service.in" | \
95                 sed -e "s:@sbindir@:${EPREFIX}/sbin:g" \
96                         -e "s:@sysconfdir@:${EPREFIX}/etc:g" \
97                 > "${T}/zfs.service" || die
98         cat "${FILESDIR}/zfs-init.sh.in" | \
99                 sed -e "s:@sbindir@:${EPREFIX}/sbin:g" \
100                         -e "s:@sysconfdir@:${EPREFIX}/etc:g" \
101                 > "${T}/zfs-init.sh" || die
102 }
103
104 src_install() {
105         autotools-utils_src_install
106         gen_usr_ldscript -a uutil nvpair zpool zfs zfs_core
107         rm -rf "${ED}usr/lib/dracut"
108         use test-suite || rm -rf "${ED}usr/share/zfs"
109
110         use bash-completion && newbashcomp "${FILESDIR}/bash-completion-r1" zfs
111
112         exeinto /usr/libexec
113         doexe "${T}/zfs-init.sh"
114         systemd_dounit "${T}/zfs.service"
115         doinitd "${FILESDIR}/zed"
116 }
117
118 pkg_postinst() {
119
120         if ! use kernel-builtin && [ ${PV} = "9999" ]
121         then
122                 einfo "Adding ${P} to the module database to ensure that the"
123                 einfo "kernel modules and userland utilities stay in sync."
124                 update_moduledb
125         fi
126
127         if [ -e "${EROOT}etc/runlevels/boot/zfs" ]
128         then
129                 einfo 'The zfs boot script has been split into the zfs-import,'
130                 einfo 'zfs-mount and zfs-share scripts, with zed being added in the'
131                 einfo 'form of a fourth script.'
132                 einfo
133                 einfo 'You had the zfs script in your boot runlevel. For your'
134                 einfo 'convenience, it has been automatically removed and the three'
135                 einfo 'scripts that replace it have been configured to start.'
136                 einfo 'The zfs-import and zfs-mount scripts have been added to the boot'
137                 einfo 'runlevel while the zfs-share script is in the default runlevel.'
138
139                 rm "${EROOT}etc/runlevels/boot/zfs"
140                 ln -snf "${EROOT}etc/init.d/zfs-import" \
141                         "${EROOT}etc/runlevels/boot/zfs-import"
142                 ln -snf "${EROOT}etc/init.d/zfs-mount" \
143                         "${EROOT}etc/runlevels/boot/zfs-mount"
144                 ln -snf "${EROOT}etc/init.d/zfs-share" \
145                         "${EROOT}etc/runlevels/default/zfs-share"
146         else
147                 [ -e "${EROOT}etc/runlevels/boot/zfs-import" ] || \
148                         einfo "You should add zfs-import to the boot runlevel."
149                 [ -e "${EROOT}etc/runlevels/boot/zfs-mount" ] || \
150                         einfo "You should add zfs-mount to the boot runlevel."
151                 [ -e "${EROOT}etc/runlevels/default/zfs-share" ] || \
152                         einfo "You should add zfs-share to the default runlevel."
153         fi
154
155         [ -e "${EROOT}etc/runlevels/default/zfs-zed" ] || \
156                 einfo "You should add zfs-zed to the default runlevel."
157
158         if [ -e "${EROOT}etc/runlevels/shutdown/zfs-shutdown" ]
159         then
160                 einfo "The zfs-shutdown script is obsolete. Removing it from runlevel."
161                 rm "${EROOT}etc/runlevels/shutdown/zfs-shutdown"
162         fi
163
164 }
165
166 pkg_postrm() {
167         if ! use kernel-builtin && [ ${PV} = "9999" ]
168         then
169                 remove_moduledb
170         fi
171 }