public inbox for gentoo-dev@lists.gentoo.org
 help / color / mirror / Atom feed
* [gentoo-dev] [PATCH 0/3] dist-kernel-utils.eclass and support for initramfs-on-module rebuild
@ 2021-01-10 19:31 Michał Górny
  2021-01-10 19:32 ` [gentoo-dev] [PATCH 1/3] dist-kernel-utils.eclass: Introduce eclass for helper functions Michał Górny
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Michał Górny @ 2021-01-10 19:31 UTC (permalink / raw
  To: gentoo-dev; +Cc: Michał Górny

Hi,

Here's the next batch of patches to the dist-kernel framework.  This
includes:

1. Introducing a new dist-kernel-utils.eclass that can be used
   by packages that need some logic related to dist-kernel but do not
   want to fight the phase functions exported by the current eclasses.

2. Adding a new dist-kernel_reinstall_initramfs function that triggers
   initramfs rebuild and installkernel for the currently installed
   dist-kernel (if any).


The primary use case is ensuring that the necessary kernel modules
are included in the initramfs for the newly built kernel.  This relies
on the dist-kernel flag introduced by the previous patchset, that
triggers module rebuilds on kernel upgrade.  Technically, the process
is:

1. New kernel is installed, with 'broken' initramfs.

2. Modules are rebuilt, via slot operator rebuilds.

3. When important modules are rebuilt, initramfs is updated via their
   postinst.

This was requested for sys-fs/zfs-kmod, and the patch for it is included
in the thread.  However, I do not use ZFS, so I'd appreciate if someone
who does did a real-system testing.


Michał Górny (3):
  dist-kernel-utils.eclass: Introduce eclass for helper functions
  dist-kernel-utils.eclass: Add a function to rebuild initramfs
  sys-fs/zfs-kmod: Rebuild initramfs after installing

 eclass/dist-kernel-utils.eclass               | 132 ++++++++++++++++++
 eclass/kernel-build.eclass                    |   4 +-
 eclass/kernel-install.eclass                  |  80 ++---------
 sys-fs/zfs-kmod/zfs-kmod-0.8.6.ebuild         |   6 +-
 sys-fs/zfs-kmod/zfs-kmod-2.0.1.ebuild         |   6 +-
 sys-fs/zfs-kmod/zfs-kmod-9999.ebuild          |   6 +-
 .../gentoo-kernel-bin-5.10.3-r1.ebuild        |   2 +-
 .../gentoo-kernel-bin-5.10.3.ebuild           |   2 +-
 .../gentoo-kernel-bin-5.10.4-r1.ebuild        |   2 +-
 .../gentoo-kernel-bin-5.10.4.ebuild           |   2 +-
 .../gentoo-kernel-bin-5.10.5-r1.ebuild        |   2 +-
 .../gentoo-kernel-bin-5.10.5.ebuild           |   2 +-
 .../gentoo-kernel-bin-5.10.6.ebuild           |   2 +-
 .../gentoo-kernel-bin-5.4.80-r2.ebuild        |   2 +-
 .../gentoo-kernel-bin-5.4.83-r1.ebuild        |   2 +-
 .../gentoo-kernel-bin-5.4.83.ebuild           |   2 +-
 .../gentoo-kernel-bin-5.4.85-r1.ebuild        |   2 +-
 .../gentoo-kernel-bin-5.4.85.ebuild           |   2 +-
 .../gentoo-kernel-bin-5.4.86-r1.ebuild        |   2 +-
 .../gentoo-kernel-bin-5.4.86.ebuild           |   2 +-
 .../gentoo-kernel-bin-5.4.87-r1.ebuild        |   2 +-
 .../gentoo-kernel-bin-5.4.87.ebuild           |   2 +-
 .../gentoo-kernel-bin-5.4.88.ebuild           |   2 +-
 23 files changed, 174 insertions(+), 94 deletions(-)
 create mode 100644 eclass/dist-kernel-utils.eclass

-- 
2.30.0



^ permalink raw reply	[flat|nested] 4+ messages in thread

* [gentoo-dev] [PATCH 1/3] dist-kernel-utils.eclass: Introduce eclass for helper functions
  2021-01-10 19:31 [gentoo-dev] [PATCH 0/3] dist-kernel-utils.eclass and support for initramfs-on-module rebuild Michał Górny
@ 2021-01-10 19:32 ` Michał Górny
  2021-01-10 19:32 ` [gentoo-dev] [PATCH 2/3] dist-kernel-utils.eclass: Add a function to rebuild initramfs Michał Górny
  2021-01-10 19:32 ` [gentoo-dev] [PATCH 3/3] sys-fs/zfs-kmod: Rebuild initramfs after installing Michał Górny
  2 siblings, 0 replies; 4+ messages in thread
From: Michał Górny @ 2021-01-10 19:32 UTC (permalink / raw
  To: gentoo-dev; +Cc: Michał Górny

Move some of the utility functions from kernel-install.eclass
into dist-kernel-utils.eclass, in order to permit using them without
having all kernel-install phases exported.  This will be used in order
to support rebuilding initramfs in sys-fs/zfs-kmod.

Since the eclasses are used only by dist-kernel project eclasses
and ebuilds, update the function prefix while moving them.

Signed-off-by: Michał Górny <mgorny@gentoo.org>
---
 eclass/dist-kernel-utils.eclass               | 96 +++++++++++++++++++
 eclass/kernel-build.eclass                    |  4 +-
 eclass/kernel-install.eclass                  | 80 ++--------------
 .../gentoo-kernel-bin-5.10.3-r1.ebuild        |  2 +-
 .../gentoo-kernel-bin-5.10.3.ebuild           |  2 +-
 .../gentoo-kernel-bin-5.10.4-r1.ebuild        |  2 +-
 .../gentoo-kernel-bin-5.10.4.ebuild           |  2 +-
 .../gentoo-kernel-bin-5.10.5-r1.ebuild        |  2 +-
 .../gentoo-kernel-bin-5.10.5.ebuild           |  2 +-
 .../gentoo-kernel-bin-5.10.6.ebuild           |  2 +-
 .../gentoo-kernel-bin-5.4.80-r2.ebuild        |  2 +-
 .../gentoo-kernel-bin-5.4.83-r1.ebuild        |  2 +-
 .../gentoo-kernel-bin-5.4.83.ebuild           |  2 +-
 .../gentoo-kernel-bin-5.4.85-r1.ebuild        |  2 +-
 .../gentoo-kernel-bin-5.4.85.ebuild           |  2 +-
 .../gentoo-kernel-bin-5.4.86-r1.ebuild        |  2 +-
 .../gentoo-kernel-bin-5.4.86.ebuild           |  2 +-
 .../gentoo-kernel-bin-5.4.87-r1.ebuild        |  2 +-
 .../gentoo-kernel-bin-5.4.87.ebuild           |  2 +-
 .../gentoo-kernel-bin-5.4.88.ebuild           |  2 +-
 20 files changed, 123 insertions(+), 91 deletions(-)
 create mode 100644 eclass/dist-kernel-utils.eclass

diff --git a/eclass/dist-kernel-utils.eclass b/eclass/dist-kernel-utils.eclass
new file mode 100644
index 000000000000..cf7165d89947
--- /dev/null
+++ b/eclass/dist-kernel-utils.eclass
@@ -0,0 +1,96 @@
+# Copyright 2020-2021 Gentoo Authors
+# Distributed under the terms of the GNU General Public License v2
+
+# @ECLASS: dist-kernel-utils.eclass
+# @MAINTAINER:
+# Distribution Kernel Project <dist-kernel@gentoo.org>
+# @AUTHOR:
+# Michał Górny <mgorny@gentoo.org>
+# @SUPPORTED_EAPIS: 7
+# @BLURB: Utility functions related to Distribution Kernels
+# @DESCRIPTION:
+# This eclass provides various utility functions related to Distribution
+# Kernels.
+
+if [[ ! ${_DIST_KERNEL_UTILS} ]]; then
+
+case "${EAPI:-0}" in
+	0|1|2|3|4|5|6)
+		die "Unsupported EAPI=${EAPI:-0} (too old) for ${ECLASS}"
+		;;
+	7)
+		;;
+	*)
+		die "Unsupported EAPI=${EAPI} (unknown) for ${ECLASS}"
+		;;
+esac
+
+# @FUNCTION: dist-kernel_build_initramfs
+# @USAGE: <output> <version>
+# @DESCRIPTION:
+# Build an initramfs for the kernel.  <output> specifies the absolute
+# path where initramfs will be created, while <version> specifies
+# the kernel version, used to find modules.
+#
+# Note: while this function uses dracut at the moment, other initramfs
+# variants may be supported in the future.
+dist-kernel_build_initramfs() {
+	debug-print-function ${FUNCNAME} "${@}"
+
+	[[ ${#} -eq 2 ]] || die "${FUNCNAME}: invalid arguments"
+	local output=${1}
+	local version=${2}
+
+	ebegin "Building initramfs via dracut"
+	dracut --force "${output}" "${version}"
+	eend ${?} || die "Building initramfs failed"
+}
+
+# @FUNCTION: dist-kernel_get_image_path
+# @DESCRIPTION:
+# Get relative kernel image path specific to the current ${ARCH}.
+dist-kernel_get_image_path() {
+	case ${ARCH} in
+		amd64|x86)
+			echo arch/x86/boot/bzImage
+			;;
+		arm64)
+			echo arch/arm64/boot/Image.gz
+			;;
+		arm)
+			echo arch/arm/boot/zImage
+			;;
+		ppc64)
+			# ./ is required because of ${image_path%/*}
+			# substitutions in the code
+			echo ./vmlinux
+			;;
+		*)
+			die "${FUNCNAME}: unsupported ARCH=${ARCH}"
+			;;
+	esac
+}
+
+# @FUNCTION: dist-kernel_install_kernel
+# @USAGE: <version> <image> <system.map>
+# @DESCRIPTION:
+# Install kernel using installkernel tool.  <version> specifies
+# the kernel version, <image> full path to the image, <system.map>
+# full path to System.map.
+dist-kernel_install_kernel() {
+	debug-print-function ${FUNCNAME} "${@}"
+
+	[[ ${#} -eq 3 ]] || die "${FUNCNAME}: invalid arguments"
+	local version=${1}
+	local image=${2}
+	local map=${3}
+
+	ebegin "Installing the kernel via installkernel"
+	# note: .config is taken relatively to System.map;
+	# initrd relatively to bzImage
+	installkernel "${version}" "${image}" "${map}"
+	eend ${?} || die "Installing the kernel failed"
+}
+
+_DIST_KERNEL_UTILS=1
+fi
diff --git a/eclass/kernel-build.eclass b/eclass/kernel-build.eclass
index 99279ba58a99..d13b002f5ce1 100644
--- a/eclass/kernel-build.eclass
+++ b/eclass/kernel-build.eclass
@@ -117,7 +117,7 @@ kernel-build_src_test() {
 
 	local ver="${PV}${KV_LOCALVERSION}"
 	kernel-install_test "${ver}" \
-		"${WORKDIR}/build/$(kernel-install_get_image_path)" \
+		"${WORKDIR}/build/$(dist-kernel_get_image_path)" \
 		"${T}/lib/modules/${ver}"
 }
 
@@ -173,7 +173,7 @@ kernel-build_src_install() {
 	# install the kernel and files needed for module builds
 	insinto "/usr/src/linux-${ver}"
 	doins build/{System.map,Module.symvers}
-	local image_path=$(kernel-install_get_image_path)
+	local image_path=$(dist-kernel_get_image_path)
 	cp -p "build/${image_path}" "${ED}/usr/src/linux-${ver}/${image_path}" || die
 
 	# building modules fails with 'vmlinux has no symtab?' if stripped
diff --git a/eclass/kernel-install.eclass b/eclass/kernel-install.eclass
index e826626e13f2..a2f7bd55b9c0 100644
--- a/eclass/kernel-install.eclass
+++ b/eclass/kernel-install.eclass
@@ -40,7 +40,7 @@ case "${EAPI:-0}" in
 		;;
 esac
 
-inherit mount-boot toolchain-funcs
+inherit dist-kernel-utils mount-boot toolchain-funcs
 
 SLOT="${PV}"
 IUSE="+initramfs test"
@@ -70,70 +70,6 @@ BDEPEND="
 		x86? ( app-emulation/qemu[qemu_softmmu_targets_i386] )
 	)"
 
-# @FUNCTION: kernel-install_build_initramfs
-# @USAGE: <output> <version>
-# @DESCRIPTION:
-# Build an initramfs for the kernel.  <output> specifies the absolute
-# path where initramfs will be created, while <version> specifies
-# the kernel version, used to find modules.
-kernel-install_build_initramfs() {
-	debug-print-function ${FUNCNAME} "${@}"
-
-	[[ ${#} -eq 2 ]] || die "${FUNCNAME}: invalid arguments"
-	local output=${1}
-	local version=${2}
-
-	ebegin "Building initramfs via dracut"
-	dracut --force "${output}" "${version}"
-	eend ${?} || die "Building initramfs failed"
-}
-
-# @FUNCTION: kernel-install_get_image_path
-# @DESCRIPTION:
-# Get relative kernel image path specific to the current ${ARCH}.
-kernel-install_get_image_path() {
-	case ${ARCH} in
-		amd64|x86)
-			echo arch/x86/boot/bzImage
-			;;
-		arm64)
-			echo arch/arm64/boot/Image.gz
-			;;
-		arm)
-			echo arch/arm/boot/zImage
-			;;
-		ppc64)
-			# ./ is required because of ${image_path%/*}
-			# substitutions in the code
-			echo ./vmlinux
-			;;
-		*)
-			die "${FUNCNAME}: unsupported ARCH=${ARCH}"
-			;;
-	esac
-}
-
-# @FUNCTION: kernel-install_install_kernel
-# @USAGE: <version> <image> <system.map>
-# @DESCRIPTION:
-# Install kernel using installkernel tool.  <version> specifies
-# the kernel version, <image> full path to the image, <system.map>
-# full path to System.map.
-kernel-install_install_kernel() {
-	debug-print-function ${FUNCNAME} "${@}"
-
-	[[ ${#} -eq 3 ]] || die "${FUNCNAME}: invalid arguments"
-	local version=${1}
-	local image=${2}
-	local map=${3}
-
-	ebegin "Installing the kernel via installkernel"
-	# note: .config is taken relatively to System.map;
-	# initrd relatively to bzImage
-	installkernel "${version}" "${image}" "${map}"
-	eend ${?} || die "Installing the kernel failed"
-}
-
 # @FUNCTION: kernel-install_update_symlink
 # @USAGE: <target> <version>
 # @DESCRIPTION:
@@ -406,16 +342,16 @@ kernel-install_pkg_postinst() {
 		mount-boot_pkg_preinst
 
 		local ver="${PV}${KV_LOCALVERSION}"
-		local image_path=$(kernel-install_get_image_path)
+		local image_path=$(dist-kernel_get_image_path)
 		if use initramfs; then
 			# putting it alongside kernel image as 'initrd' makes
 			# kernel-install happier
-			kernel-install_build_initramfs \
+			dist-kernel_build_initramfs \
 				"${EROOT}/usr/src/linux-${ver}/${image_path%/*}/initrd" \
 				"${ver}"
 		fi
 
-		kernel-install_install_kernel "${ver}" \
+		dist-kernel_install_kernel "${ver}" \
 			"${EROOT}/usr/src/linux-${ver}/${image_path}" \
 			"${EROOT}/usr/src/linux-${ver}/System.map"
 	fi
@@ -441,7 +377,7 @@ kernel-install_pkg_postrm() {
 
 	if [[ -z ${ROOT} ]] && use initramfs; then
 		local ver="${PV}${KV_LOCALVERSION}"
-		local image_path=$(kernel-install_get_image_path)
+		local image_path=$(dist-kernel_get_image_path)
 		ebegin "Removing initramfs"
 		rm -f "${EROOT}/usr/src/linux-${ver}/${image_path%/*}/initrd" &&
 			find "${EROOT}/usr/src/linux-${ver}" -depth -type d -empty -delete
@@ -458,16 +394,16 @@ kernel-install_pkg_config() {
 	mount-boot_pkg_preinst
 
 	local ver="${PV}${KV_LOCALVERSION}"
-	local image_path=$(kernel-install_get_image_path)
+	local image_path=$(dist-kernel_get_image_path)
 	if use initramfs; then
 		# putting it alongside kernel image as 'initrd' makes
 		# kernel-install happier
-		kernel-install_build_initramfs \
+		dist-kernel_build_initramfs \
 			"${EROOT}/usr/src/linux-${ver}/${image_path%/*}/initrd" \
 			"${ver}"
 	fi
 
-	kernel-install_install_kernel "${ver}" \
+	dist-kernel_install_kernel "${ver}" \
 		"${EROOT}/usr/src/linux-${ver}/${image_path}" \
 		"${EROOT}/usr/src/linux-${ver}/System.map"
 }
diff --git a/sys-kernel/gentoo-kernel-bin/gentoo-kernel-bin-5.10.3-r1.ebuild b/sys-kernel/gentoo-kernel-bin/gentoo-kernel-bin-5.10.3-r1.ebuild
index 1b430cf56222..877b8ca0e49e 100644
--- a/sys-kernel/gentoo-kernel-bin/gentoo-kernel-bin-5.10.3-r1.ebuild
+++ b/sys-kernel/gentoo-kernel-bin/gentoo-kernel-bin-5.10.3-r1.ebuild
@@ -33,7 +33,7 @@ src_unpack() {
 
 src_test() {
 	kernel-install_test "${PV}" \
-		"${WORKDIR}/usr/src/linux-${PV}/$(kernel-install_get_image_path)" \
+		"${WORKDIR}/usr/src/linux-${PV}/$(dist-kernel_get_image_path)" \
 		"lib/modules/${PV}"
 }
 
diff --git a/sys-kernel/gentoo-kernel-bin/gentoo-kernel-bin-5.10.3.ebuild b/sys-kernel/gentoo-kernel-bin/gentoo-kernel-bin-5.10.3.ebuild
index 68ca59b57351..30f0bbd5163a 100644
--- a/sys-kernel/gentoo-kernel-bin/gentoo-kernel-bin-5.10.3.ebuild
+++ b/sys-kernel/gentoo-kernel-bin/gentoo-kernel-bin-5.10.3.ebuild
@@ -37,7 +37,7 @@ src_unpack() {
 
 src_test() {
 	kernel-install_test "${PV}" \
-		"${WORKDIR}/usr/src/linux-${PV}/$(kernel-install_get_image_path)" \
+		"${WORKDIR}/usr/src/linux-${PV}/$(dist-kernel_get_image_path)" \
 		"lib/modules/${PV}"
 }
 
diff --git a/sys-kernel/gentoo-kernel-bin/gentoo-kernel-bin-5.10.4-r1.ebuild b/sys-kernel/gentoo-kernel-bin/gentoo-kernel-bin-5.10.4-r1.ebuild
index 8ff91a4ba931..fa7357082db9 100644
--- a/sys-kernel/gentoo-kernel-bin/gentoo-kernel-bin-5.10.4-r1.ebuild
+++ b/sys-kernel/gentoo-kernel-bin/gentoo-kernel-bin-5.10.4-r1.ebuild
@@ -35,7 +35,7 @@ src_unpack() {
 
 src_test() {
 	kernel-install_test "${PV}" \
-		"${WORKDIR}/usr/src/linux-${PV}/$(kernel-install_get_image_path)" \
+		"${WORKDIR}/usr/src/linux-${PV}/$(dist-kernel_get_image_path)" \
 		"lib/modules/${PV}"
 }
 
diff --git a/sys-kernel/gentoo-kernel-bin/gentoo-kernel-bin-5.10.4.ebuild b/sys-kernel/gentoo-kernel-bin/gentoo-kernel-bin-5.10.4.ebuild
index 89b5eb86defb..31b6fee9f812 100644
--- a/sys-kernel/gentoo-kernel-bin/gentoo-kernel-bin-5.10.4.ebuild
+++ b/sys-kernel/gentoo-kernel-bin/gentoo-kernel-bin-5.10.4.ebuild
@@ -39,7 +39,7 @@ src_unpack() {
 
 src_test() {
 	kernel-install_test "${PV}" \
-		"${WORKDIR}/usr/src/linux-${PV}/$(kernel-install_get_image_path)" \
+		"${WORKDIR}/usr/src/linux-${PV}/$(dist-kernel_get_image_path)" \
 		"lib/modules/${PV}"
 }
 
diff --git a/sys-kernel/gentoo-kernel-bin/gentoo-kernel-bin-5.10.5-r1.ebuild b/sys-kernel/gentoo-kernel-bin/gentoo-kernel-bin-5.10.5-r1.ebuild
index 8ff91a4ba931..fa7357082db9 100644
--- a/sys-kernel/gentoo-kernel-bin/gentoo-kernel-bin-5.10.5-r1.ebuild
+++ b/sys-kernel/gentoo-kernel-bin/gentoo-kernel-bin-5.10.5-r1.ebuild
@@ -35,7 +35,7 @@ src_unpack() {
 
 src_test() {
 	kernel-install_test "${PV}" \
-		"${WORKDIR}/usr/src/linux-${PV}/$(kernel-install_get_image_path)" \
+		"${WORKDIR}/usr/src/linux-${PV}/$(dist-kernel_get_image_path)" \
 		"lib/modules/${PV}"
 }
 
diff --git a/sys-kernel/gentoo-kernel-bin/gentoo-kernel-bin-5.10.5.ebuild b/sys-kernel/gentoo-kernel-bin/gentoo-kernel-bin-5.10.5.ebuild
index 89b5eb86defb..31b6fee9f812 100644
--- a/sys-kernel/gentoo-kernel-bin/gentoo-kernel-bin-5.10.5.ebuild
+++ b/sys-kernel/gentoo-kernel-bin/gentoo-kernel-bin-5.10.5.ebuild
@@ -39,7 +39,7 @@ src_unpack() {
 
 src_test() {
 	kernel-install_test "${PV}" \
-		"${WORKDIR}/usr/src/linux-${PV}/$(kernel-install_get_image_path)" \
+		"${WORKDIR}/usr/src/linux-${PV}/$(dist-kernel_get_image_path)" \
 		"lib/modules/${PV}"
 }
 
diff --git a/sys-kernel/gentoo-kernel-bin/gentoo-kernel-bin-5.10.6.ebuild b/sys-kernel/gentoo-kernel-bin/gentoo-kernel-bin-5.10.6.ebuild
index 89b5eb86defb..31b6fee9f812 100644
--- a/sys-kernel/gentoo-kernel-bin/gentoo-kernel-bin-5.10.6.ebuild
+++ b/sys-kernel/gentoo-kernel-bin/gentoo-kernel-bin-5.10.6.ebuild
@@ -39,7 +39,7 @@ src_unpack() {
 
 src_test() {
 	kernel-install_test "${PV}" \
-		"${WORKDIR}/usr/src/linux-${PV}/$(kernel-install_get_image_path)" \
+		"${WORKDIR}/usr/src/linux-${PV}/$(dist-kernel_get_image_path)" \
 		"lib/modules/${PV}"
 }
 
diff --git a/sys-kernel/gentoo-kernel-bin/gentoo-kernel-bin-5.4.80-r2.ebuild b/sys-kernel/gentoo-kernel-bin/gentoo-kernel-bin-5.4.80-r2.ebuild
index 303c752a7bc6..3c35619d286b 100644
--- a/sys-kernel/gentoo-kernel-bin/gentoo-kernel-bin-5.4.80-r2.ebuild
+++ b/sys-kernel/gentoo-kernel-bin/gentoo-kernel-bin-5.4.80-r2.ebuild
@@ -44,7 +44,7 @@ src_unpack() {
 
 src_test() {
 	kernel-install_test "${PV}" \
-		"${WORKDIR}/usr/src/linux-${PV}/$(kernel-install_get_image_path)" \
+		"${WORKDIR}/usr/src/linux-${PV}/$(dist-kernel_get_image_path)" \
 		"lib/modules/${PV}"
 }
 
diff --git a/sys-kernel/gentoo-kernel-bin/gentoo-kernel-bin-5.4.83-r1.ebuild b/sys-kernel/gentoo-kernel-bin/gentoo-kernel-bin-5.4.83-r1.ebuild
index 5ba1bd156ea4..a61ddfdf57b7 100644
--- a/sys-kernel/gentoo-kernel-bin/gentoo-kernel-bin-5.4.83-r1.ebuild
+++ b/sys-kernel/gentoo-kernel-bin/gentoo-kernel-bin-5.4.83-r1.ebuild
@@ -48,7 +48,7 @@ src_unpack() {
 
 src_test() {
 	kernel-install_test "${PV}" \
-		"${WORKDIR}/usr/src/linux-${PV}/$(kernel-install_get_image_path)" \
+		"${WORKDIR}/usr/src/linux-${PV}/$(dist-kernel_get_image_path)" \
 		"lib/modules/${PV}"
 }
 
diff --git a/sys-kernel/gentoo-kernel-bin/gentoo-kernel-bin-5.4.83.ebuild b/sys-kernel/gentoo-kernel-bin/gentoo-kernel-bin-5.4.83.ebuild
index 1e1643331694..cef28ee2e6a7 100644
--- a/sys-kernel/gentoo-kernel-bin/gentoo-kernel-bin-5.4.83.ebuild
+++ b/sys-kernel/gentoo-kernel-bin/gentoo-kernel-bin-5.4.83.ebuild
@@ -44,7 +44,7 @@ src_unpack() {
 
 src_test() {
 	kernel-install_test "${PV}" \
-		"${WORKDIR}/usr/src/linux-${PV}/$(kernel-install_get_image_path)" \
+		"${WORKDIR}/usr/src/linux-${PV}/$(dist-kernel_get_image_path)" \
 		"lib/modules/${PV}"
 }
 
diff --git a/sys-kernel/gentoo-kernel-bin/gentoo-kernel-bin-5.4.85-r1.ebuild b/sys-kernel/gentoo-kernel-bin/gentoo-kernel-bin-5.4.85-r1.ebuild
index 2378adc3f352..c3da4264d118 100644
--- a/sys-kernel/gentoo-kernel-bin/gentoo-kernel-bin-5.4.85-r1.ebuild
+++ b/sys-kernel/gentoo-kernel-bin/gentoo-kernel-bin-5.4.85-r1.ebuild
@@ -48,7 +48,7 @@ src_unpack() {
 
 src_test() {
 	kernel-install_test "${PV}" \
-		"${WORKDIR}/usr/src/linux-${PV}/$(kernel-install_get_image_path)" \
+		"${WORKDIR}/usr/src/linux-${PV}/$(dist-kernel_get_image_path)" \
 		"lib/modules/${PV}"
 }
 
diff --git a/sys-kernel/gentoo-kernel-bin/gentoo-kernel-bin-5.4.85.ebuild b/sys-kernel/gentoo-kernel-bin/gentoo-kernel-bin-5.4.85.ebuild
index d6e61fa69369..753e4bddf47c 100644
--- a/sys-kernel/gentoo-kernel-bin/gentoo-kernel-bin-5.4.85.ebuild
+++ b/sys-kernel/gentoo-kernel-bin/gentoo-kernel-bin-5.4.85.ebuild
@@ -44,7 +44,7 @@ src_unpack() {
 
 src_test() {
 	kernel-install_test "${PV}" \
-		"${WORKDIR}/usr/src/linux-${PV}/$(kernel-install_get_image_path)" \
+		"${WORKDIR}/usr/src/linux-${PV}/$(dist-kernel_get_image_path)" \
 		"lib/modules/${PV}"
 }
 
diff --git a/sys-kernel/gentoo-kernel-bin/gentoo-kernel-bin-5.4.86-r1.ebuild b/sys-kernel/gentoo-kernel-bin/gentoo-kernel-bin-5.4.86-r1.ebuild
index cced2ee66bff..8ec8fdea9936 100644
--- a/sys-kernel/gentoo-kernel-bin/gentoo-kernel-bin-5.4.86-r1.ebuild
+++ b/sys-kernel/gentoo-kernel-bin/gentoo-kernel-bin-5.4.86-r1.ebuild
@@ -50,7 +50,7 @@ src_unpack() {
 
 src_test() {
 	kernel-install_test "${PV}" \
-		"${WORKDIR}/usr/src/linux-${PV}/$(kernel-install_get_image_path)" \
+		"${WORKDIR}/usr/src/linux-${PV}/$(dist-kernel_get_image_path)" \
 		"lib/modules/${PV}"
 }
 
diff --git a/sys-kernel/gentoo-kernel-bin/gentoo-kernel-bin-5.4.86.ebuild b/sys-kernel/gentoo-kernel-bin/gentoo-kernel-bin-5.4.86.ebuild
index 6021b37ab4b4..b8eb2c63573a 100644
--- a/sys-kernel/gentoo-kernel-bin/gentoo-kernel-bin-5.4.86.ebuild
+++ b/sys-kernel/gentoo-kernel-bin/gentoo-kernel-bin-5.4.86.ebuild
@@ -46,7 +46,7 @@ src_unpack() {
 
 src_test() {
 	kernel-install_test "${PV}" \
-		"${WORKDIR}/usr/src/linux-${PV}/$(kernel-install_get_image_path)" \
+		"${WORKDIR}/usr/src/linux-${PV}/$(dist-kernel_get_image_path)" \
 		"lib/modules/${PV}"
 }
 
diff --git a/sys-kernel/gentoo-kernel-bin/gentoo-kernel-bin-5.4.87-r1.ebuild b/sys-kernel/gentoo-kernel-bin/gentoo-kernel-bin-5.4.87-r1.ebuild
index cced2ee66bff..8ec8fdea9936 100644
--- a/sys-kernel/gentoo-kernel-bin/gentoo-kernel-bin-5.4.87-r1.ebuild
+++ b/sys-kernel/gentoo-kernel-bin/gentoo-kernel-bin-5.4.87-r1.ebuild
@@ -50,7 +50,7 @@ src_unpack() {
 
 src_test() {
 	kernel-install_test "${PV}" \
-		"${WORKDIR}/usr/src/linux-${PV}/$(kernel-install_get_image_path)" \
+		"${WORKDIR}/usr/src/linux-${PV}/$(dist-kernel_get_image_path)" \
 		"lib/modules/${PV}"
 }
 
diff --git a/sys-kernel/gentoo-kernel-bin/gentoo-kernel-bin-5.4.87.ebuild b/sys-kernel/gentoo-kernel-bin/gentoo-kernel-bin-5.4.87.ebuild
index 6021b37ab4b4..b8eb2c63573a 100644
--- a/sys-kernel/gentoo-kernel-bin/gentoo-kernel-bin-5.4.87.ebuild
+++ b/sys-kernel/gentoo-kernel-bin/gentoo-kernel-bin-5.4.87.ebuild
@@ -46,7 +46,7 @@ src_unpack() {
 
 src_test() {
 	kernel-install_test "${PV}" \
-		"${WORKDIR}/usr/src/linux-${PV}/$(kernel-install_get_image_path)" \
+		"${WORKDIR}/usr/src/linux-${PV}/$(dist-kernel_get_image_path)" \
 		"lib/modules/${PV}"
 }
 
diff --git a/sys-kernel/gentoo-kernel-bin/gentoo-kernel-bin-5.4.88.ebuild b/sys-kernel/gentoo-kernel-bin/gentoo-kernel-bin-5.4.88.ebuild
index 6021b37ab4b4..b8eb2c63573a 100644
--- a/sys-kernel/gentoo-kernel-bin/gentoo-kernel-bin-5.4.88.ebuild
+++ b/sys-kernel/gentoo-kernel-bin/gentoo-kernel-bin-5.4.88.ebuild
@@ -46,7 +46,7 @@ src_unpack() {
 
 src_test() {
 	kernel-install_test "${PV}" \
-		"${WORKDIR}/usr/src/linux-${PV}/$(kernel-install_get_image_path)" \
+		"${WORKDIR}/usr/src/linux-${PV}/$(dist-kernel_get_image_path)" \
 		"lib/modules/${PV}"
 }
 
-- 
2.30.0



^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [gentoo-dev] [PATCH 2/3] dist-kernel-utils.eclass: Add a function to rebuild initramfs
  2021-01-10 19:31 [gentoo-dev] [PATCH 0/3] dist-kernel-utils.eclass and support for initramfs-on-module rebuild Michał Górny
  2021-01-10 19:32 ` [gentoo-dev] [PATCH 1/3] dist-kernel-utils.eclass: Introduce eclass for helper functions Michał Górny
@ 2021-01-10 19:32 ` Michał Górny
  2021-01-10 19:32 ` [gentoo-dev] [PATCH 3/3] sys-fs/zfs-kmod: Rebuild initramfs after installing Michał Górny
  2 siblings, 0 replies; 4+ messages in thread
From: Michał Górny @ 2021-01-10 19:32 UTC (permalink / raw
  To: gentoo-dev; +Cc: Michał Górny

Signed-off-by: Michał Górny <mgorny@gentoo.org>
---
 eclass/dist-kernel-utils.eclass | 36 +++++++++++++++++++++++++++++++++
 1 file changed, 36 insertions(+)

diff --git a/eclass/dist-kernel-utils.eclass b/eclass/dist-kernel-utils.eclass
index cf7165d89947..d92642a25a0a 100644
--- a/eclass/dist-kernel-utils.eclass
+++ b/eclass/dist-kernel-utils.eclass
@@ -92,5 +92,41 @@ dist-kernel_install_kernel() {
 	eend ${?} || die "Installing the kernel failed"
 }
 
+# @FUNCTION: dist-kernel_reinstall_initramfs
+# @USAGE: <kv-dir> <kv-full>
+# @DESCRIPTION:
+# Rebuild and install initramfs for the specified dist-kernel.
+# <kv-dir> is the kernel source directory (${KV_DIR} from linux-info),
+# while <kv-full> is the full kernel version (${KV_FULL}).
+# The function will determine whether <kernel-dir> is actually
+# a dist-kernel, and whether initramfs was used.
+#
+# This function is to be used in pkg_postinst() of ebuilds installing
+# kernel modules that are included in the initramfs.
+dist-kernel_reinstall_initramfs() {
+	debug-print-function ${FUNCNAME} "${@}"
+
+	[[ ${#} -eq 2 ]] || die "${FUNCNAME}: invalid arguments"
+	local kernel_dir=${1}
+	local ver=${2}
+
+	local image_path=${kernel_dir}/$(dist-kernel_get_image_path)
+	local initramfs_path=${image_path%/*}/initrd
+	if [[ ! -f ${image_path} ]]; then
+		eerror "Kernel install missing, image not found:"
+		eerror "  ${image_path}"
+		eerror "Initramfs will not be updated.  Please reinstall your kernel."
+		return
+	fi
+	if [[ ! -f ${initramfs_path} ]]; then
+		einfo "No initramfs found at ${initramfs_path}"
+		return
+	fi
+
+	dist-kernel_build_initramfs "${initramfs_path}" "${ver}"
+	dist-kernel_install_kernel "${ver}" "${image_path}" \
+		"${kernel_dir}/System.map"
+}
+
 _DIST_KERNEL_UTILS=1
 fi
-- 
2.30.0



^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [gentoo-dev] [PATCH 3/3] sys-fs/zfs-kmod: Rebuild initramfs after installing
  2021-01-10 19:31 [gentoo-dev] [PATCH 0/3] dist-kernel-utils.eclass and support for initramfs-on-module rebuild Michał Górny
  2021-01-10 19:32 ` [gentoo-dev] [PATCH 1/3] dist-kernel-utils.eclass: Introduce eclass for helper functions Michał Górny
  2021-01-10 19:32 ` [gentoo-dev] [PATCH 2/3] dist-kernel-utils.eclass: Add a function to rebuild initramfs Michał Górny
@ 2021-01-10 19:32 ` Michał Górny
  2 siblings, 0 replies; 4+ messages in thread
From: Michał Górny @ 2021-01-10 19:32 UTC (permalink / raw
  To: gentoo-dev; +Cc: Michał Górny

Signed-off-by: Michał Górny <mgorny@gentoo.org>
---
 sys-fs/zfs-kmod/zfs-kmod-0.8.6.ebuild | 6 +++++-
 sys-fs/zfs-kmod/zfs-kmod-2.0.1.ebuild | 6 +++++-
 sys-fs/zfs-kmod/zfs-kmod-9999.ebuild  | 6 +++++-
 3 files changed, 15 insertions(+), 3 deletions(-)

diff --git a/sys-fs/zfs-kmod/zfs-kmod-0.8.6.ebuild b/sys-fs/zfs-kmod/zfs-kmod-0.8.6.ebuild
index 9067f3662366..2e05194236ed 100644
--- a/sys-fs/zfs-kmod/zfs-kmod-0.8.6.ebuild
+++ b/sys-fs/zfs-kmod/zfs-kmod-0.8.6.ebuild
@@ -3,7 +3,7 @@
 
 EAPI=7
 
-inherit autotools flag-o-matic linux-mod toolchain-funcs
+inherit autotools dist-kernel-utils flag-o-matic linux-mod toolchain-funcs
 
 DESCRIPTION="Linux ZFS kernel module for sys-fs/zfs"
 HOMEPAGE="https://github.com/openzfs/zfs"
@@ -158,6 +158,10 @@ pkg_postinst() {
 		rmdir --ignore-fail-on-non-empty "${EROOT}/lib/modules/${KV_FULL}/addon"
 	fi
 
+	if [[ -z ${ROOT} ]] && use dist-kernel; then
+		dist-kernel_reinstall_initramfs "${KV_DIR}" "${KV_FULL}"
+	fi
+
 	if use x86 || use arm; then
 		ewarn "32-bit kernels will likely require increasing vmalloc to"
 		ewarn "at least 256M and decreasing zfs_arc_max to some value less than that."
diff --git a/sys-fs/zfs-kmod/zfs-kmod-2.0.1.ebuild b/sys-fs/zfs-kmod/zfs-kmod-2.0.1.ebuild
index 4ea7b063affe..2fbfd85f7ccf 100644
--- a/sys-fs/zfs-kmod/zfs-kmod-2.0.1.ebuild
+++ b/sys-fs/zfs-kmod/zfs-kmod-2.0.1.ebuild
@@ -3,7 +3,7 @@
 
 EAPI=7
 
-inherit autotools flag-o-matic linux-mod toolchain-funcs
+inherit autotools dist-kernel-utils flag-o-matic linux-mod toolchain-funcs
 
 DESCRIPTION="Linux ZFS kernel module for sys-fs/zfs"
 HOMEPAGE="https://github.com/openzfs/zfs"
@@ -149,6 +149,10 @@ pkg_postinst() {
 		rmdir --ignore-fail-on-non-empty "${EROOT}/lib/modules/${KV_FULL}/addon"
 	fi
 
+	if [[ -z ${ROOT} ]] && use dist-kernel; then
+		dist-kernel_reinstall_initramfs "${KV_DIR}" "${KV_FULL}"
+	fi
+
 	if use x86 || use arm; then
 		ewarn "32-bit kernels will likely require increasing vmalloc to"
 		ewarn "at least 256M and decreasing zfs_arc_max to some value less than that."
diff --git a/sys-fs/zfs-kmod/zfs-kmod-9999.ebuild b/sys-fs/zfs-kmod/zfs-kmod-9999.ebuild
index 4ea7b063affe..2fbfd85f7ccf 100644
--- a/sys-fs/zfs-kmod/zfs-kmod-9999.ebuild
+++ b/sys-fs/zfs-kmod/zfs-kmod-9999.ebuild
@@ -3,7 +3,7 @@
 
 EAPI=7
 
-inherit autotools flag-o-matic linux-mod toolchain-funcs
+inherit autotools dist-kernel-utils flag-o-matic linux-mod toolchain-funcs
 
 DESCRIPTION="Linux ZFS kernel module for sys-fs/zfs"
 HOMEPAGE="https://github.com/openzfs/zfs"
@@ -149,6 +149,10 @@ pkg_postinst() {
 		rmdir --ignore-fail-on-non-empty "${EROOT}/lib/modules/${KV_FULL}/addon"
 	fi
 
+	if [[ -z ${ROOT} ]] && use dist-kernel; then
+		dist-kernel_reinstall_initramfs "${KV_DIR}" "${KV_FULL}"
+	fi
+
 	if use x86 || use arm; then
 		ewarn "32-bit kernels will likely require increasing vmalloc to"
 		ewarn "at least 256M and decreasing zfs_arc_max to some value less than that."
-- 
2.30.0



^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2021-01-10 19:33 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-01-10 19:31 [gentoo-dev] [PATCH 0/3] dist-kernel-utils.eclass and support for initramfs-on-module rebuild Michał Górny
2021-01-10 19:32 ` [gentoo-dev] [PATCH 1/3] dist-kernel-utils.eclass: Introduce eclass for helper functions Michał Górny
2021-01-10 19:32 ` [gentoo-dev] [PATCH 2/3] dist-kernel-utils.eclass: Add a function to rebuild initramfs Michał Górny
2021-01-10 19:32 ` [gentoo-dev] [PATCH 3/3] sys-fs/zfs-kmod: Rebuild initramfs after installing Michał Górny

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox