backport a patch for kernel-install

This commit is contained in:
Yu Watanabe 2019-01-27 17:55:18 +01:00
parent 0eab21cb2b
commit ee8fc244d8
2 changed files with 116 additions and 1 deletions

View File

@ -0,0 +1,111 @@
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

View File

@ -15,7 +15,7 @@
Name: systemd
Url: https://www.freedesktop.org/wiki/Software/systemd
Version: 241~rc1
Release: 1%{?commit:.git%{shortcommit}}%{?dist}
Release: 2%{?commit:.git%{shortcommit}}%{?dist}
# For a breakdown of the licensing, see README
License: LGPLv2+ and MIT and GPLv2+
Summary: System and Service Manager
@ -52,6 +52,7 @@ i=1; for j in 00*patch; do printf "Patch%04d: %s\n" $i $j; i=$((i+1));done|
GIT_DIR=../../src/systemd/.git git diffab -M v233..master@{2017-06-15} -- hwdb/[67]* hwdb/parse_hwdb.py > hwdb.patch
%endif
Patch0001: 0001-kernel-install-fix-dracut-initrd-detection-240-backw.patch
Patch0002: 0002-Revert-units-set-NoNewPrivileges-for-all-long-runnin.patch
Patch0998: 0998-resolved-create-etc-resolv.conf-symlink-at-runtime.patch
@ -694,6 +695,9 @@ fi
%files tests -f .file-list-tests
%changelog
* Sun Jan 27 2019 Yu Watanabe <watanabe.yu@gmail.com> - 241~rc1-2
- Backport a patch for kernel-install
* Sat Jan 26 2019 Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl> - 241~rc1-1
- Update to latest release -rc1