Gentoo Archives: gentoo-commits

From: Georgy Yakovlev <gyakovlev@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] repo/gentoo:master commit in: sys-fs/zfs/, sys-fs/zfs/files/
Date: Sun, 31 Mar 2019 03:54:04
Message-Id: 1554004422.b0c6076e0f64f1a8a798b1f7b2b74a180f7eb5e8.gyakovlev@gentoo
1 commit: b0c6076e0f64f1a8a798b1f7b2b74a180f7eb5e8
2 Author: Georgy Yakovlev <gyakovlev <AT> gentoo <DOT> org>
3 AuthorDate: Sat Mar 23 04:52:57 2019 +0000
4 Commit: Georgy Yakovlev <gyakovlev <AT> gentoo <DOT> org>
5 CommitDate: Sun Mar 31 03:53:42 2019 +0000
6 URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=b0c6076e
7
8 sys-fs/zfs: rework live ebuild
9
10 major rework
11 bump eapi to 7
12 add multi-python pyzfs installation behind python useflag
13 use provided systemd unit, since upstream systemd handling changed
14 use upstream bash-completion (with local patch)
15 fix sed->zed typo in postinst code
16
17 Closes: https://bugs.gentoo.org/548856
18 Package-Manager: Portage-2.3.62, Repoman-2.3.12
19 Signed-off-by: Georgy Yakovlev <gyakovlev <AT> gentoo.org>
20
21 sys-fs/zfs/files/bash-completion-sudo.patch | 35 ++++++
22 sys-fs/zfs/zfs-9999.ebuild | 185 ++++++++++++++++------------
23 2 files changed, 138 insertions(+), 82 deletions(-)
24
25 diff --git a/sys-fs/zfs/files/bash-completion-sudo.patch b/sys-fs/zfs/files/bash-completion-sudo.patch
26 new file mode 100644
27 index 00000000000..8ae9d25d276
28 --- /dev/null
29 +++ b/sys-fs/zfs/files/bash-completion-sudo.patch
30 @@ -0,0 +1,35 @@
31 +From 3829d0b867f6aa4bde8798147dee74a86435d12c Mon Sep 17 00:00:00 2001
32 +From: Georgy Yakovlev <gyakovlev@g.o>
33 +Date: Fri, 22 Mar 2019 22:04:40 -0700
34 +Subject: [PATCH] contrib/bash_completion.d/zfs: remove sudo reference
35 +
36 +---
37 + contrib/bash_completion.d/zfs | 10 +++++-----
38 + 1 file changed, 5 insertions(+), 5 deletions(-)
39 +
40 +diff --git a/contrib/bash_completion.d/zfs b/contrib/bash_completion.d/zfs
41 +index 914db43c..b1aded36 100644
42 +--- a/contrib/bash_completion.d/zfs
43 ++++ b/contrib/bash_completion.d/zfs
44 +@@ -21,13 +21,13 @@
45 + # FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
46 + # OTHER DEALINGS IN THE SOFTWARE.
47 +
48 +-if [[ -w /dev/zfs ]]; then
49 ++#if [[ -w /dev/zfs ]]; then
50 + __ZFS_CMD="zfs"
51 + __ZPOOL_CMD="zpool"
52 +-else
53 +- __ZFS_CMD="sudo zfs"
54 +- __ZPOOL_CMD="sudo zpool"
55 +-fi
56 ++#else
57 ++# __ZFS_CMD="sudo zfs"
58 ++# __ZPOOL_CMD="sudo zpool"
59 ++#fi
60 +
61 + __zfs_get_commands()
62 + {
63 +--
64 +2.21.0
65 +
66
67 diff --git a/sys-fs/zfs/zfs-9999.ebuild b/sys-fs/zfs/zfs-9999.ebuild
68 index 0d0c1cf5b26..bde2d9e06bc 100644
69 --- a/sys-fs/zfs/zfs-9999.ebuild
70 +++ b/sys-fs/zfs/zfs-9999.ebuild
71 @@ -1,43 +1,61 @@
72 -# Copyright 1999-2018 Gentoo Authors
73 +# Copyright 1999-2019 Gentoo Authors
74 # Distributed under the terms of the GNU General Public License v2
75
76 -EAPI="5"
77 -PYTHON_COMPAT=( python{2_7,3_4,3_5,3_6} )
78 +EAPI=7
79
80 -if [ ${PV} == "9999" ] ; then
81 - inherit git-r3 linux-mod
82 - AUTOTOOLS_AUTORECONF="1"
83 - EGIT_REPO_URI="https://github.com/zfsonlinux/${PN}.git"
84 -else
85 - SRC_URI="https://github.com/zfsonlinux/${PN}/releases/download/${P}/${P}.tar.gz"
86 - KEYWORDS="~amd64 ~arm ~ppc ~ppc64"
87 -fi
88 +DISTUTILS_OPTIONAL=1
89 +PYTHON_COMPAT=( python{2_7,3_{5,6,7}} )
90
91 -inherit autotools-utils bash-completion-r1 flag-o-matic linux-info python-r1 systemd toolchain-funcs udev
92 +inherit bash-completion-r1 flag-o-matic linux-info linux-mod distutils-r1 systemd toolchain-funcs udev
93
94 DESCRIPTION="Userland utilities for ZFS Linux kernel module"
95 HOMEPAGE="https://zfsonlinux.org/"
96
97 +if [[ ${PV} == "9999" ]] ; then
98 + inherit autotools git-r3
99 + EGIT_REPO_URI="https://github.com/zfsonlinux/zfs.git"
100 +else
101 + SRC_URI="https://github.com/zfsonlinux/${PN}/releases/download/${P}/${P}.tar.gz"
102 + KEYWORDS="~amd64"
103 +fi
104 +
105 LICENSE="BSD-2 CDDL MIT"
106 SLOT="0"
107 -IUSE="custom-cflags debug kernel-builtin +rootfs test-suite static-libs"
108 -RESTRICT="test"
109 +IUSE="custom-cflags debug kernel-builtin python +rootfs test-suite static-libs"
110
111 COMMON_DEPEND="
112 + ${PYTHON_DEPS}
113 net-libs/libtirpc
114 sys-apps/util-linux[static-libs?]
115 sys-libs/zlib[static-libs(+)?]
116 virtual/awk
117 + python? (
118 + virtual/python-cffi[${PYTHON_USEDEP}]
119 + )
120 "
121 -DEPEND="${COMMON_DEPEND}
122 +
123 +BDEPEND="${COMMON_DEPEND}
124 virtual/pkgconfig
125 + python? (
126 + dev-python/setuptools[${PYTHON_USEDEP}]
127 + )
128 "
129
130 RDEPEND="${COMMON_DEPEND}
131 !=sys-apps/grep-2.13*
132 - !kernel-builtin? ( =sys-fs/zfs-kmod-${PV}* )
133 + !kernel-builtin? ( ~sys-fs/zfs-kmod-${PV} )
134 !sys-fs/zfs-fuse
135 !prefix? ( virtual/udev )
136 + sys-fs/udev-init-scripts
137 + rootfs? (
138 + app-arch/cpio
139 + app-misc/pax-utils
140 + !<sys-boot/grub-2.00-r2:2
141 + !<sys-kernel/genkernel-3.5.1.1
142 + !<sys-kernel/genkernel-next-67
143 + !<sys-kernel/bliss-initramfs-7.1.0
144 + !<sys-kernel/dracut-044-r1
145 + )
146 test-suite? (
147 sys-apps/util-linux
148 sys-devel/bc
149 @@ -46,24 +64,22 @@ RDEPEND="${COMMON_DEPEND}
150 sys-fs/mdadm
151 sys-process/procps
152 virtual/modutils
153 - )
154 - rootfs? (
155 - app-arch/cpio
156 - app-misc/pax-utils
157 - !<sys-boot/grub-2.00-r2:2
158 - )
159 + )
160 "
161
162 -AT_M4DIR="config"
163 -AUTOTOOLS_IN_SOURCE_BUILD="1"
164 +REQUIRED_USE="${PYTHON_REQUIRED_USE}"
165 +
166 +RESTRICT="test"
167 +
168 +PATCHES=( "${FILESDIR}/bash-completion-sudo.patch" )
169
170 pkg_setup() {
171 if use kernel_linux && use test-suite; then
172 linux-info_pkg_setup
173 +
174 if ! linux_config_exists; then
175 ewarn "Cannot check the linux kernel configuration."
176 else
177 - # recheck that we don't have usblp to collide with libusb
178 if use test-suite; then
179 if linux_chkconfig_present BLK_DEV_LOOP; then
180 eerror "The ZFS test suite requires loop device support enabled."
181 @@ -72,34 +88,38 @@ pkg_setup() {
182 eerror "in /usr/src/linux/.config or"
183 eerror " Device Drivers --->"
184 eerror " Block devices --->"
185 - eerror " [ ] Loopback device support"
186 + eerror " [X] Loopback device support"
187 fi
188 fi
189 fi
190 fi
191 -
192 }
193
194 src_prepare() {
195 + default
196 +
197 + [[ ${PV} == "9999" ]] && eautoreconf
198 +
199 # Update paths
200 sed -e "s|/sbin/lsmod|/bin/lsmod|" \
201 -e "s|/usr/bin/scsi-rescan|/usr/sbin/rescan-scsi-bus|" \
202 -e "s|/sbin/parted|/usr/sbin/parted|" \
203 - -i scripts/common.sh.in
204 + -i scripts/common.sh.in || die
205
206 - if use kernel-builtin
207 - then
208 - einfo "kernel-builtin enabled, removing module loading from"
209 - einfo "systemd units."
210 - sed -i -e '/modprobe\ zfs/d' etc/systemd/system/*.service.in || die
211 + if use python; then
212 + pushd contrib/pyzfs >/dev/null || die
213 + distutils-r1_src_prepare
214 + popd >/dev/null || die
215 fi
216 - autotools-utils_src_prepare
217 }
218
219 src_configure() {
220 use custom-cflags || strip-flags
221 - local myeconfargs=(
222 +
223 + local myconf=(
224 --bindir="${EPREFIX}/bin"
225 + --enable-systemd
226 + --enable-sysvinit
227 --sbindir="${EPREFIX}/sbin"
228 --with-config=user
229 --with-dracutdir="${EPREFIX}/usr/lib/dracut"
230 @@ -109,47 +129,53 @@ src_configure() {
231 --with-systemdunitdir="$(systemd_get_systemunitdir)"
232 --with-systemdpresetdir="${EPREFIX}/lib/systemd/system-preset"
233 $(use_enable debug)
234 + $(use_enable python pyzfs)
235 )
236 - autotools-utils_src_configure
237 -
238 - # prepare systemd unit and helper script
239 - cat "${FILESDIR}/zfs.service.in" | \
240 - sed -e "s:@sbindir@:${EPREFIX}/sbin:g" \
241 - -e "s:@sysconfdir@:${EPREFIX}/etc:g" \
242 - > "${T}/zfs.service" || die
243 - cat "${FILESDIR}/zfs-init.sh.in" | \
244 - sed -e "s:@sbindir@:${EPREFIX}/sbin:g" \
245 - -e "s:@sysconfdir@:${EPREFIX}/etc:g" \
246 - > "${T}/zfs-init.sh" || die
247 - if use kernel-builtin
248 - then
249 - sed -i -e '/modprobe\ zfs/d' "${T}/zfs.service" || die
250 +
251 + econf "${myconf[@]}"
252 +}
253 +
254 +src_compile() {
255 + default
256 + if use python; then
257 + pushd contrib/pyzfs >/dev/null || die
258 + distutils-r1_src_compile
259 + popd >/dev/null || die
260 fi
261 }
262
263 src_install() {
264 - autotools-utils_src_install
265 + default
266 +
267 gen_usr_ldscript -a uutil nvpair zpool zfs zfs_core
268 - use test-suite || rm -rf "${ED}usr/share/zfs"
269
270 - newbashcomp "${FILESDIR}/bash-completion-r1" zfs
271 + use test-suite || rm -rf "${ED}/usr/share/zfs"
272 +
273 + dobashcomp contrib/bash_completion.d/zfs
274 bashcomp_alias zfs zpool
275
276 - exeinto /usr/libexec
277 - doexe "${T}/zfs-init.sh"
278 - systemd_dounit "${T}/zfs.service"
279 + # strip executable bit from conf.d file
280 + fperms 0644 /etc/conf.d/zfs
281 +
282 + if use python; then
283 + pushd contrib/pyzfs >/dev/null || die
284 + distutils-r1_src_install
285 + popd >/dev/null || die
286 + fi
287 +
288 + # enforce best available python implementation
289 + python_setup
290 + python_fix_shebang "${ED}/bin"
291 }
292
293 pkg_postinst() {
294 - if ! use kernel-builtin && [ ${PV} = "9999" ]
295 - then
296 + if ! use kernel-builtin && [[ ${PV} = "9999" ]]; then
297 einfo "Adding ${P} to the module database to ensure that the"
298 einfo "kernel modules and userland utilities stay in sync."
299 update_moduledb
300 fi
301
302 - if [ -e "${EROOT}etc/runlevels/boot/zfs" ]
303 - then
304 + if [[ -e "${EROOT}/etc/runlevels/boot/zfs" ]]; then
305 einfo 'The zfs boot script has been split into the zfs-import,'
306 einfo 'zfs-mount and zfs-share scripts.'
307 einfo
308 @@ -159,24 +185,23 @@ pkg_postinst() {
309 einfo 'The zfs-import and zfs-mount scripts have been added to the boot'
310 einfo 'runlevel while the zfs-share script is in the default runlevel.'
311
312 - rm "${EROOT}etc/runlevels/boot/zfs"
313 - ln -snf "${EROOT}etc/init.d/zfs-import" \
314 - "${EROOT}etc/runlevels/boot/zfs-import"
315 - ln -snf "${EROOT}etc/init.d/zfs-mount" \
316 - "${EROOT}etc/runlevels/boot/zfs-mount"
317 - ln -snf "${EROOT}etc/init.d/zfs-share" \
318 - "${EROOT}etc/runlevels/default/zfs-share"
319 + rm "${EROOT}/etc/runlevels/boot/zfs"
320 + ln -snf "${EROOT}/etc/init.d/zfs-import" \
321 + "${EROOT}/etc/runlevels/boot/zfs-import"
322 + ln -snf "${EROOT}/etc/init.d/zfs-mount" \
323 + "${EROOT}/etc/runlevels/boot/zfs-mount"
324 + ln -snf "${EROOT}/etc/init.d/zfs-share" \
325 + "${EROOT}/etc/runlevels/default/zfs-share"
326 else
327 - [ -e "${EROOT}etc/runlevels/boot/zfs-import" ] || \
328 + [[ -e "${EROOT}/etc/runlevels/boot/zfs-import" ]] || \
329 einfo "You should add zfs-import to the boot runlevel."
330 - [ -e "${EROOT}etc/runlevels/boot/zfs-mount" ] || \
331 + [[ -e "${EROOT}/etc/runlevels/boot/zfs-mount" ]]|| \
332 einfo "You should add zfs-mount to the boot runlevel."
333 - [ -e "${EROOT}etc/runlevels/default/zfs-share" ] || \
334 + [[ -e "${EROOT}/etc/runlevels/default/zfs-share" ]] || \
335 einfo "You should add zfs-share to the default runlevel."
336 fi
337
338 - if [ -e "${EROOT}etc/runlevels/default/zed" ]
339 - then
340 + if [[ -e "${EROOT}/etc/runlevels/default/zed" ]]; then
341 einfo 'The downstream OpenRC zed script has replaced by the upstream'
342 einfo 'OpenRC zfs-zed script.'
343 einfo
344 @@ -184,18 +209,17 @@ pkg_postinst() {
345 einfo 'convenience, it has been automatically removed and the zfs-zed'
346 einfo 'script that replaced it has been configured to start.'
347
348 - rm "${EROOT}etc/runlevels/boot/zed"
349 - ln -snf "${EROOT}etc/init.d/zfs-sed" \
350 - "${EROOT}etc/runlevels/default/zfs-zed"
351 + rm "${EROOT}/etc/runlevels/boot/zed"
352 + ln -snf "${EROOT}/etc/init.d/zfs-zed" \
353 + "${EROOT}/etc/runlevels/default/zfs-zed"
354 else
355 - [ -e "${EROOT}etc/runlevels/default/zfs-zed" ] || \
356 + [[ -e "${EROOT}/etc/runlevels/default/zfs-zed" ]] || \
357 einfo "You should add zfs-zed to the default runlevel."
358 fi
359
360 - if [ -e "${EROOT}etc/runlevels/shutdown/zfs-shutdown" ]
361 - then
362 + if [[ -e "${EROOT}/etc/runlevels/shutdown/zfs-shutdown" ]]; then
363 einfo "The zfs-shutdown script is obsolete. Removing it from runlevel."
364 - rm "${EROOT}etc/runlevels/shutdown/zfs-shutdown"
365 + rm "${EROOT}/etc/runlevels/shutdown/zfs-shutdown"
366 fi
367
368 systemd_reenable zfs-zed.service
369 @@ -205,13 +229,10 @@ pkg_postinst() {
370 systemd_reenable zfs-share.service
371 systemd_reenable zfs-import.target
372 systemd_reenable zfs.target
373 - systemd_reenable zfs.service
374 -
375 }
376
377 pkg_postrm() {
378 - if ! use kernel-builtin && [ ${PV} = "9999" ]
379 - then
380 + if ! use kernel-builtin && [[ ${PV} == "9999" ]]; then
381 remove_moduledb
382 fi
383 }