add zfs 0.7 snapshot
[portage-squeep] / sys-fs / zfs / zfs-0.7.13-r1.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="amd64"
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 pkg_setup() {
69 python-single-r1_pkg_setup
70 if use kernel_linux && use test-suite; then
71 linux-info_pkg_setup
72 if ! linux_config_exists; then
73 ewarn "Cannot check the linux kernel configuration."
74 else
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"
85 fi
86 fi
87 fi
88 fi
89 }
90
91 src_prepare() {
92 # Update paths
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
97
98 autotools-utils_src_prepare
99 }
100
101 src_configure() {
102 use custom-cflags || strip-flags
103 local myeconfargs=(
104 --bindir="${EPREFIX}/bin"
105 --sbindir="${EPREFIX}/sbin"
106 --with-config=user
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"
113 $(use_enable debug)
114 $(use_enable systemd)
115 )
116 autotools-utils_src_configure
117
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
127 }
128
129 src_install() {
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"
133
134 newbashcomp "${FILESDIR}/bash-completion-r1" zfs
135 bashcomp_alias zfs zpool
136
137 exeinto /usr/libexec
138 doexe "${T}/zfs-init.sh"
139 systemd_dounit "${T}/zfs.service"
140
141 # enforce selected python implementation
142 python_fix_shebang "${ED}/bin"
143 }
144
145 pkg_postinst() {
146 if ! use kernel-builtin && [ ${PV} = "9999" ]
147 then
148 einfo "Adding ${P} to the module database to ensure that the"
149 einfo "kernel modules and userland utilities stay in sync."
150 update_moduledb
151 fi
152
153 if [ -e "${EROOT}etc/runlevels/boot/zfs" ]
154 then
155 einfo 'The zfs boot script has been split into the zfs-import,'
156 einfo 'zfs-mount and zfs-share scripts.'
157 einfo
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.'
163
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"
171 else
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."
178 fi
179
180 if [ -e "${EROOT}etc/runlevels/default/zed" ]
181 then
182 einfo 'The downstream OpenRC zed script has replaced by the upstream'
183 einfo 'OpenRC zfs-zed script.'
184 einfo
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.'
188
189 rm "${EROOT}etc/runlevels/boot/zed"
190 ln -snf "${EROOT}etc/init.d/zfs-sed" \
191 "${EROOT}etc/runlevels/default/zfs-zed"
192 else
193 [ -e "${EROOT}etc/runlevels/default/zfs-zed" ] || \
194 einfo "You should add zfs-zed to the default runlevel."
195 fi
196
197 if [ -e "${EROOT}etc/runlevels/shutdown/zfs-shutdown" ]
198 then
199 einfo "The zfs-shutdown script is obsolete. Removing it from runlevel."
200 rm "${EROOT}etc/runlevels/shutdown/zfs-shutdown"
201 fi
202
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
211 }
212
213 pkg_postrm() {
214 if ! use kernel-builtin && [ ${PV} = "9999" ]
215 then
216 remove_moduledb
217 fi
218 }