1 # Copyright 1999-2020 Gentoo Authors
2 # Distributed under the terms of the GNU General Public License v2
5 PYTHON_COMPAT=( python3_6 )
7 if [ ${PV} == "9999" ] ; then
8 inherit git-r3 linux-mod
9 AUTOTOOLS_AUTORECONF="1"
10 EGIT_REPO_URI="git://github.com/zfsonlinux/${PN}.git"
12 SRC_URI="https://github.com/zfsonlinux/${PN}/releases/download/${P}/${P}.tar.gz"
16 inherit autotools-utils bash-completion-r1 flag-o-matic linux-info python-single-r1 systemd toolchain-funcs udev usr-ldscript
18 DESCRIPTION="Userland utilities for ZFS Linux kernel module"
19 HOMEPAGE="https://zfsonlinux.org/"
21 LICENSE="BSD-2 CDDL MIT"
23 IUSE="custom-cflags debug kernel-builtin +rootfs systemd test-suite static-libs"
28 sys-apps/util-linux[static-libs?]
29 sys-libs/zlib[static-libs(+)?]
32 DEPEND="${COMMON_DEPEND}
36 RDEPEND="${COMMON_DEPEND}
39 !kernel-builtin? ( =sys-fs/zfs-kmod-${PV}* )
41 !prefix? ( virtual/udev )
54 !<sys-boot/grub-2.00-r2:2
55 !<sys-kernel/genkernel-3.5.1.1
56 !<sys-kernel/genkernel-next-67
57 !<sys-kernel/bliss-initramfs-7.1.0
58 !<sys-kernel/dracut-044-r1
60 sys-fs/udev-init-scripts
63 REQUIRED_USE="${PYTHON_REQUIRED_USE}"
66 AUTOTOOLS_IN_SOURCE_BUILD="1"
68 PATCHES=( "${FILESDIR}/0.7.13-ZPOOL_IMPORT_UDEV_TIMEOUT_MS.patch" )
71 python-single-r1_pkg_setup
72 if use kernel_linux && use test-suite; then
74 if ! linux_config_exists; then
75 ewarn "Cannot check the linux kernel configuration."
77 # recheck that we don't have usblp to collide with libusb
78 if use test-suite; then
79 if linux_chkconfig_present BLK_DEV_LOOP; then
80 eerror "The ZFS test suite requires loop device support enabled."
81 eerror "Please enable it:"
82 eerror " CONFIG_BLK_DEV_LOOP=y"
83 eerror "in /usr/src/linux/.config or"
84 eerror " Device Drivers --->"
85 eerror " Block devices --->"
86 eerror " [ ] Loopback device support"
95 sed -e "s|/sbin/lsmod|/bin/lsmod|" \
96 -e "s|/usr/bin/scsi-rescan|/usr/sbin/rescan-scsi-bus|" \
97 -e "s|/sbin/parted|/usr/sbin/parted|" \
98 -i scripts/common.sh.in || die
100 autotools-utils_src_prepare
104 use custom-cflags || strip-flags
106 --bindir="${EPREFIX}/bin"
107 --sbindir="${EPREFIX}/sbin"
109 --with-dracutdir="${EPREFIX}/usr/lib/dracut"
110 --with-linux="${KV_DIR}"
111 --with-linux-obj="${KV_OUT_DIR}"
112 --with-udevdir="$(get_udevdir)"
113 --with-systemdunitdir="$(systemd_get_systemunitdir)"
114 --with-systemdpresetdir="${EPREFIX}/lib/systemd/system-preset"
116 $(use_enable systemd)
118 autotools-utils_src_configure
120 # prepare systemd unit and helper script
121 cat "${FILESDIR}/zfs.service.in" | \
122 sed -e "s:@sbindir@:${EPREFIX}/sbin:g" \
123 -e "s:@sysconfdir@:${EPREFIX}/etc:g" \
124 > "${T}/zfs.service" || die
125 cat "${FILESDIR}/zfs-init.sh.in" | \
126 sed -e "s:@sbindir@:${EPREFIX}/sbin:g" \
127 -e "s:@sysconfdir@:${EPREFIX}/etc:g" \
128 > "${T}/zfs-init.sh" || die
132 autotools-utils_src_install
133 gen_usr_ldscript -a uutil nvpair zpool zfs zfs_core
134 use test-suite || rm -rf "${ED}usr/share/zfs"
136 newbashcomp "${FILESDIR}/bash-completion-r1" zfs
137 bashcomp_alias zfs zpool
140 doexe "${T}/zfs-init.sh"
141 systemd_dounit "${T}/zfs.service"
143 # enforce selected python implementation
144 python_fix_shebang "${ED}/bin"
148 if ! use kernel-builtin && [ ${PV} = "9999" ]
150 einfo "Adding ${P} to the module database to ensure that the"
151 einfo "kernel modules and userland utilities stay in sync."
155 if [ -e "${EROOT}etc/runlevels/boot/zfs" ]
157 einfo 'The zfs boot script has been split into the zfs-import,'
158 einfo 'zfs-mount and zfs-share scripts.'
160 einfo 'You had the zfs script in your boot runlevel. For your'
161 einfo 'convenience, it has been automatically removed and the three'
162 einfo 'scripts that replace it have been configured to start.'
163 einfo 'The zfs-import and zfs-mount scripts have been added to the boot'
164 einfo 'runlevel while the zfs-share script is in the default runlevel.'
166 rm "${EROOT}etc/runlevels/boot/zfs"
167 ln -snf "${EROOT}etc/init.d/zfs-import" \
168 "${EROOT}etc/runlevels/boot/zfs-import"
169 ln -snf "${EROOT}etc/init.d/zfs-mount" \
170 "${EROOT}etc/runlevels/boot/zfs-mount"
171 ln -snf "${EROOT}etc/init.d/zfs-share" \
172 "${EROOT}etc/runlevels/default/zfs-share"
174 [ -e "${EROOT}etc/runlevels/boot/zfs-import" ] || \
175 einfo "You should add zfs-import to the boot runlevel."
176 [ -e "${EROOT}etc/runlevels/boot/zfs-mount" ] || \
177 einfo "You should add zfs-mount to the boot runlevel."
178 [ -e "${EROOT}etc/runlevels/default/zfs-share" ] || \
179 einfo "You should add zfs-share to the default runlevel."
182 if [ -e "${EROOT}etc/runlevels/default/zed" ]
184 einfo 'The downstream OpenRC zed script has replaced by the upstream'
185 einfo 'OpenRC zfs-zed script.'
187 einfo 'You had the zed script in your default runlevel. For your'
188 einfo 'convenience, it has been automatically removed and the zfs-zed'
189 einfo 'script that replaced it has been configured to start.'
191 rm "${EROOT}etc/runlevels/boot/zed"
192 ln -snf "${EROOT}etc/init.d/zfs-sed" \
193 "${EROOT}etc/runlevels/default/zfs-zed"
195 [ -e "${EROOT}etc/runlevels/default/zfs-zed" ] || \
196 einfo "You should add zfs-zed to the default runlevel."
199 if [ -e "${EROOT}etc/runlevels/shutdown/zfs-shutdown" ]
201 einfo "The zfs-shutdown script is obsolete. Removing it from runlevel."
202 rm "${EROOT}etc/runlevels/shutdown/zfs-shutdown"
205 systemd_reenable zfs-zed.service
206 systemd_reenable zfs-import-cache.service
207 systemd_reenable zfs-import-scan.service
208 systemd_reenable zfs-mount.service
209 systemd_reenable zfs-share.service
210 systemd_reenable zfs-import.target
211 systemd_reenable zfs.target
212 systemd_reenable zfs.service
216 if ! use kernel-builtin && [ ${PV} = "9999" ]