mirror of
https://github.com/systemd/systemd.git
synced 2025-03-13 00:58:27 +03:00
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
This commit is contained in:
parent
ccfe70a6ee
commit
d279b185c0
@ -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
|
||||
|
@ -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
|
||||
|
Loading…
x
Reference in New Issue
Block a user