1 # Copyright 1999-2020 Gentoo Authors
2 # Distributed under the terms of the GNU General Public License v2
7 PYTHON_COMPAT=( python3_{6,7} )
9 inherit autotools bash-completion-r1 flag-o-matic linux-info distutils-r1 systemd toolchain-funcs udev usr-ldscript
11 DESCRIPTION="Userland utilities for ZFS Linux kernel module"
12 HOMEPAGE="https://github.com/openzfs/zfs"
14 if [[ ${PV} == "9999" ]] ; then
15 inherit git-r3 linux-mod
16 EGIT_REPO_URI="https://github.com/openzfs/zfs.git"
18 SRC_URI="https://github.com/openzfs/${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}]
48 !kernel-builtin? ( ~sys-fs/zfs-kmod-${PV} )
49 !prefix? ( virtual/udev )
50 sys-fs/udev-init-scripts
54 !<sys-kernel/genkernel-3.5.1.1
67 REQUIRED_USE="${PYTHON_REQUIRED_USE}"
72 "${FILESDIR}/bash-completion-sudo.patch"
73 "${FILESDIR}/${PV}-initconfdir.patch"
77 if use kernel_linux && use test-suite; then
80 if ! linux_config_exists; then
81 ewarn "Cannot check the linux kernel configuration."
83 if use test-suite; then
84 if linux_chkconfig_present BLK_DEV_LOOP; then
85 eerror "The ZFS test suite requires loop device support enabled."
86 eerror "Please enable it:"
87 eerror " CONFIG_BLK_DEV_LOOP=y"
88 eerror "in /usr/src/linux/.config or"
89 eerror " Device Drivers --->"
90 eerror " Block devices --->"
91 eerror " [X] Loopback device support"
101 if [[ ${PV} == "9999" ]]; then
104 # Set revision number
105 sed -i "s/\(Release:\)\(.*\)1/\1\2${PR}-gentoo/" META || die "Could not set Gentoo release"
109 pushd contrib/pyzfs >/dev/null || die
110 distutils-r1_src_prepare
111 popd >/dev/null || die
114 # prevent errors showing up on zfs-mount stop, #647688
115 # openrc will unmount all filesystems anyway.
116 sed -i "/^ZFS_UNMOUNT=/ s/yes/no/" "etc/default/zfs.in" || die
120 use custom-cflags || strip-flags
124 --bindir="${EPREFIX}/bin"
128 --localstatedir="${EPREFIX}/var"
129 --sbindir="${EPREFIX}/sbin"
131 --with-dracutdir="${EPREFIX}/usr/lib/dracut"
132 --with-linux="${KV_DIR}"
133 --with-linux-obj="${KV_OUT_DIR}"
134 --with-udevdir="$(get_udevdir)"
135 --with-python="${EPYTHON}"
136 --with-systemdunitdir="$(systemd_get_systemunitdir)"
137 --with-systemdpresetdir="${EPREFIX}/lib/systemd/system-preset"
139 $(use_enable python pyzfs)
140 $(use_enable static-libs static)
149 pushd contrib/pyzfs >/dev/null || die
150 distutils-r1_src_compile
151 popd >/dev/null || die
158 gen_usr_ldscript -a uutil nvpair zpool zfs zfs_core
160 use test-suite || rm -rf "${ED}/usr/share/zfs"
162 if ! use static-libs; then
163 find "${ED}/" -name '*.la' -delete || die
166 dobashcomp contrib/bash_completion.d/zfs
167 bashcomp_alias zfs zpool
169 # strip executable bit from conf.d file
170 fperms 0644 /etc/conf.d/zfs
173 pushd contrib/pyzfs >/dev/null || die
174 distutils-r1_src_install
175 popd >/dev/null || die
178 # enforce best available python implementation
179 python_fix_shebang "${ED}/bin"
184 if ! has_version sys-kernel/genkernel && ! has_version sys-kernel/dracut; then
185 elog "root on zfs requires initramfs to boot"
186 elog "the following packages known to provide one and tested on regular basis:"
187 elog " sys-kernel/dracut"
188 elog " sys-kernel/genkernel"
192 if ! use kernel-builtin && [[ ${PV} = "9999" ]]; then
193 einfo "Adding ${P} to the module database to ensure that the"
194 einfo "kernel modules and userland utilities stay in sync."
198 [[ -e "${EROOT}/etc/runlevels/boot/zfs-import" ]] || \
199 einfo "You should add zfs-import to the boot runlevel."
200 [[ -e "${EROOT}/etc/runlevels/boot/zfs-mount" ]]|| \
201 einfo "You should add zfs-mount to the boot runlevel."
202 [[ -e "${EROOT}/etc/runlevels/default/zfs-share" ]] || \
203 einfo "You should add zfs-share to the default runlevel."
204 [[ -e "${EROOT}/etc/runlevels/default/zfs-zed" ]] || \
205 einfo "You should add zfs-zed to the default runlevel."
209 if ! use kernel-builtin && [[ ${PV} == "9999" ]]; then