Diff zfs-2.2.9 with a zfs-9999

/usr/portage/sys-fs/zfs/zfs-9999.ebuild 2025-12-04 18:18:04.045240377 +0300
3 3

  
4 4
EAPI=8
5 5

  
6
# Maintainers should consider lurking in the ZFS IRC channels (there's several)
7
# and regularly checking ZFS GitHub issues and PRs. Look out for the 'zfs-*'
8
# stable backport PRs when they're opened and subscribe to them for any important
9
# cherry-picks that may be needed in advance.
10

  
6 11
DISTUTILS_OPTIONAL=1
7 12
DISTUTILS_USE_PEP517=setuptools
8 13
PYTHON_COMPAT=( python3_{11..14} )
9 14

  
10
inherit autotools bash-completion-r1 dist-kernel-utils distutils-r1 flag-o-matic linux-info
11
inherit pam systemd udev usr-ldscript
15
MODULES_INITRAMFS_IUSE=+initramfs
16
MODULES_OPTIONAL_IUSE=+modules
17

  
18
inherit autotools bash-completion-r1 distutils-r1 flag-o-matic linux-info
19
inherit linux-mod-r1 multiprocessing pam systemd udev usr-ldscript
12 20

  
13
DESCRIPTION="Userland utilities for ZFS Linux kernel module"
21
DESCRIPTION="Linux kernel module and userland utilities for ZFS"
14 22
HOMEPAGE="https://github.com/openzfs/zfs"
15 23

  
24
MODULES_KERNEL_MAX=6.17
25
MODULES_KERNEL_MIN=4.18
26

  
16 27
if [[ ${PV} == "9999" ]]; then
17 28
	inherit git-r3
18 29
	EGIT_REPO_URI="https://github.com/openzfs/zfs.git"
......
25 36
	SRC_URI+=" verify-sig? ( https://github.com/openzfs/${PN}/releases/download/${MY_P}/${MY_P}.tar.gz.asc )"
26 37
	S="${WORKDIR}/${MY_P}"
27 38

  
39
	ZFS_KERNEL_COMPAT="${MODULES_KERNEL_MAX}"
40
	# Increments minor eg 5.14 -> 5.15, and still supports override.
41
	ZFS_KERNEL_DEP="${ZFS_KERNEL_COMPAT_OVERRIDE:-${ZFS_KERNEL_COMPAT}}"
42
	ZFS_KERNEL_DEP="${ZFS_KERNEL_DEP%%.*}.$(( ${ZFS_KERNEL_DEP##*.} + 1))"
43

  
28 44
	if [[ ${PV} != *_rc* ]]; then
29 45
		KEYWORDS="~amd64 ~arm64 ~loong ~ppc64 ~riscv ~sparc"
30 46
	fi
31 47
fi
32 48

  
33
LICENSE="BSD-2 CDDL MIT"
49
LICENSE="BSD-2 CDDL MIT modules? ( debug? ( GPL-2+ ) )"
34 50
# just libzfs soname major for now.
35
# possible candidates: libuutil, libzpool, libnvpair. Those do not provide stable abi, but are considered.
51
# possible candidates are libzpool and libnvpair. Those do not provide stable abi, but are considered.
36 52
# see libsoversion_check() below as well
37
SLOT="0/5"
38
IUSE="custom-cflags debug dist-kernel kernel-builtin minimal nls pam python +rootfs selinux test-suite unwind"
53
SLOT="0/7"
54
IUSE="custom-cflags debug dist-kernel minimal nls pam python +rootfs selinux test-suite unwind"
39 55

  
40 56
DEPEND="
41 57
	dev-libs/openssl:=
......
54 70
BDEPEND="
55 71
	app-alternatives/awk
56 72
	virtual/pkgconfig
73
	modules? ( dev-lang/perl )
57 74
	nls? ( sys-devel/gettext )
58 75
	python? (
59 76
		${DISTUTILS_DEPS}
......
66 83

  
67 84
if [[ ${PV} != "9999" ]] ; then
68 85
	BDEPEND+=" verify-sig? ( sec-keys/openpgp-keys-openzfs )"
86

  
87
	IUSE+=" +dist-kernel-cap"
88
	RDEPEND="
89
		dist-kernel-cap? ( dist-kernel? (
90
			<virtual/dist-kernel-${ZFS_KERNEL_DEP}
91
		) )
92
	"
69 93
fi
70 94

  
71 95
# awk is used for some scripts, completions, and the Dracut module
72 96
RDEPEND="
73 97
	${DEPEND}
74
	!kernel-builtin? ( ~sys-fs/zfs-kmod-${PV}:= )
75 98
	!prefix? ( virtual/udev )
76 99
	app-alternatives/awk
77 100
	sys-fs/udev-init-scripts
......
91 114
		sys-fs/mdadm
92 115
		sys-process/procps
93 116
	)
117
	!<sys-fs/zfs-kmod-2.4.0_rc2-r1
94 118
"
95 119

  
96
# PDEPEND in this form is needed to trick portage suggest
97
# enabling dist-kernel if only 1 package have it set, without suggesting to disable
98
PDEPEND="dist-kernel? ( ~sys-fs/zfs-kmod-${PV}[dist-kernel] )"
99

  
100 120
REQUIRED_USE="
101 121
	!minimal? ( ${PYTHON_REQUIRED_USE} )
102 122
	python? ( !minimal )
......
106 126
RESTRICT="test"
107 127

  
108 128
PATCHES=(
109
	"${FILESDIR}"/2.1.5-dracut-zfs-missing.patch
110
	"${FILESDIR}"/2.3.4-musl.patch
111
	"${FILESDIR}"/2.2.9-nfs-truncate-shares.patch
129
	"${FILESDIR}"/${PN}-2.1.11-gentoo.patch
112 130
)
113 131

  
114 132
pkg_pretend() {
......
124 142

  
125 143
pkg_setup() {
126 144
	if use kernel_linux; then
127
		linux-info_pkg_setup
145
		if use modules; then
146
			local CONFIG_CHECK="
147
				EFI_PARTITION
148
				ZLIB_DEFLATE
149
				ZLIB_INFLATE
150
				!DEBUG_LOCK_ALLOC
151
				!PAX_KERNEXEC_PLUGIN_METHOD_OR
152
			"
153
			use debug && CONFIG_CHECK+="
154
				DEBUG_INFO
155
				FRAME_POINTER
156
				!DEBUG_INFO_REDUCED
157
			"
158
			use rootfs && CONFIG_CHECK+="
159
				BLK_DEV_INITRD
160
				DEVTMPFS
161
			"
162

  
163
			kernel_is -lt 5 && CONFIG_CHECK+=" IOSCHED_NOOP"
164

  
165
			if [[ ${PV} != 9999 ]] ; then
166
				local kv_major_max kv_minor_max zcompat
167
				zcompat="${ZFS_KERNEL_COMPAT_OVERRIDE:-${ZFS_KERNEL_COMPAT}}"
168
				kv_major_max="${zcompat%%.*}"
169
				zcompat="${zcompat#*.}"
170
				kv_minor_max="${zcompat%%.*}"
171
				kernel_is -le "${kv_major_max}" "${kv_minor_max}" || die \
172
					"Linux ${kv_major_max}.${kv_minor_max} is the latest supported version"
173
			fi
174

  
175
			linux-mod-r1_pkg_setup
176
		else
177
			linux-info_pkg_setup
178
		fi
128 179

  
129 180
		if ! linux_config_exists; then
130 181
			ewarn "Cannot check the linux kernel configuration."
......
199 250

  
200 251
	local myconf=(
201 252
		--bindir="${EPREFIX}/bin"
253
		--sbindir="${EPREFIX}/sbin"
202 254
		--enable-shared
203 255
		--enable-sysvinit
204 256
		--localstatedir="${EPREFIX}/var"
205 257
		--sbindir="${EPREFIX}/sbin"
206
		--with-config=user
258
		--with-config="$(usex modules all user)"
207 259
		--with-dracutdir="${EPREFIX}/usr/lib/dracut"
208 260
		--with-linux="${KV_DIR}"
209 261
		--with-linux-obj="${KV_OUT_DIR}"
......
227 279
		$(use_with unwind libunwind)
228 280
		--disable-static
229 281
		$(usex minimal --without-python --with-python="${EPYTHON}")
282

  
283
		# See gentoo.patch
284
		GENTOO_MAKEARGS_EVAL="${MODULES_MAKEARGS[*]@Q}"
285
		TEST_JOBS="$(makeopts_jobs)"
230 286
	)
231 287

  
232 288
	econf "${myconf[@]}"
233 289
}
234 290

  
235 291
src_compile() {
236
	default
292
	if use modules; then
293
		emake "${MODULES_MAKEARGS[@]}"
294
	else
295
		default
296
	fi
297

  
237 298
	if use python; then
238 299
		pushd contrib/pyzfs >/dev/null || die
239 300
		distutils-r1_src_compile
......
242 303
}
243 304

  
244 305
src_install() {
245
	default
306
	DOCS=( AUTHORS COPYRIGHT META README.md )
246 307

  
247
	gen_usr_ldscript -a nvpair uutil zfsbootenv zfs zfs_core zpool
308
	if use modules; then
309
		emake "${MODULES_MAKEARGS[@]}" DESTDIR="${ED}" install
310
		modules_post_process
311
		einstalldocs
312
	else
313
		default
314
	fi
315
	# distutils-r1_src_install tries to run einstalldocs as well
316
	# bug #965156
317
	unset DOCS
318

  
319
	gen_usr_ldscript -a nvpair zfsbootenv zfs zfs_core zpool
248 320

  
249 321
	use pam && { rm -rv "${ED}/unwanted_files" || die ; }
250 322

  
......
268 340
	use minimal || python_fix_shebang "${ED}/bin"
269 341
}
270 342

  
343
_old_layout_cleanup() {
344
	# new files are just extra/{spl,zfs}.ko with no subdirs.
345
	local olddir=(
346
		avl/zavl
347
		icp/icp
348
		lua/zlua
349
		nvpair/znvpair
350
		spl/spl
351
		unicode/zunicode
352
		zcommon/zcommon
353
		zfs/zfs
354
		zstd/zzstd
355
	)
356

  
357
	# kernel/module/Kconfig contains possible compressed extentions.
358
	local kext kextfiles
359
		for kext in .ko{,.{gz,xz,zst}}; do
360
		kextfiles+=( "${olddir[@]/%/${kext}}" )
361
	done
362

  
363
	local oldfile oldpath
364
	for oldfile in "${kextfiles[@]}"; do
365
		oldpath="${EROOT}/lib/modules/${KV_FULL}/extra/${oldfile}"
366
		if [[ -f "${oldpath}" ]]; then
367
			ewarn "Found obsolete zfs module ${oldfile} for current kernel ${KV_FULL}, removing."
368
			rm -rv "${oldpath}" || die
369
			# we do not remove non-empty directories just for safety in case there's something else.
370
			# also it may fail if there are both compressed and uncompressed modules installed.
371
			rmdir -v --ignore-fail-on-non-empty "${oldpath%/*.*}" || die
372
		fi
373
	done
374
}
375

  
271 376
pkg_postinst() {
272 377
	udev_reload
273 378

  
274
	# we always need userspace utils in sync with zfs-kmod
275
	# so force initrd update for userspace as well, to avoid
276
	# situation when zfs-kmod trigger initrd rebuild before
277
	# userspace component is rebuilt
278
	# KV_* variables are provided by linux-info.eclass
279
	if [[ -z ${ROOT} ]] && use dist-kernel; then
280
		dist-kernel_reinstall_initramfs "${KV_DIR}" "${KV_FULL}"
379
	if use modules; then
380
		# Check for old module layout before doing anything else.
381
		# only attempt layout cleanup if new .ko location is used.
382
		local newko=( "${EROOT}/lib/modules/${KV_FULL}/extra"/{zfs,spl}.ko* )
383
		# We check first array member, if glob above did not exand, it will be "zfs.ko*" and -f will return false.
384
		# if glob expanded -f will do correct file precense check.
385
		[[ -f ${newko[0]} ]] && _old_layout_cleanup
386

  
387
		linux-mod-r1_pkg_postinst
388

  
389
		if use x86 || use arm ; then
390
			ewarn "32-bit kernels will likely require increasing vmalloc to"
391
			ewarn "at least 256M and decreasing zfs_arc_max to some value less than that."
392
		fi
393

  
394
		if has_version sys-boot/grub ; then
395
			ewarn "This version of OpenZFS includes support for new feature flags"
396
			ewarn "that are incompatible with previous versions. GRUB2 support for"
397
			ewarn "/boot with the new feature flags is not yet available."
398
			ewarn "Do *NOT* upgrade root pools to use the new feature flags."
399
			ewarn "Any new pools will be created with the new feature flags by default"
400
			ewarn "and will not be compatible with older versions of OpenZFS. To"
401
			ewarn "create a new pool that is backward compatible wih GRUB2, use "
402
			ewarn
403
			ewarn "zpool create -o compatibility=grub2 ..."
404
			ewarn
405
			ewarn "Refer to /usr/share/zfs/compatibility.d/grub2 for list of features."
406
		fi
281 407
	fi
282 408

  
283 409
	if use rootfs; then
Thank you!