summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichał Górny <mgorny@gentoo.org>2021-01-10 13:50:24 +0100
committerMichał Górny <mgorny@gentoo.org>2021-01-13 12:54:25 +0100
commitb62ff375dac23963ebe5da2e0dbf847052374de2 (patch)
tree7e3b58df1b9508433a230d24bd5811806dadac0f /eclass/dist-kernel-utils.eclass
parentdist-kernel-utils.eclass: Introduce eclass for helper functions (diff)
downloadgentoo-b62ff375dac23963ebe5da2e0dbf847052374de2.tar.gz
gentoo-b62ff375dac23963ebe5da2e0dbf847052374de2.tar.bz2
gentoo-b62ff375dac23963ebe5da2e0dbf847052374de2.zip
dist-kernel-utils.eclass: Add a function to rebuild initramfs
Signed-off-by: Michał Górny <mgorny@gentoo.org>
Diffstat (limited to 'eclass/dist-kernel-utils.eclass')
-rw-r--r--eclass/dist-kernel-utils.eclass36
1 files changed, 36 insertions, 0 deletions
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