Gentoo Archives: gentoo-dev

From: "Michał Górny" <mgorny@g.o>
To: gentoo-dev@l.g.o
Cc: "Michał Górny" <mgorny@g.o>
Subject: [gentoo-dev] [PATCH 1/6] kernel-install.eclass: Move common to kernel-install_install_all
Date: Wed, 13 Jan 2021 14:36:25
Message-Id: 20210113143516.1766-2-mgorny@gentoo.org
In Reply to: [gentoo-dev] [PATCH 0/6] kernel-install.eclass: dracut uefi=yes support + improved error handling by "Michał Górny"
1 Move the code shared by pkg_postinst() and pkg_config() to a new
2 kernel-install_install_all() function. After all, the purpose
3 of pkg_config() is to repeat what pkg_postinst() does normally.
4 Keeping it in a common function improves maintainability.
5
6 Signed-off-by: Michał Górny <mgorny@g.o>
7 ---
8 eclass/kernel-install.eclass | 62 +++++++++++++++++++-----------------
9 1 file changed, 32 insertions(+), 30 deletions(-)
10
11 diff --git a/eclass/kernel-install.eclass b/eclass/kernel-install.eclass
12 index 3b4af9e51c07..b1d48b6b3b5a 100644
13 --- a/eclass/kernel-install.eclass
14 +++ b/eclass/kernel-install.eclass
15 @@ -331,6 +331,34 @@ kernel-install_pkg_preinst() {
16 # (no-op)
17 }
18
19 +# @FUNCTION: kernel-install_install_all
20 +# @USAGE: <ver>
21 +# @DESCRIPTION:
22 +# Build an initramfs for the kernel and install the kernel. This is
23 +# called from pkg_postinst() and pkg_config(). <ver> is the full
24 +# kernel version.
25 +kernel-install_install_all() {
26 + debug-print-function ${FUNCNAME} "${@}"
27 +
28 + [[ ${#} -eq 1 ]] || die "${FUNCNAME}: invalid arguments"
29 + local ver=${1}
30 +
31 + mount-boot_pkg_preinst
32 +
33 + local image_path=$(dist-kernel_get_image_path)
34 + if use initramfs; then
35 + # putting it alongside kernel image as 'initrd' makes
36 + # kernel-install happier
37 + dist-kernel_build_initramfs \
38 + "${EROOT}/usr/src/linux-${ver}/${image_path%/*}/initrd" \
39 + "${ver}"
40 + fi
41 +
42 + dist-kernel_install_kernel "${ver}" \
43 + "${EROOT}/usr/src/linux-${ver}/${image_path}" \
44 + "${EROOT}/usr/src/linux-${ver}/System.map"
45 +}
46 +
47 # @FUNCTION: kernel-install_pkg_postinst
48 # @DESCRIPTION:
49 # Build an initramfs for the kernel, install it and update
50 @@ -338,22 +366,10 @@ kernel-install_pkg_preinst() {
51 kernel-install_pkg_postinst() {
52 debug-print-function ${FUNCNAME} "${@}"
53
54 - if [[ -z ${ROOT} ]]; then
55 - mount-boot_pkg_preinst
56 -
57 - local ver="${PV}${KV_LOCALVERSION}"
58 - local image_path=$(dist-kernel_get_image_path)
59 - if use initramfs; then
60 - # putting it alongside kernel image as 'initrd' makes
61 - # kernel-install happier
62 - dist-kernel_build_initramfs \
63 - "${EROOT}/usr/src/linux-${ver}/${image_path%/*}/initrd" \
64 - "${ver}"
65 - fi
66 + local ver="${PV}${KV_LOCALVERSION}"
67
68 - dist-kernel_install_kernel "${ver}" \
69 - "${EROOT}/usr/src/linux-${ver}/${image_path}" \
70 - "${EROOT}/usr/src/linux-${ver}/System.map"
71 + if [[ -z ${ROOT} ]]; then
72 + kernel-install_install_all "${ver}"
73 fi
74
75 kernel-install_update_symlink "${EROOT}/usr/src/linux" "${ver}"
76 @@ -391,21 +407,7 @@ kernel-install_pkg_postrm() {
77 kernel-install_pkg_config() {
78 [[ -z ${ROOT} ]] || die "ROOT!=/ not supported currently"
79
80 - mount-boot_pkg_preinst
81 -
82 - local ver="${PV}${KV_LOCALVERSION}"
83 - local image_path=$(dist-kernel_get_image_path)
84 - if use initramfs; then
85 - # putting it alongside kernel image as 'initrd' makes
86 - # kernel-install happier
87 - dist-kernel_build_initramfs \
88 - "${EROOT}/usr/src/linux-${ver}/${image_path%/*}/initrd" \
89 - "${ver}"
90 - fi
91 -
92 - dist-kernel_install_kernel "${ver}" \
93 - "${EROOT}/usr/src/linux-${ver}/${image_path}" \
94 - "${EROOT}/usr/src/linux-${ver}/System.map"
95 + kernel-install_install_all "${PV}${KV_LOCALVERSION}"
96 }
97
98 _KERNEL_INSTALL_ECLASS=1
99 --
100 2.30.0