1 # Copyright 1999-2020 Gentoo Authors
2 # Distributed under the terms of the GNU General Public License v2
7 PYTHON_COMPAT=( python{2_7,3_{6,7}} )
9 inherit bash-completion-r1 flag-o-matic linux-info linux-mod distutils-r1 systemd toolchain-funcs udev usr-ldscript
11 DESCRIPTION="Userland utilities for ZFS Linux kernel module"
12 HOMEPAGE="https://zfsonlinux.org/"
14 if [[ ${PV} == "9999" ]] ; then
15 inherit autotools git-r3
16 EGIT_REPO_URI="https://github.com/zfsonlinux/zfs.git"
18 SRC_URI="https://github.com/zfsonlinux/${PN}/releases/download/${P}/${P}.tar.gz"
19 KEYWORDS="~amd64 ~arm64 ~ppc64"
22 LICENSE="BSD-2 CDDL MIT"
24 IUSE="custom-cflags debug kernel-builtin libressl python +rootfs test-suite static-libs"
28 net-libs/libtirpc[static-libs?]
29 sys-apps/util-linux[static-libs?]
30 sys-libs/zlib[static-libs(+)?]
32 virtual/libudev[static-libs(-)?]
33 libressl? ( dev-libs/libressl:0=[static-libs?] )
34 !libressl? ( dev-libs/openssl:0=[static-libs?] )
36 virtual/python-cffi[${PYTHON_USEDEP}]
43 dev-python/setuptools[${PYTHON_USEDEP}]
49 !kernel-builtin? ( ~sys-fs/zfs-kmod-${PV} )
51 !prefix? ( virtual/udev )
52 sys-fs/udev-init-scripts
56 !<sys-boot/grub-2.00-r2:2
57 !<sys-kernel/genkernel-3.5.1.1
58 !<sys-kernel/genkernel-next-67
59 !<sys-kernel/bliss-initramfs-7.1.0
60 !<sys-kernel/dracut-044-r1
73 REQUIRED_USE="${PYTHON_REQUIRED_USE}"
77 PATCHES=( "${FILESDIR}/bash-completion-sudo.patch" )
80 if use kernel_linux && use test-suite; then
83 if ! linux_config_exists; then
84 ewarn "Cannot check the linux kernel configuration."
86 if use test-suite; then
87 if linux_chkconfig_present BLK_DEV_LOOP; then
88 eerror "The ZFS test suite requires loop device support enabled."
89 eerror "Please enable it:"
90 eerror " CONFIG_BLK_DEV_LOOP=y"
91 eerror "in /usr/src/linux/.config or"
92 eerror " Device Drivers --->"
93 eerror " Block devices --->"
94 eerror " [X] Loopback device support"
104 if [[ ${PV} == "9999" ]]; then
107 # Set revision number
108 sed -i "s/\(Release:\)\(.*\)1/\1\2${PR}-gentoo/" META || die "Could not set Gentoo release"
112 pushd contrib/pyzfs >/dev/null || die
113 distutils-r1_src_prepare
114 popd >/dev/null || die
117 # prevent errors showing up on zfs-mount stop, #647688
118 # openrc will unmount all filesystems anyway.
119 sed -i "/^ZFS_UNMOUNT=/ s/yes/no/" etc/init.d/zfs.in || die
123 use custom-cflags || strip-flags
126 --bindir="${EPREFIX}/bin"
130 --localstatedir="${EPREFIX}/var"
131 --sbindir="${EPREFIX}/sbin"
133 --with-dracutdir="${EPREFIX}/usr/lib/dracut"
134 --with-linux="${KV_DIR}"
135 --with-linux-obj="${KV_OUT_DIR}"
136 --with-udevdir="$(get_udevdir)"
137 --with-systemdunitdir="$(systemd_get_systemunitdir)"
138 --with-systemdpresetdir="${EPREFIX}/lib/systemd/system-preset"
140 $(use_enable python pyzfs)
141 $(use_enable static-libs static)
150 pushd contrib/pyzfs >/dev/null || die
151 distutils-r1_src_compile
152 popd >/dev/null || die
159 gen_usr_ldscript -a uutil nvpair zpool zfs zfs_core
161 use test-suite || rm -rf "${ED}/usr/share/zfs"
163 if ! use static-libs; then
164 find "${ED}/" -name '*.la' -delete || die
167 dobashcomp contrib/bash_completion.d/zfs
168 bashcomp_alias zfs zpool
170 # strip executable bit from conf.d file
171 fperms 0644 /etc/conf.d/zfs
174 pushd contrib/pyzfs >/dev/null || die
175 distutils-r1_src_install
176 popd >/dev/null || die
179 # enforce best available python implementation
181 python_fix_shebang "${ED}/bin"
186 if ! has_version sys-kernel/genkernel && ! has_version sys-kernel/dracut; then
187 elog "root on zfs requires initramfs to boot"
188 elog "the following packages known to provide one and tested on regular basis:"
189 elog " sys-kernel/dracut"
190 elog " sys-kernel/genkernel"
193 if has_version "<=sys-kernel/genkernel-3.5.3.3"; then
194 einfo "genkernel version 3.5.3.3 and earlier does NOT support"
195 einfo " unlocking pools with native zfs encryption enabled at boot"
196 einfo " use dracut or >=genkernel-4 if you requre this functionality"
200 if ! use kernel-builtin && [[ ${PV} = "9999" ]]; then
201 einfo "Adding ${P} to the module database to ensure that the"
202 einfo "kernel modules and userland utilities stay in sync."
206 [[ -e "${EROOT}/etc/runlevels/boot/zfs-import" ]] || \
207 einfo "You should add zfs-import to the boot runlevel."
208 [[ -e "${EROOT}/etc/runlevels/boot/zfs-mount" ]]|| \
209 einfo "You should add zfs-mount to the boot runlevel."
210 [[ -e "${EROOT}/etc/runlevels/default/zfs-share" ]] || \
211 einfo "You should add zfs-share to the default runlevel."
212 [[ -e "${EROOT}/etc/runlevels/default/zfs-zed" ]] || \
213 einfo "You should add zfs-zed to the default runlevel."
217 if ! use kernel-builtin && [[ ${PV} == "9999" ]]; then