sys-fs/lsscsi: amd64 stable wrt bug #667022
[gentoo.git] / sys-fs / zfs / zfs-0.7.9999.ebuild
1 # Copyright 1999-2018 Gentoo Foundation
2 # Distributed under the terms of the GNU General Public License v2
3
4 EAPI="5"
5 PYTHON_COMPAT=( python{2_7,3_4,3_5,3_6} )
6
7 if [[ ${PV} == *"9999" ]] ; then
8         AUTOTOOLS_AUTORECONF="1"
9         EGIT_REPO_URI="https://github.com/zfsonlinux/${PN}.git"
10         EGIT_BRANCH="zfs-0.7-release"
11         inherit git-r3 linux-mod
12 else
13         SRC_URI="https://github.com/zfsonlinux/${PN}/releases/download/${P}/${P}.tar.gz"
14         KEYWORDS="~amd64 ~arm ~ppc ~ppc64"
15 fi
16
17 inherit autotools-utils bash-completion-r1 flag-o-matic linux-info python-r1 systemd toolchain-funcs udev
18
19 DESCRIPTION="Userland utilities for ZFS Linux kernel module"
20 HOMEPAGE="http://zfsonlinux.org/"
21
22 LICENSE="BSD-2 CDDL MIT"
23 SLOT="0"
24 IUSE="custom-cflags debug kernel-builtin +rootfs test-suite static-libs"
25 RESTRICT="test"
26
27 COMMON_DEPEND="
28         net-libs/libtirpc
29         sys-apps/util-linux[static-libs?]
30         sys-libs/zlib[static-libs(+)?]
31         virtual/awk
32 "
33 DEPEND="${COMMON_DEPEND}
34         virtual/pkgconfig
35 "
36
37 RDEPEND="${COMMON_DEPEND}
38         !=sys-apps/grep-2.13*
39         !kernel-builtin? ( =sys-fs/zfs-kmod-${PV}* )
40         !sys-fs/zfs-fuse
41         !prefix? ( virtual/udev )
42         test-suite? (
43                 sys-apps/util-linux
44                 sys-devel/bc
45                 sys-block/parted
46                 sys-fs/lsscsi
47                 sys-fs/mdadm
48                 sys-process/procps
49                 virtual/modutils
50                 )
51         rootfs? (
52                 app-arch/cpio
53                 app-misc/pax-utils
54                 !<sys-boot/grub-2.00-r2:2
55                 )
56 "
57
58 AT_M4DIR="config"
59 AUTOTOOLS_IN_SOURCE_BUILD="1"
60
61 pkg_setup() {
62         if use kernel_linux && use test-suite; then
63                 linux-info_pkg_setup
64                 if  ! linux_config_exists; then
65                         ewarn "Cannot check the linux kernel configuration."
66                 else
67                         # recheck that we don't have usblp to collide with libusb
68                         if use test-suite; then
69                                 if linux_chkconfig_present BLK_DEV_LOOP; then
70                                         eerror "The ZFS test suite requires loop device support enabled."
71                                         eerror "Please enable it:"
72                                         eerror "    CONFIG_BLK_DEV_LOOP=y"
73                                         eerror "in /usr/src/linux/.config or"
74                                         eerror "    Device Drivers --->"
75                                         eerror "        Block devices --->"
76                                         eerror "            [ ] Loopback device support"
77                                 fi
78                         fi
79                 fi
80         fi
81
82 }
83
84 src_prepare() {
85         # Update paths
86         sed -e "s|/sbin/lsmod|/bin/lsmod|" \
87                 -e "s|/usr/bin/scsi-rescan|/usr/sbin/rescan-scsi-bus|" \
88                 -e "s|/sbin/parted|/usr/sbin/parted|" \
89                 -i scripts/common.sh.in
90
91         autotools-utils_src_prepare
92 }
93
94 src_configure() {
95         use custom-cflags || strip-flags
96         local myeconfargs=(
97                 --bindir="${EPREFIX}/bin"
98                 --sbindir="${EPREFIX}/sbin"
99                 --with-config=user
100                 --with-dracutdir="${EPREFIX}/usr/lib/dracut"
101                 --with-linux="${KV_DIR}"
102                 --with-linux-obj="${KV_OUT_DIR}"
103                 --with-udevdir="$(get_udevdir)"
104                 --with-systemdunitdir="$(systemd_get_systemunitdir)"
105                 --with-systemdpresetdir="${EPREFIX}/lib/systemd/system-preset"
106                 $(use_enable debug)
107         )
108         autotools-utils_src_configure
109
110         # prepare systemd unit and helper script
111         cat "${FILESDIR}/zfs.service.in" | \
112                 sed -e "s:@sbindir@:${EPREFIX}/sbin:g" \
113                         -e "s:@sysconfdir@:${EPREFIX}/etc:g" \
114                 > "${T}/zfs.service" || die
115         cat "${FILESDIR}/zfs-init.sh.in" | \
116                 sed -e "s:@sbindir@:${EPREFIX}/sbin:g" \
117                         -e "s:@sysconfdir@:${EPREFIX}/etc:g" \
118                 > "${T}/zfs-init.sh" || die
119 }
120
121 src_install() {
122         autotools-utils_src_install
123         gen_usr_ldscript -a uutil nvpair zpool zfs zfs_core
124         use test-suite || rm -rf "${ED}usr/share/zfs"
125
126         newbashcomp "${FILESDIR}/bash-completion-r1" zfs
127         bashcomp_alias zfs zpool
128
129         exeinto /usr/libexec
130         doexe "${T}/zfs-init.sh"
131         systemd_dounit "${T}/zfs.service"
132 }
133
134 pkg_postinst() {
135         if ! use kernel-builtin && [[ ${PV} = *"9999" ]]
136         then
137                 einfo "Adding ${P} to the module database to ensure that the"
138                 einfo "kernel modules and userland utilities stay in sync."
139                 update_moduledb
140         fi
141
142         if [ -e "${EROOT}etc/runlevels/boot/zfs" ]
143         then
144                 einfo 'The zfs boot script has been split into the zfs-import,'
145                 einfo 'zfs-mount and zfs-share scripts.'
146                 einfo
147                 einfo 'You had the zfs script in your boot runlevel. For your'
148                 einfo 'convenience, it has been automatically removed and the three'
149                 einfo 'scripts that replace it have been configured to start.'
150                 einfo 'The zfs-import and zfs-mount scripts have been added to the boot'
151                 einfo 'runlevel while the zfs-share script is in the default runlevel.'
152
153                 rm "${EROOT}etc/runlevels/boot/zfs"
154                 ln -snf "${EROOT}etc/init.d/zfs-import" \
155                         "${EROOT}etc/runlevels/boot/zfs-import"
156                 ln -snf "${EROOT}etc/init.d/zfs-mount" \
157                         "${EROOT}etc/runlevels/boot/zfs-mount"
158                 ln -snf "${EROOT}etc/init.d/zfs-share" \
159                         "${EROOT}etc/runlevels/default/zfs-share"
160         else
161                 [ -e "${EROOT}etc/runlevels/boot/zfs-import" ] || \
162                         einfo "You should add zfs-import to the boot runlevel."
163                 [ -e "${EROOT}etc/runlevels/boot/zfs-mount" ] || \
164                         einfo "You should add zfs-mount to the boot runlevel."
165                 [ -e "${EROOT}etc/runlevels/default/zfs-share" ] || \
166                         einfo "You should add zfs-share to the default runlevel."
167         fi
168
169         if [ -e "${EROOT}etc/runlevels/default/zed" ]
170         then
171                 einfo 'The downstream OpenRC zed script has replaced by the upstream'
172                 einfo 'OpenRC zfs-zed script.'
173                 einfo
174                 einfo 'You had the zed script in your default runlevel. For your'
175                 einfo 'convenience, it has been automatically removed and the zfs-zed'
176                 einfo 'script that replaced it has been configured to start.'
177
178                 rm "${EROOT}etc/runlevels/boot/zed"
179                 ln -snf "${EROOT}etc/init.d/zfs-sed" \
180                         "${EROOT}etc/runlevels/default/zfs-zed"
181         else
182                 [ -e "${EROOT}etc/runlevels/default/zfs-zed" ] || \
183                         einfo "You should add zfs-zed to the default runlevel."
184         fi
185
186         if [ -e "${EROOT}etc/runlevels/shutdown/zfs-shutdown" ]
187         then
188                 einfo "The zfs-shutdown script is obsolete. Removing it from runlevel."
189                 rm "${EROOT}etc/runlevels/shutdown/zfs-shutdown"
190         fi
191
192         systemd_reenable zfs-zed.service
193         systemd_reenable zfs-import-cache.service
194         systemd_reenable zfs-import-scan.service
195         systemd_reenable zfs-mount.service
196         systemd_reenable zfs-share.service
197         systemd_reenable zfs-import.target
198         systemd_reenable zfs.target
199         systemd_reenable zfs.service
200
201 }
202
203 pkg_postrm() {
204         if ! use kernel-builtin && [[ ${PV} = *"9999" ]]
205         then
206                 remove_moduledb
207         fi
208 }