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"
69 python-single-r1_pkg_setup
70 if use kernel_linux && use test-suite; then
72 if ! linux_config_exists; then
73 ewarn "Cannot check the linux kernel configuration."
75 # recheck that we don't have usblp to collide with libusb
76 if use test-suite; then
77 if linux_chkconfig_present BLK_DEV_LOOP; then
78 eerror "The ZFS test suite requires loop device support enabled."
79 eerror "Please enable it:"
80 eerror " CONFIG_BLK_DEV_LOOP=y"
81 eerror "in /usr/src/linux/.config or"
82 eerror " Device Drivers --->"
83 eerror " Block devices --->"
84 eerror " [ ] Loopback device support"
93 sed -e "s|/sbin/lsmod|/bin/lsmod|" \
94 -e "s|/usr/bin/scsi-rescan|/usr/sbin/rescan-scsi-bus|" \
95 -e "s|/sbin/parted|/usr/sbin/parted|" \
96 -i scripts/common.sh.in || die
98 autotools-utils_src_prepare
102 use custom-cflags || strip-flags
104 --bindir="${EPREFIX}/bin"
105 --sbindir="${EPREFIX}/sbin"
107 --with-dracutdir="${EPREFIX}/usr/lib/dracut"
108 --with-linux="${KV_DIR}"
109 --with-linux-obj="${KV_OUT_DIR}"
110 --with-udevdir="$(get_udevdir)"
111 --with-systemdunitdir="$(systemd_get_systemunitdir)"
112 --with-systemdpresetdir="${EPREFIX}/lib/systemd/system-preset"
114 $(use_enable systemd)
116 autotools-utils_src_configure
118 # prepare systemd unit and helper script
119 cat "${FILESDIR}/zfs.service.in" | \
120 sed -e "s:@sbindir@:${EPREFIX}/sbin:g" \
121 -e "s:@sysconfdir@:${EPREFIX}/etc:g" \
122 > "${T}/zfs.service" || die
123 cat "${FILESDIR}/zfs-init.sh.in" | \
124 sed -e "s:@sbindir@:${EPREFIX}/sbin:g" \
125 -e "s:@sysconfdir@:${EPREFIX}/etc:g" \
126 > "${T}/zfs-init.sh" || die
130 autotools-utils_src_install
131 gen_usr_ldscript -a uutil nvpair zpool zfs zfs_core
132 use test-suite || rm -rf "${ED}usr/share/zfs"
134 newbashcomp "${FILESDIR}/bash-completion-r1" zfs
135 bashcomp_alias zfs zpool
138 doexe "${T}/zfs-init.sh"
139 systemd_dounit "${T}/zfs.service"
141 # enforce selected python implementation
142 python_fix_shebang "${ED}/bin"
146 if ! use kernel-builtin && [ ${PV} = "9999" ]
148 einfo "Adding ${P} to the module database to ensure that the"
149 einfo "kernel modules and userland utilities stay in sync."
153 if [ -e "${EROOT}etc/runlevels/boot/zfs" ]
155 einfo 'The zfs boot script has been split into the zfs-import,'
156 einfo 'zfs-mount and zfs-share scripts.'
158 einfo 'You had the zfs script in your boot runlevel. For your'
159 einfo 'convenience, it has been automatically removed and the three'
160 einfo 'scripts that replace it have been configured to start.'
161 einfo 'The zfs-import and zfs-mount scripts have been added to the boot'
162 einfo 'runlevel while the zfs-share script is in the default runlevel.'
164 rm "${EROOT}etc/runlevels/boot/zfs"
165 ln -snf "${EROOT}etc/init.d/zfs-import" \
166 "${EROOT}etc/runlevels/boot/zfs-import"
167 ln -snf "${EROOT}etc/init.d/zfs-mount" \
168 "${EROOT}etc/runlevels/boot/zfs-mount"
169 ln -snf "${EROOT}etc/init.d/zfs-share" \
170 "${EROOT}etc/runlevels/default/zfs-share"
172 [ -e "${EROOT}etc/runlevels/boot/zfs-import" ] || \
173 einfo "You should add zfs-import to the boot runlevel."
174 [ -e "${EROOT}etc/runlevels/boot/zfs-mount" ] || \
175 einfo "You should add zfs-mount to the boot runlevel."
176 [ -e "${EROOT}etc/runlevels/default/zfs-share" ] || \
177 einfo "You should add zfs-share to the default runlevel."
180 if [ -e "${EROOT}etc/runlevels/default/zed" ]
182 einfo 'The downstream OpenRC zed script has replaced by the upstream'
183 einfo 'OpenRC zfs-zed script.'
185 einfo 'You had the zed script in your default runlevel. For your'
186 einfo 'convenience, it has been automatically removed and the zfs-zed'
187 einfo 'script that replaced it has been configured to start.'
189 rm "${EROOT}etc/runlevels/boot/zed"
190 ln -snf "${EROOT}etc/init.d/zfs-sed" \
191 "${EROOT}etc/runlevels/default/zfs-zed"
193 [ -e "${EROOT}etc/runlevels/default/zfs-zed" ] || \
194 einfo "You should add zfs-zed to the default runlevel."
197 if [ -e "${EROOT}etc/runlevels/shutdown/zfs-shutdown" ]
199 einfo "The zfs-shutdown script is obsolete. Removing it from runlevel."
200 rm "${EROOT}etc/runlevels/shutdown/zfs-shutdown"
203 systemd_reenable zfs-zed.service
204 systemd_reenable zfs-import-cache.service
205 systemd_reenable zfs-import-scan.service
206 systemd_reenable zfs-mount.service
207 systemd_reenable zfs-share.service
208 systemd_reenable zfs-import.target
209 systemd_reenable zfs.target
210 systemd_reenable zfs.service
214 if ! use kernel-builtin && [ ${PV} = "9999" ]