1 # Copyright 1999-2018 Gentoo Foundation
2 # Distributed under the terms of the GNU General Public License v2
5 PYTHON_COMPAT=( python{2_7,3_4,3_5,3_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
13 SRC_URI="https://github.com/zfsonlinux/${PN}/releases/download/${P}/${P}.tar.gz"
14 KEYWORDS="~amd64 ~arm ~ppc ~ppc64"
17 inherit autotools-utils bash-completion-r1 flag-o-matic linux-info python-r1 systemd toolchain-funcs udev
19 DESCRIPTION="Userland utilities for ZFS Linux kernel module"
20 HOMEPAGE="http://zfsonlinux.org/"
22 LICENSE="BSD-2 CDDL MIT"
24 IUSE="custom-cflags debug kernel-builtin +rootfs test-suite static-libs"
29 sys-apps/util-linux[static-libs?]
30 sys-libs/zlib[static-libs(+)?]
33 DEPEND="${COMMON_DEPEND}
37 RDEPEND="${COMMON_DEPEND}
39 !kernel-builtin? ( =sys-fs/zfs-kmod-${PV}* )
41 !prefix? ( virtual/udev )
54 !<sys-boot/grub-2.00-r2:2
59 AUTOTOOLS_IN_SOURCE_BUILD="1"
62 if use kernel_linux && use test-suite; then
64 if ! linux_config_exists; then
65 ewarn "Cannot check the linux kernel configuration."
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"
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
91 autotools-utils_src_prepare
95 use custom-cflags || strip-flags
97 --bindir="${EPREFIX}/bin"
98 --sbindir="${EPREFIX}/sbin"
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"
108 autotools-utils_src_configure
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
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"
126 newbashcomp "${FILESDIR}/bash-completion-r1" zfs
127 bashcomp_alias zfs zpool
130 doexe "${T}/zfs-init.sh"
131 systemd_dounit "${T}/zfs.service"
135 if ! use kernel-builtin && [[ ${PV} = *"9999" ]]
137 einfo "Adding ${P} to the module database to ensure that the"
138 einfo "kernel modules and userland utilities stay in sync."
142 if [ -e "${EROOT}etc/runlevels/boot/zfs" ]
144 einfo 'The zfs boot script has been split into the zfs-import,'
145 einfo 'zfs-mount and zfs-share scripts.'
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.'
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"
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."
169 if [ -e "${EROOT}etc/runlevels/default/zed" ]
171 einfo 'The downstream OpenRC zed script has replaced by the upstream'
172 einfo 'OpenRC zfs-zed script.'
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.'
178 rm "${EROOT}etc/runlevels/boot/zed"
179 ln -snf "${EROOT}etc/init.d/zfs-sed" \
180 "${EROOT}etc/runlevels/default/zfs-zed"
182 [ -e "${EROOT}etc/runlevels/default/zfs-zed" ] || \
183 einfo "You should add zfs-zed to the default runlevel."
186 if [ -e "${EROOT}etc/runlevels/shutdown/zfs-shutdown" ]
188 einfo "The zfs-shutdown script is obsolete. Removing it from runlevel."
189 rm "${EROOT}etc/runlevels/shutdown/zfs-shutdown"
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
204 if ! use kernel-builtin && [[ ${PV} = *"9999" ]]