add zfs 0.7 snapshot
[portage-squeep] / sys-fs / zfs / zfs-0.7.13-r2.ebuild
1 # Copyright 1999-2020 Gentoo Authors
2 # Distributed under the terms of the GNU General Public License v2
3
4 EAPI="5"
5 PYTHON_COMPAT=( python3_6 )
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"
11 else
12 SRC_URI="https://github.com/zfsonlinux/${PN}/releases/download/${P}/${P}.tar.gz"
13 KEYWORDS=""
14 fi
15
16 inherit autotools-utils bash-completion-r1 flag-o-matic linux-info python-single-r1 systemd toolchain-funcs udev usr-ldscript
17
18 DESCRIPTION="Userland utilities for ZFS Linux kernel module"
19 HOMEPAGE="https://zfsonlinux.org/"
20
21 LICENSE="BSD-2 CDDL MIT"
22 SLOT="0"
23 IUSE="custom-cflags debug kernel-builtin +rootfs systemd test-suite static-libs"
24 RESTRICT="test"
25
26 COMMON_DEPEND="
27 net-libs/libtirpc
28 sys-apps/util-linux[static-libs?]
29 sys-libs/zlib[static-libs(+)?]
30 virtual/awk
31 "
32 DEPEND="${COMMON_DEPEND}
33 virtual/pkgconfig
34 "
35
36 RDEPEND="${COMMON_DEPEND}
37 ${PYTHON_DEPS}
38 !=sys-apps/grep-2.13*
39 !kernel-builtin? ( =sys-fs/zfs-kmod-${PV}* )
40 !sys-fs/zfs-fuse
41 !prefix? ( virtual/udev )
42 test-suite? (
43 sys-apps/util-linux
44 sys-devel/bc
45 sys-block/parted
46 sys-fs/lsscsi
47 sys-fs/mdadm
48 sys-process/procps
49 virtual/modutils
50 )
51 rootfs? (
52 app-arch/cpio
53 app-misc/pax-utils
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
59 )
60 sys-fs/udev-init-scripts
61 "
62
63 REQUIRED_USE="${PYTHON_REQUIRED_USE}"
64
65 AT_M4DIR="config"
66 AUTOTOOLS_IN_SOURCE_BUILD="1"
67
68 PATCHES=( "${FILESDIR}/0.7.13-ZPOOL_IMPORT_UDEV_TIMEOUT_MS.patch" )
69
70 pkg_setup() {
71 python-single-r1_pkg_setup
72 if use kernel_linux && use test-suite; then
73 linux-info_pkg_setup
74 if ! linux_config_exists; then
75 ewarn "Cannot check the linux kernel configuration."
76 else
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"
87 fi
88 fi
89 fi
90 fi
91 }
92
93 src_prepare() {
94 # Update paths
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
99
100 autotools-utils_src_prepare
101 }
102
103 src_configure() {
104 use custom-cflags || strip-flags
105 local myeconfargs=(
106 --bindir="${EPREFIX}/bin"
107 --sbindir="${EPREFIX}/sbin"
108 --with-config=user
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"
115 $(use_enable debug)
116 $(use_enable systemd)
117 )
118 autotools-utils_src_configure
119
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
129 }
130
131 src_install() {
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"
135
136 newbashcomp "${FILESDIR}/bash-completion-r1" zfs
137 bashcomp_alias zfs zpool
138
139 exeinto /usr/libexec
140 doexe "${T}/zfs-init.sh"
141 systemd_dounit "${T}/zfs.service"
142
143 # enforce selected python implementation
144 python_fix_shebang "${ED}/bin"
145 }
146
147 pkg_postinst() {
148 if ! use kernel-builtin && [ ${PV} = "9999" ]
149 then
150 einfo "Adding ${P} to the module database to ensure that the"
151 einfo "kernel modules and userland utilities stay in sync."
152 update_moduledb
153 fi
154
155 if [ -e "${EROOT}etc/runlevels/boot/zfs" ]
156 then
157 einfo 'The zfs boot script has been split into the zfs-import,'
158 einfo 'zfs-mount and zfs-share scripts.'
159 einfo
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.'
165
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"
173 else
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."
180 fi
181
182 if [ -e "${EROOT}etc/runlevels/default/zed" ]
183 then
184 einfo 'The downstream OpenRC zed script has replaced by the upstream'
185 einfo 'OpenRC zfs-zed script.'
186 einfo
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.'
190
191 rm "${EROOT}etc/runlevels/boot/zed"
192 ln -snf "${EROOT}etc/init.d/zfs-sed" \
193 "${EROOT}etc/runlevels/default/zfs-zed"
194 else
195 [ -e "${EROOT}etc/runlevels/default/zfs-zed" ] || \
196 einfo "You should add zfs-zed to the default runlevel."
197 fi
198
199 if [ -e "${EROOT}etc/runlevels/shutdown/zfs-shutdown" ]
200 then
201 einfo "The zfs-shutdown script is obsolete. Removing it from runlevel."
202 rm "${EROOT}etc/runlevels/shutdown/zfs-shutdown"
203 fi
204
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
213 }
214
215 pkg_postrm() {
216 if ! use kernel-builtin && [ ${PV} = "9999" ]
217 then
218 remove_moduledb
219 fi
220 }