Gentoo Archives: gentoo-commits

From: Sam James <sam@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] repo/gentoo:master commit in: sys-fs/zfs/files/, sys-fs/zfs/
Date: Thu, 30 Jun 2022 10:38:01
Message-Id: 1656585469.cfd4165530beb09e3e75d91fe56b2dcce910aadc.sam@gentoo
1 commit: cfd4165530beb09e3e75d91fe56b2dcce910aadc
2 Author: Sam James <sam <AT> gentoo <DOT> org>
3 AuthorDate: Thu Jun 30 01:55:16 2022 +0000
4 Commit: Sam James <sam <AT> gentoo <DOT> org>
5 CommitDate: Thu Jun 30 10:37:49 2022 +0000
6 URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=cfd41655
7
8 sys-fs/zfs: backport build fixes and non-root dracut boot fix
9
10 Closes: https://bugs.gentoo.org/855182
11 Closes: https://bugs.gentoo.org/854333
12 Signed-off-by: Sam James <sam <AT> gentoo.org>
13
14 sys-fs/zfs/files/2.1.5-build-issues.patch | 74 +++++++
15 sys-fs/zfs/files/2.1.5-dracut-non-root.patch | 33 +++
16 sys-fs/zfs/zfs-2.1.5-r1.ebuild | 310 +++++++++++++++++++++++++++
17 3 files changed, 417 insertions(+)
18
19 diff --git a/sys-fs/zfs/files/2.1.5-build-issues.patch b/sys-fs/zfs/files/2.1.5-build-issues.patch
20 new file mode 100644
21 index 000000000000..cca6561b16f7
22 --- /dev/null
23 +++ b/sys-fs/zfs/files/2.1.5-build-issues.patch
24 @@ -0,0 +1,74 @@
25 +https://github.com/openzfs/zfs/commit/a6e8113fed8a508ffda13cf1c4d8da99a4e8133a
26 +https://github.com/openzfs/zfs/commit/60e389ca10085acfa7cd35f79ab4465d968a942f
27 +Cherry-picked from https://github.com/openzfs/zfs/pull/13575
28 +
29 +https://bugs.gentoo.org/855182
30 +--- a/config/always-compiler-options.m4
31 ++++ b/config/always-compiler-options.m4
32 +@@ -205,6 +205,29 @@ AC_DEFUN([ZFS_AC_CONFIG_ALWAYS_CC_NO_OMIT_FRAME_POINTER], [
33 + AC_SUBST([NO_OMIT_FRAME_POINTER])
34 + ])
35 +
36 ++dnl #
37 ++dnl # Check if cc supports -Winfinite-recursion option.
38 ++dnl #
39 ++AC_DEFUN([ZFS_AC_CONFIG_ALWAYS_CC_INFINITE_RECURSION], [
40 ++ AC_MSG_CHECKING([whether $CC supports -Winfinite-recursion])
41 ++
42 ++ saved_flags="$CFLAGS"
43 ++ CFLAGS="$CFLAGS -Werror -Winfinite-recursion"
44 ++
45 ++ AC_COMPILE_IFELSE([AC_LANG_PROGRAM([], [])], [
46 ++ INFINITE_RECURSION=-Winfinite-recursion
47 ++ AC_DEFINE([HAVE_INFINITE_RECURSION], 1,
48 ++ [Define if compiler supports -Winfinite-recursion])
49 ++ AC_MSG_RESULT([yes])
50 ++ ], [
51 ++ INFINITE_RECURSION=
52 ++ AC_MSG_RESULT([no])
53 ++ ])
54 ++
55 ++ CFLAGS="$saved_flags"
56 ++ AC_SUBST([INFINITE_RECURSION])
57 ++])
58 ++
59 + dnl #
60 + dnl # Check if cc supports -fno-ipa-sra option.
61 + dnl #
62 +--- a/config/zfs-build.m4
63 ++++ b/config/zfs-build.m4
64 +@@ -211,6 +211,7 @@ AC_DEFUN([ZFS_AC_CONFIG_ALWAYS], [
65 +
66 + ZFS_AC_CONFIG_ALWAYS_CC_NO_UNUSED_BUT_SET_VARIABLE
67 + ZFS_AC_CONFIG_ALWAYS_CC_NO_BOOL_COMPARE
68 ++ ZFS_AC_CONFIG_ALWAYS_CC_INFINITE_RECURSION
69 + ZFS_AC_CONFIG_ALWAYS_CC_IMPLICIT_FALLTHROUGH
70 + ZFS_AC_CONFIG_ALWAYS_CC_FRAME_LARGER_THAN
71 + ZFS_AC_CONFIG_ALWAYS_CC_NO_FORMAT_TRUNCATION
72 +--- a/module/lua/ldo.c
73 ++++ b/module/lua/ldo.c
74 +@@ -168,6 +168,13 @@ static void seterrorobj (lua_State *L, int errcode, StkId oldtop) {
75 + L->top = oldtop + 1;
76 + }
77 +
78 ++/*
79 ++ * Silence infinite recursion warning which was added to -Wall in gcc 12.1
80 ++ */
81 ++#if defined(HAVE_INFINITE_RECURSION)
82 ++#pragma GCC diagnostic push
83 ++#pragma GCC diagnostic ignored "-Winfinite-recursion"
84 ++#endif
85 +
86 + l_noret luaD_throw (lua_State *L, int errcode) {
87 + if (L->errorJmp) { /* thread has an error handler? */
88 +@@ -190,6 +197,10 @@ l_noret luaD_throw (lua_State *L, int errcode) {
89 + }
90 + }
91 +
92 ++#if defined(HAVE_INFINITE_RECURSION)
93 ++#pragma GCC diagnostic pop
94 ++#endif
95 ++
96 +
97 + int luaD_rawrunprotected (lua_State *L, Pfunc f, void *ud) {
98 + unsigned short oldnCcalls = L->nCcalls;
99
100 diff --git a/sys-fs/zfs/files/2.1.5-dracut-non-root.patch b/sys-fs/zfs/files/2.1.5-dracut-non-root.patch
101 new file mode 100644
102 index 000000000000..6d1caf92cd2d
103 --- /dev/null
104 +++ b/sys-fs/zfs/files/2.1.5-dracut-non-root.patch
105 @@ -0,0 +1,33 @@
106 +https://github.com/openzfs/zfs/pull/13589
107 +https://bugs.gentoo.org/854333
108 +
109 +From ef9d996669cc2ec596d4e90753b89b32a3f0ce59 Mon Sep 17 00:00:00 2001
110 +From: "Andrew J. Hesford" <ajh@××××××××.org>
111 +Date: Fri, 24 Jun 2022 11:05:53 -0400
112 +Subject: [PATCH] Dracut module: fix parsing of root= kernel command-line
113 + argument
114 +
115 +Some Dracut modules may read the `root=` kernel command-line argument
116 +and rewrite it; in particular, `rootfs-block` installs a command-line
117 +hook that to canonicalize arguments that specify block devices. If the
118 +`zfs` module is added to an initramfs (which it is, by default, as long
119 +as the core ZFS utilities are available) on a system that does not use a
120 +ZFS root filesystem, the `zfs` module will overwrite the `root` shell
121 +variable with the contents of the kernel command-line in the process of
122 +determining if it should control mounting the root. This breaks the
123 +initramfs. To solve this problem, only parse the kernel command-line
124 +directly if the `root` shell variable is empty; otherwise, rely on the
125 +parsing (and possible rewriting) done by other modules.
126 +
127 +Signed-off-by: Andrew J. Hesford <ajh@××××××××.org>
128 +--- a/contrib/dracut/90zfs/zfs-lib.sh.in
129 ++++ b/contrib/dracut/90zfs/zfs-lib.sh.in
130 +@@ -88,7 +88,7 @@ decode_root_args() {
131 + return
132 + fi
133 +
134 +- root=$(getarg root=)
135 ++ [ -n "$root" ] || root=$(getarg root=)
136 + rootfstype=$(getarg rootfstype=)
137 +
138 + # shellcheck disable=SC2249
139
140 diff --git a/sys-fs/zfs/zfs-2.1.5-r1.ebuild b/sys-fs/zfs/zfs-2.1.5-r1.ebuild
141 new file mode 100644
142 index 000000000000..7f0466ea0e20
143 --- /dev/null
144 +++ b/sys-fs/zfs/zfs-2.1.5-r1.ebuild
145 @@ -0,0 +1,310 @@
146 +# Copyright 1999-2022 Gentoo Authors
147 +# Distributed under the terms of the GNU General Public License v2
148 +
149 +EAPI=7
150 +
151 +DISTUTILS_OPTIONAL=1
152 +PYTHON_COMPAT=( python3_{8..10} )
153 +
154 +inherit autotools bash-completion-r1 dist-kernel-utils distutils-r1 flag-o-matic linux-info pam systemd udev usr-ldscript
155 +
156 +DESCRIPTION="Userland utilities for ZFS Linux kernel module"
157 +HOMEPAGE="https://github.com/openzfs/zfs"
158 +
159 +if [[ ${PV} == "9999" ]]; then
160 + inherit git-r3 linux-mod
161 + EGIT_REPO_URI="https://github.com/openzfs/zfs.git"
162 +else
163 + VERIFY_SIG_OPENPGP_KEY_PATH=${BROOT}/usr/share/openpgp-keys/openzfs.asc
164 + inherit verify-sig
165 +
166 + MY_P="${P/_rc/-rc}"
167 + SRC_URI="https://github.com/openzfs/${PN}/releases/download/${MY_P}/${MY_P}.tar.gz"
168 + SRC_URI+=" verify-sig? ( https://github.com/openzfs/${PN}/releases/download/${MY_P}/${MY_P}.tar.gz.asc )"
169 + S="${WORKDIR}/${P%_rc?}"
170 +
171 + if [[ ${PV} != *_rc* ]]; then
172 + KEYWORDS="~amd64 ~arm64 ~ppc64 ~riscv"
173 + fi
174 +fi
175 +
176 +LICENSE="BSD-2 CDDL MIT"
177 +# just libzfs soname major for now.
178 +# possible candidates: libuutil, libzpool, libnvpair. Those do not provide stable abi, but are considered.
179 +# see libsoversion_check() below as well
180 +SLOT="0/5"
181 +IUSE="custom-cflags debug dist-kernel kernel-builtin minimal nls pam python +rootfs test-suite"
182 +
183 +DEPEND="
184 + net-libs/libtirpc:=
185 + sys-apps/util-linux
186 + sys-libs/zlib
187 + virtual/libudev:=
188 + dev-libs/openssl:0=
189 + !minimal? ( ${PYTHON_DEPS} )
190 + pam? ( sys-libs/pam )
191 + python? (
192 + virtual/python-cffi[${PYTHON_USEDEP}]
193 + )
194 +"
195 +
196 +BDEPEND="virtual/awk
197 + virtual/pkgconfig
198 + nls? ( sys-devel/gettext )
199 + python? (
200 + dev-python/setuptools[${PYTHON_USEDEP}]
201 + || (
202 + dev-python/packaging[${PYTHON_USEDEP}]
203 + dev-python/distlib[${PYTHON_USEDEP}]
204 + )
205 + )
206 +"
207 +
208 +if [[ ${PV} != "9999" ]] ; then
209 + BDEPEND+=" verify-sig? ( sec-keys/openpgp-keys-openzfs )"
210 +fi
211 +
212 +# awk is used for some scripts, completions, and the Dracut module
213 +RDEPEND="${DEPEND}
214 + !kernel-builtin? ( ~sys-fs/zfs-kmod-${PV}:= )
215 + !prefix? ( virtual/udev )
216 + sys-fs/udev-init-scripts
217 + virtual/awk
218 + dist-kernel? ( virtual/dist-kernel:= )
219 + rootfs? (
220 + app-arch/cpio
221 + app-misc/pax-utils
222 + !<sys-kernel/genkernel-3.5.1.1
223 + )
224 + test-suite? (
225 + app-shells/ksh
226 + sys-apps/kmod[tools]
227 + sys-apps/util-linux
228 + sys-devel/bc
229 + sys-block/parted
230 + sys-fs/lsscsi
231 + sys-fs/mdadm
232 + sys-process/procps
233 + )
234 +"
235 +
236 +# PDEPEND in this form is needed to trick portage suggest
237 +# enabling dist-kernel if only 1 package have it set, without suggesting to disable
238 +PDEPEND="dist-kernel? ( ~sys-fs/zfs-kmod-${PV}[dist-kernel] )"
239 +
240 +REQUIRED_USE="
241 + !minimal? ( ${PYTHON_REQUIRED_USE} )
242 + python? ( !minimal )
243 + test-suite? ( !minimal )
244 +"
245 +
246 +RESTRICT="test"
247 +
248 +PATCHES=(
249 + # bug #855182
250 + "${FILESDIR}"/${PV}-build-issues.patch
251 + # bug #854333
252 + "${FILESDIR}"/${PV}-dracut-non-root.patch
253 +)
254 +
255 +pkg_pretend() {
256 + use rootfs || return 0
257 +
258 + if has_version virtual/dist-kernel && ! use dist-kernel; then
259 + ewarn "You have virtual/dist-kernel installed, but"
260 + ewarn "USE=\"dist-kernel\" is not enabled for ${CATEGORY}/${PN}"
261 + ewarn "It's recommended to globally enable dist-kernel USE flag"
262 + ewarn "to auto-trigger initrd rebuilds with kernel updates"
263 + fi
264 +}
265 +
266 +pkg_setup() {
267 + if use kernel_linux; then
268 + linux-info_pkg_setup
269 +
270 + if ! linux_config_exists; then
271 + ewarn "Cannot check the linux kernel configuration."
272 + else
273 + if use test-suite; then
274 + if linux_chkconfig_present BLK_DEV_LOOP; then
275 + eerror "The ZFS test suite requires loop device support enabled."
276 + eerror "Please enable it:"
277 + eerror " CONFIG_BLK_DEV_LOOP=y"
278 + eerror "in /usr/src/linux/.config or"
279 + eerror " Device Drivers --->"
280 + eerror " Block devices --->"
281 + eerror " [X] Loopback device support"
282 + fi
283 + fi
284 + fi
285 + fi
286 +}
287 +
288 +libsoversion_check() {
289 + local bugurl libzfs_sover
290 + bugurl="https://bugs.gentoo.org/enter_bug.cgi?form_name=enter_bug&product=Gentoo+Linux&component=Current+packages"
291 +
292 + libzfs_sover="$(grep 'libzfs_la_LDFLAGS += -version-info' lib/libzfs/Makefile.am \
293 + | grep -Eo '[0-9]+:[0-9]+:[0-9]+')"
294 + libzfs_sover="${libzfs_sover%%:*}"
295 +
296 + if [[ ${libzfs_sover} -ne $(ver_cut 2 ${SLOT}) ]]; then
297 + echo
298 + eerror "BUG BUG BUG BUG BUG BUG BUG BUG"
299 + eerror "ebuild subslot does not match libzfs soversion!"
300 + eerror "libzfs soversion: ${libzfs_sover}"
301 + eerror "ebuild value: $(ver_cut 2 ${SLOT})"
302 + eerror "This is a bug in the ebuild, please use the following URL to report it"
303 + eerror "${bugurl}&short_desc=${CATEGORY}%2F${P}+update+subslot"
304 + echo
305 + # we want to abort for releases, but just print a warning for live ebuild
306 + # to keep package installable
307 + [[ ${PV} == "9999" ]] || die
308 + fi
309 +}
310 +
311 +src_prepare() {
312 + default
313 + libsoversion_check
314 +
315 + # Run unconditionally (bug #792627)
316 + eautoreconf
317 +
318 + if [[ ${PV} != "9999" ]]; then
319 + # Set revision number
320 + sed -i "s/\(Release:\)\(.*\)1/\1\2${PR}-gentoo/" META || die "Could not set Gentoo release"
321 + fi
322 +
323 + if use python; then
324 + pushd contrib/pyzfs >/dev/null || die
325 + distutils-r1_src_prepare
326 + popd >/dev/null || die
327 + fi
328 +
329 + # prevent errors showing up on zfs-mount stop, #647688
330 + # openrc will unmount all filesystems anyway.
331 + sed -i "/^ZFS_UNMOUNT=/ s/yes/no/" "etc/default/zfs.in" || die
332 +}
333 +
334 +src_configure() {
335 + use custom-cflags || strip-flags
336 + use minimal || python_setup
337 +
338 + local myconf=(
339 + --bindir="${EPREFIX}/bin"
340 + --enable-shared
341 + --enable-sysvinit
342 + --localstatedir="${EPREFIX}/var"
343 + --sbindir="${EPREFIX}/sbin"
344 + --with-config=user
345 + --with-dracutdir="${EPREFIX}/usr/lib/dracut"
346 + --with-linux="${KV_DIR}"
347 + --with-linux-obj="${KV_OUT_DIR}"
348 + --with-udevdir="$(get_udevdir)"
349 + --with-pamconfigsdir="${EPREFIX}/unwanted_files"
350 + --with-pammoduledir="$(getpam_mod_dir)"
351 + --with-systemdunitdir="$(systemd_get_systemunitdir)"
352 + --with-systemdpresetdir="$(systemd_get_systempresetdir)"
353 + --with-vendor=gentoo
354 + # Building zfs-mount-generator.c on musl breaks as strndupa
355 + # isn't available. But systemd doesn't support musl anyway, so
356 + # just disable building it.
357 + $(use_enable !elibc_musl systemd)
358 + $(use_enable debug)
359 + $(use_enable nls)
360 + $(use_enable pam)
361 + $(use_enable python pyzfs)
362 + --disable-static
363 + $(usex minimal --without-python --with-python="${EPYTHON}")
364 + )
365 +
366 + econf "${myconf[@]}"
367 +}
368 +
369 +src_compile() {
370 + default
371 + if use python; then
372 + pushd contrib/pyzfs >/dev/null || die
373 + distutils-r1_src_compile
374 + popd >/dev/null || die
375 + fi
376 +}
377 +
378 +src_install() {
379 + default
380 +
381 + gen_usr_ldscript -a nvpair uutil zfsbootenv zfs zfs_core zpool
382 +
383 + use pam && { rm -rv "${ED}/unwanted_files" || die ; }
384 +
385 + use test-suite || { rm -r "${ED}"/usr/share/zfs/{test-runner,zfs-tests,runfiles,*sh} || die ; }
386 +
387 + find "${ED}" -name '*.la' -delete || die
388 +
389 + dobashcomp contrib/bash_completion.d/zfs
390 + bashcomp_alias zfs zpool
391 +
392 + # strip executable bit from conf.d file
393 + fperms 0644 /etc/conf.d/zfs
394 +
395 + if use python; then
396 + pushd contrib/pyzfs >/dev/null || die
397 + distutils-r1_src_install
398 + popd >/dev/null || die
399 + fi
400 +
401 + # enforce best available python implementation
402 + use minimal || python_fix_shebang "${ED}/bin"
403 +}
404 +
405 +pkg_postinst() {
406 + udev_reload
407 +
408 + # we always need userspace utils in sync with zfs-kmod
409 + # so force initrd update for userspace as well, to avoid
410 + # situation when zfs-kmod trigger initrd rebuild before
411 + # userspace component is rebuilt
412 + # KV_* variables are provided by linux-info.eclass
413 + if [[ -z ${ROOT} ]] && use dist-kernel; then
414 + dist-kernel_reinstall_initramfs "${KV_DIR}" "${KV_FULL}"
415 + fi
416 +
417 + if use rootfs; then
418 + if ! has_version sys-kernel/genkernel && ! has_version sys-kernel/dracut; then
419 + elog "Root on zfs requires an initramfs to boot"
420 + elog "The following packages provide one and are tested on a regular basis:"
421 + elog " sys-kernel/dracut ( preferred, module maintained by zfs developers )"
422 + elog " sys-kernel/genkernel"
423 + fi
424 + fi
425 +
426 + if ! use kernel-builtin && [[ ${PV} == "9999" ]]; then
427 + einfo "Adding ${P} to the module database to ensure that the"
428 + einfo "kernel modules and userland utilities stay in sync."
429 + update_moduledb
430 + fi
431 +
432 + if systemd_is_booted || has_version sys-apps/systemd; then
433 + einfo "Please refer to ${EROOT}/$(systemd_get_systempresetdir)/50-zfs.preset"
434 + einfo "for default zfs systemd service configuration"
435 + else
436 + [[ -e "${EROOT}/etc/runlevels/boot/zfs-import" ]] || \
437 + einfo "You should add zfs-import to the boot runlevel."
438 + [[ -e "${EROOT}/etc/runlevels/boot/zfs-load-key" ]] || \
439 + einfo "You should add zfs-load-key to the boot runlevel."
440 + [[ -e "${EROOT}/etc/runlevels/boot/zfs-mount" ]]|| \
441 + einfo "You should add zfs-mount to the boot runlevel."
442 + [[ -e "${EROOT}/etc/runlevels/default/zfs-share" ]] || \
443 + einfo "You should add zfs-share to the default runlevel."
444 + [[ -e "${EROOT}/etc/runlevels/default/zfs-zed" ]] || \
445 + einfo "You should add zfs-zed to the default runlevel."
446 + fi
447 +}
448 +
449 +pkg_postrm() {
450 + udev_reload
451 +
452 + if ! use kernel-builtin && [[ ${PV} == "9999" ]]; then
453 + remove_moduledb
454 + fi
455 +}