1 # Copyright 1999-2015 Gentoo Foundation
2 # Distributed under the terms of the GNU General Public License v2
5 PYTHON_COMPAT=( python{2_7,3_4,3_5} )
8 AUTOTOOLS_AUTORECONF="1"
9 AUTOTOOLS_IN_SOURCE_BUILD="1"
11 if [ ${PV} == "9999" ] ; then
12 inherit git-r3 linux-mod
13 AUTOTOOLS_AUTORECONF="1"
14 EGIT_REPO_URI="git://github.com/zfsonlinux/${PN}.git"
16 SRC_URI="https://github.com/zfsonlinux/${PN}/releases/download/${P}/${P}.tar.gz
17 https://dev.gentoo.org/~ryao/dist/${P}-patches-p2.tar.xz"
18 KEYWORDS="~amd64 ~arm ~ppc ~ppc64"
21 inherit autotools-utils bash-completion-r1 flag-o-matic linux-info python-r1 systemd toolchain-funcs udev
23 DESCRIPTION="Userland utilities for ZFS Linux kernel module"
24 HOMEPAGE="http://zfsonlinux.org/"
26 LICENSE="BSD-2 CDDL MIT"
28 IUSE="custom-cflags debug kernel-builtin +rootfs test-suite static-libs"
32 sys-apps/util-linux[static-libs?]
33 sys-libs/zlib[static-libs(+)?]
36 DEPEND="${COMMON_DEPEND}
40 RDEPEND="${COMMON_DEPEND}
43 =sys-fs/zfs-kmod-${PV}*
44 !<sys-fs/zfs-kmod-0.6.5.3-r1
47 !prefix? ( virtual/udev )
60 !<sys-boot/grub-2.00-r2:2
62 !>=sys-fs/udev-init-scripts-28
66 AUTOTOOLS_IN_SOURCE_BUILD="1"
69 if use kernel_linux && use test-suite; then
71 if ! linux_config_exists; then
72 ewarn "Cannot check the linux kernel configuration."
74 # recheck that we don't have usblp to collide with libusb
75 if use test-suite; then
76 if linux_chkconfig_present BLK_DEV_LOOP; then
77 eerror "The ZFS test suite requires loop device support enabled."
78 eerror "Please enable it:"
79 eerror " CONFIG_BLK_DEV_LOOP=y"
80 eerror "in /usr/src/linux/.config or"
81 eerror " Device Drivers --->"
82 eerror " Block devices --->"
83 eerror " [ ] Loopback device support"
92 if [ ${PV} != "9999" ]
95 EPATCH_SUFFIX="patch" \
97 epatch "${WORKDIR}/${P}-patches"
101 sed -e "s|/sbin/lsmod|/bin/lsmod|" \
102 -e "s|/usr/bin/scsi-rescan|/usr/sbin/rescan-scsi-bus|" \
103 -e "s|/sbin/parted|/usr/sbin/parted|" \
104 -i scripts/common.sh.in
106 autotools-utils_src_prepare
110 use custom-cflags || strip-flags
112 --bindir="${EPREFIX}/bin"
113 --sbindir="${EPREFIX}/sbin"
115 --with-dracutdir="/usr/$(get_libdir)/dracut"
116 --with-linux="${KV_DIR}"
117 --with-linux-obj="${KV_OUT_DIR}"
118 --with-udevdir="$(get_udevdir)"
122 autotools-utils_src_configure
124 # prepare systemd unit and helper script
125 cat "${FILESDIR}/zfs.service.in" | \
126 sed -e "s:@sbindir@:${EPREFIX}/sbin:g" \
127 -e "s:@sysconfdir@:${EPREFIX}/etc:g" \
128 > "${T}/zfs.service" || die
129 cat "${FILESDIR}/zfs-init.sh.in" | \
130 sed -e "s:@sbindir@:${EPREFIX}/sbin:g" \
131 -e "s:@sysconfdir@:${EPREFIX}/etc:g" \
132 > "${T}/zfs-init.sh" || die
136 autotools-utils_src_install
137 gen_usr_ldscript -a uutil nvpair zpool zfs zfs_core
138 use test-suite || rm -rf "${ED}usr/share/zfs"
140 newbashcomp "${FILESDIR}/bash-completion-r1" zfs
141 bashcomp_alias zfs zpool
144 doexe "${T}/zfs-init.sh"
145 systemd_dounit "${T}/zfs.service"
149 if ! use kernel-builtin && [ ${PV} = "9999" ]
151 einfo "Adding ${P} to the module database to ensure that the"
152 einfo "kernel modules and userland utilities stay in sync."
156 if [ -e "${EROOT}etc/runlevels/boot/zfs" ]
158 einfo 'The zfs boot script has been split into the zfs-import,'
159 einfo 'zfs-mount and zfs-share scripts.'
161 einfo 'You had the zfs script in your boot runlevel. For your'
162 einfo 'convenience, it has been automatically removed and the three'
163 einfo 'scripts that replace it have been configured to start.'
164 einfo 'The zfs-import and zfs-mount scripts have been added to the boot'
165 einfo 'runlevel while the zfs-share script is in the default runlevel.'
167 rm "${EROOT}etc/runlevels/boot/zfs"
168 ln -snf "${EROOT}etc/init.d/zfs-import" \
169 "${EROOT}etc/runlevels/boot/zfs-import"
170 ln -snf "${EROOT}etc/init.d/zfs-mount" \
171 "${EROOT}etc/runlevels/boot/zfs-mount"
172 ln -snf "${EROOT}etc/init.d/zfs-share" \
173 "${EROOT}etc/runlevels/default/zfs-share"
175 [ -e "${EROOT}etc/runlevels/boot/zfs-import" ] || \
176 einfo "You should add zfs-import to the boot runlevel."
177 [ -e "${EROOT}etc/runlevels/boot/zfs-mount" ] || \
178 einfo "You should add zfs-mount to the boot runlevel."
179 [ -e "${EROOT}etc/runlevels/default/zfs-share" ] || \
180 einfo "You should add zfs-share to the default runlevel."
183 if [ -e "${EROOT}etc/runlevels/default/zed" ]
185 einfo 'The downstream OpenRC zed script has replaced by the upstream'
186 einfo 'OpenRC zfs-zed script.'
188 einfo 'You had the zed script in your default runlevel. For your'
189 einfo 'convenience, it has been automatically removed and the zfs-zed'
190 einfo 'script that replaced it has been configured to start.'
192 rm "${EROOT}etc/runlevels/boot/zed"
193 ln -snf "${EROOT}etc/init.d/zfs-sed" \
194 "${EROOT}etc/runlevels/default/zfs-zed"
196 [ -e "${EROOT}etc/runlevels/default/zfs-zed" ] || \
197 einfo "You should add zfs-zed to the default runlevel."
200 if [ -e "${EROOT}etc/runlevels/shutdown/zfs-shutdown" ]
202 einfo "The zfs-shutdown script is obsolete. Removing it from runlevel."
203 rm "${EROOT}etc/runlevels/shutdown/zfs-shutdown"
206 einfo "sys-kernel/spl-0.6.5.3-r1, sys-fs/zfs-kmod-0.6.5.3-r1 and "
207 einfo "sys-fs/zfs-0.6.5.3-r1 have introduced a partial stable "
208 einfo "/dev/zfs API developed by ClusterHQ. This means that situations "
209 einfo "arising from the kernel modules and userland tools being "
210 einfo "mismatched on future updates will not cause problems."
212 einfo "In specific, this should solve the failure to mount filesystems when "
213 einfo "old modules are cached in an old initramfs provided that those "
214 einfo "modules support this API"
218 ewarn "The older modules will *NOT* work with the new userland code."
219 ewarn "It is very important that you update your initramfs after this "
225 if ! use kernel-builtin && [ ${PV} = "9999" ]