1 |
Signed-off-by: Michał Górny <mgorny@g.o> |
2 |
--- |
3 |
eclass/dist-kernel-utils.eclass | 36 +++++++++++++++++++++++++++++++++ |
4 |
1 file changed, 36 insertions(+) |
5 |
|
6 |
diff --git a/eclass/dist-kernel-utils.eclass b/eclass/dist-kernel-utils.eclass |
7 |
index cf7165d89947..d92642a25a0a 100644 |
8 |
--- a/eclass/dist-kernel-utils.eclass |
9 |
+++ b/eclass/dist-kernel-utils.eclass |
10 |
@@ -92,5 +92,41 @@ dist-kernel_install_kernel() { |
11 |
eend ${?} || die "Installing the kernel failed" |
12 |
} |
13 |
|
14 |
+# @FUNCTION: dist-kernel_reinstall_initramfs |
15 |
+# @USAGE: <kv-dir> <kv-full> |
16 |
+# @DESCRIPTION: |
17 |
+# Rebuild and install initramfs for the specified dist-kernel. |
18 |
+# <kv-dir> is the kernel source directory (${KV_DIR} from linux-info), |
19 |
+# while <kv-full> is the full kernel version (${KV_FULL}). |
20 |
+# The function will determine whether <kernel-dir> is actually |
21 |
+# a dist-kernel, and whether initramfs was used. |
22 |
+# |
23 |
+# This function is to be used in pkg_postinst() of ebuilds installing |
24 |
+# kernel modules that are included in the initramfs. |
25 |
+dist-kernel_reinstall_initramfs() { |
26 |
+ debug-print-function ${FUNCNAME} "${@}" |
27 |
+ |
28 |
+ [[ ${#} -eq 2 ]] || die "${FUNCNAME}: invalid arguments" |
29 |
+ local kernel_dir=${1} |
30 |
+ local ver=${2} |
31 |
+ |
32 |
+ local image_path=${kernel_dir}/$(dist-kernel_get_image_path) |
33 |
+ local initramfs_path=${image_path%/*}/initrd |
34 |
+ if [[ ! -f ${image_path} ]]; then |
35 |
+ eerror "Kernel install missing, image not found:" |
36 |
+ eerror " ${image_path}" |
37 |
+ eerror "Initramfs will not be updated. Please reinstall your kernel." |
38 |
+ return |
39 |
+ fi |
40 |
+ if [[ ! -f ${initramfs_path} ]]; then |
41 |
+ einfo "No initramfs found at ${initramfs_path}" |
42 |
+ return |
43 |
+ fi |
44 |
+ |
45 |
+ dist-kernel_build_initramfs "${initramfs_path}" "${ver}" |
46 |
+ dist-kernel_install_kernel "${ver}" "${image_path}" \ |
47 |
+ "${kernel_dir}/System.map" |
48 |
+} |
49 |
+ |
50 |
_DIST_KERNEL_UTILS=1 |
51 |
fi |
52 |
-- |
53 |
2.30.0 |