summaryrefslogtreecommitdiff
path: root/eclass
diff options
context:
space:
mode:
authorMichał Górny <mgorny@gentoo.org>2021-01-13 12:58:41 +0100
committerMichał Górny <mgorny@gentoo.org>2021-01-16 10:53:01 +0100
commit83e9e869d3af7ffd39b71df2fbafc029bc26dfad (patch)
tree7b704b8b33c84cff1d69405bb175be88428c4e57 /eclass
parentmount-boot.eclass: Support nonfatal (diff)
downloadgentoo-83e9e869d3af7ffd39b71df2fbafc029bc26dfad.tar.gz
gentoo-83e9e869d3af7ffd39b71df2fbafc029bc26dfad.tar.bz2
gentoo-83e9e869d3af7ffd39b71df2fbafc029bc26dfad.zip
kernel-install.eclass: Move common to kernel-install_install_all
Move the code shared by pkg_postinst() and pkg_config() to a new kernel-install_install_all() function. After all, the purpose of pkg_config() is to repeat what pkg_postinst() does normally. Keeping it in a common function improves maintainability. Signed-off-by: Michał Górny <mgorny@gentoo.org>
Diffstat (limited to 'eclass')
-rw-r--r--eclass/kernel-install.eclass62
1 files changed, 32 insertions, 30 deletions
diff --git a/eclass/kernel-install.eclass b/eclass/kernel-install.eclass
index 3b4af9e51c07..b1d48b6b3b5a 100644
--- a/eclass/kernel-install.eclass
+++ b/eclass/kernel-install.eclass
@@ -331,6 +331,34 @@ kernel-install_pkg_preinst() {
# (no-op)
}
+# @FUNCTION: kernel-install_install_all
+# @USAGE: <ver>
+# @DESCRIPTION:
+# Build an initramfs for the kernel and install the kernel. This is
+# called from pkg_postinst() and pkg_config(). <ver> is the full
+# kernel version.
+kernel-install_install_all() {
+ debug-print-function ${FUNCNAME} "${@}"
+
+ [[ ${#} -eq 1 ]] || die "${FUNCNAME}: invalid arguments"
+ local ver=${1}
+
+ mount-boot_pkg_preinst
+
+ local image_path=$(dist-kernel_get_image_path)
+ if use initramfs; then
+ # putting it alongside kernel image as 'initrd' makes
+ # kernel-install happier
+ dist-kernel_build_initramfs \
+ "${EROOT}/usr/src/linux-${ver}/${image_path%/*}/initrd" \
+ "${ver}"
+ fi
+
+ dist-kernel_install_kernel "${ver}" \
+ "${EROOT}/usr/src/linux-${ver}/${image_path}" \
+ "${EROOT}/usr/src/linux-${ver}/System.map"
+}
+
# @FUNCTION: kernel-install_pkg_postinst
# @DESCRIPTION:
# Build an initramfs for the kernel, install it and update
@@ -338,22 +366,10 @@ kernel-install_pkg_preinst() {
kernel-install_pkg_postinst() {
debug-print-function ${FUNCNAME} "${@}"
- if [[ -z ${ROOT} ]]; then
- mount-boot_pkg_preinst
-
- local ver="${PV}${KV_LOCALVERSION}"
- local image_path=$(dist-kernel_get_image_path)
- if use initramfs; then
- # putting it alongside kernel image as 'initrd' makes
- # kernel-install happier
- dist-kernel_build_initramfs \
- "${EROOT}/usr/src/linux-${ver}/${image_path%/*}/initrd" \
- "${ver}"
- fi
+ local ver="${PV}${KV_LOCALVERSION}"
- dist-kernel_install_kernel "${ver}" \
- "${EROOT}/usr/src/linux-${ver}/${image_path}" \
- "${EROOT}/usr/src/linux-${ver}/System.map"
+ if [[ -z ${ROOT} ]]; then
+ kernel-install_install_all "${ver}"
fi
kernel-install_update_symlink "${EROOT}/usr/src/linux" "${ver}"
@@ -391,21 +407,7 @@ kernel-install_pkg_postrm() {
kernel-install_pkg_config() {
[[ -z ${ROOT} ]] || die "ROOT!=/ not supported currently"
- mount-boot_pkg_preinst
-
- local ver="${PV}${KV_LOCALVERSION}"
- local image_path=$(dist-kernel_get_image_path)
- if use initramfs; then
- # putting it alongside kernel image as 'initrd' makes
- # kernel-install happier
- dist-kernel_build_initramfs \
- "${EROOT}/usr/src/linux-${ver}/${image_path%/*}/initrd" \
- "${ver}"
- fi
-
- dist-kernel_install_kernel "${ver}" \
- "${EROOT}/usr/src/linux-${ver}/${image_path}" \
- "${EROOT}/usr/src/linux-${ver}/System.map"
+ kernel-install_install_all "${PV}${KV_LOCALVERSION}"
}
_KERNEL_INSTALL_ECLASS=1