112 lines
4.1 KiB
Diff
112 lines
4.1 KiB
Diff
|
From d279b185c004fdaf7913778f052ec2ab249cd473 Mon Sep 17 00:00:00 2001
|
||
|
From: Marc-Antoine Perennou <Marc-Antoine@Perennou.com>
|
||
|
Date: Sun, 27 Jan 2019 17:32:21 +0100
|
||
|
Subject: [PATCH] kernel-install: fix dracut initrd detection (240 backward
|
||
|
compatibility) (#11570)
|
||
|
|
||
|
* kernel-install: fix initrd when called as installkernel
|
||
|
|
||
|
Running make install from the kernel runs e.g.:
|
||
|
installkernel 4.20.5 arch/x86/boot/bzImage System.map "/boot"
|
||
|
|
||
|
Since 0912c0b80eb24fb9a4e1cc4abf274a1358b9943d this would
|
||
|
cal 90-loaderentry.install with those arguments:
|
||
|
add 4.20.5 /boot/... arch/x86/boot/bzImage System.map "/boot"
|
||
|
|
||
|
The two last arguments would then be handled as the initrd files.
|
||
|
As System.map exists in current directory but not in /boot/...
|
||
|
it would get copied there, and used as initrd intead of the initrd
|
||
|
which has been generated by dracut.
|
||
|
|
||
|
With this change, nothing changes when kernel-install is called
|
||
|
directly, but when it's called as installkernel, we now pass
|
||
|
thos arguments to 90-loaderentry.install:
|
||
|
add 4.20.5 /boot/... arch/x86/boot/bzImage initrd
|
||
|
initrd is thus detected as the file to use for the initrd, and as it
|
||
|
exists, nothing is copied over and the initrd line generated is
|
||
|
consistent with what one would expect
|
||
|
|
||
|
* kernel-install: fix dracut initrd detection when called directly
|
||
|
|
||
|
This brings back the systemd 240 behaviour when called directly too
|
||
|
|
||
|
* kernel-install: unify initrd fallback
|
||
|
|
||
|
* kernel-install: move initrd fallback handling to 90-loaderentry.install
|
||
|
|
||
|
* kernel-install: move initrd fallback just before creating loader entry
|
||
|
---
|
||
|
src/kernel-install/90-loaderentry.install | 10 ++++++++--
|
||
|
src/kernel-install/kernel-install | 6 ++++--
|
||
|
2 files changed, 12 insertions(+), 4 deletions(-)
|
||
|
|
||
|
diff --git a/src/kernel-install/90-loaderentry.install b/src/kernel-install/90-loaderentry.install
|
||
|
index e5fb232f35..75dd5a1b7d 100644
|
||
|
--- a/src/kernel-install/90-loaderentry.install
|
||
|
+++ b/src/kernel-install/90-loaderentry.install
|
||
|
@@ -83,7 +83,9 @@ cp "$KERNEL_IMAGE" "$BOOT_DIR_ABS/linux" &&
|
||
|
exit 1
|
||
|
}
|
||
|
|
||
|
-for initrd in "${@:${INITRD_OPTIONS_START}}"; do
|
||
|
+INITRD_OPTIONS=( "${@:${INITRD_OPTIONS_START}}" )
|
||
|
+
|
||
|
+for initrd in "${INITRD_OPTIONS[@]}"; do
|
||
|
if [[ -f "${initrd}" ]]; then
|
||
|
initrd_basename="$(basename ${initrd})"
|
||
|
cp "${initrd}" "$BOOT_DIR_ABS/${initrd_basename}" &&
|
||
|
@@ -95,6 +97,10 @@ for initrd in "${@:${INITRD_OPTIONS_START}}"; do
|
||
|
fi
|
||
|
done
|
||
|
|
||
|
+# If no initrd option is supplied, fallback to "initrd" which is
|
||
|
+# the name used by dracut when generating it in its kernel-install hook
|
||
|
+[[ ${#INITRD_OPTIONS[@]} == 0 ]] && INITRD_OPTIONS=( initrd )
|
||
|
+
|
||
|
mkdir -p "${LOADER_ENTRY%/*}" || {
|
||
|
echo "Could not create loader entry directory '${LOADER_ENTRY%/*}'." >&2
|
||
|
exit 1
|
||
|
@@ -106,7 +112,7 @@ mkdir -p "${LOADER_ENTRY%/*}" || {
|
||
|
echo "machine-id $MACHINE_ID"
|
||
|
echo "options ${BOOT_OPTIONS[*]}"
|
||
|
echo "linux $BOOT_DIR/linux"
|
||
|
- for initrd in "${@:${INITRD_OPTIONS_START}}"; do
|
||
|
+ for initrd in "${INITRD_OPTIONS[@]}"; do
|
||
|
[[ -f $BOOT_DIR_ABS/$(basename ${initrd}) ]] && \
|
||
|
echo "initrd $BOOT_DIR/$(basename ${initrd})"
|
||
|
done
|
||
|
diff --git a/src/kernel-install/kernel-install b/src/kernel-install/kernel-install
|
||
|
index 7973818bca..b85c7c557e 100644
|
||
|
--- a/src/kernel-install/kernel-install
|
||
|
+++ b/src/kernel-install/kernel-install
|
||
|
@@ -65,14 +65,16 @@ done
|
||
|
|
||
|
if [[ "${0##*/}" == 'installkernel' ]]; then
|
||
|
COMMAND='add'
|
||
|
+ # make install doesn't pass any parameter wrt initrd handling
|
||
|
+ INITRD_OPTIONS=()
|
||
|
else
|
||
|
COMMAND="$1"
|
||
|
shift
|
||
|
+ INITRD_OPTIONS=( "${@:3}" )
|
||
|
fi
|
||
|
|
||
|
KERNEL_VERSION="$1"
|
||
|
KERNEL_IMAGE="$2"
|
||
|
-INITRD_OPTIONS_START="3"
|
||
|
|
||
|
if [[ -f /etc/machine-id ]]; then
|
||
|
read MACHINE_ID < /etc/machine-id
|
||
|
@@ -124,7 +126,7 @@ case $COMMAND in
|
||
|
|
||
|
for f in "${PLUGINS[@]}"; do
|
||
|
if [[ -x $f ]]; then
|
||
|
- "$f" add "$KERNEL_VERSION" "$BOOT_DIR_ABS" "$KERNEL_IMAGE" "${@:${INITRD_OPTIONS_START}}"
|
||
|
+ "$f" add "$KERNEL_VERSION" "$BOOT_DIR_ABS" "$KERNEL_IMAGE" "${INITRD_OPTIONS[@]}"
|
||
|
x=$?
|
||
|
if [[ $x == $SKIP_REMAINING ]]; then
|
||
|
ret=0
|
||
|
--
|
||
|
2.20.1
|
||
|
|