]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
kernel-install: ignore extra args passed when invoked as installkernel
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Tue, 24 May 2022 20:19:05 +0000 (22:19 +0200)
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Tue, 24 May 2022 21:31:43 +0000 (23:31 +0200)
kernel's 'make install' invokes install.sh which calls /sbin/install-kernel.
Thus we are invoked as e.g.
  /sbin/installkernel 5.18.0 arch/x86/boot/bzImage System.map /boot
The last two arguments would be passed as "initrds".

Before , we would just quitely ignore
/boot, because it doesn't pass the 'test -f' test, and possibly try to do
something with System.map. 742561efbe938c45936f2e4f5d81b3ff6b352882 tightened
the check, so we now throw an error.

It seems that the correct thing is to ignore those two arguments, because
our plugin syntax has no notion of System.map. And the installation directory
we can figure out ourselves better. Effectively, this makes things behave
like before, but less by accident.

Fixes #23490.

src/kernel-install/kernel-install.in

index c6c74cc79252313bb7151db3ddb8822d2f795e66..5f88ac2490ee1a880716f1dc58451198a6d658ed 100755 (executable)
@@ -81,9 +81,11 @@ fi
 if [ "${0##*/}" = "installkernel" ]; then
     COMMAND=add
     # make install doesn't pass any initrds
+    no_initrds=1
 else
     COMMAND="$1"
     [ $# -ge 1 ] && shift
+    no_initrds=0
 fi
 
 if [ "$COMMAND" = "inspect" ]; then
@@ -321,8 +323,17 @@ case "$COMMAND" in
         fi
 
         for f in $PLUGINS; do
-            [ "$KERNEL_INSTALL_VERBOSE" -gt 0 ] && echo "+$f add $KERNEL_VERSION $ENTRY_DIR_ABS $*"
-            "$f" add "$KERNEL_VERSION" "$ENTRY_DIR_ABS" "$@"
+            if [ "$no_initrds" = 1 ]; then
+                # kernel's install.sh invokes us as
+                #   /sbin/installkernel <version> <vmlinuz> <map> <installation-dir>
+                # We ignore the last two arguments.
+                [ "$KERNEL_INSTALL_VERBOSE" -gt 0 ] && echo "+$f add $KERNEL_VERSION $ENTRY_DIR_ABS $1"
+                "$f" add "$KERNEL_VERSION" "$ENTRY_DIR_ABS" "$1"
+            else
+                [ "$KERNEL_INSTALL_VERBOSE" -gt 0 ] && echo "+$f add $KERNEL_VERSION $ENTRY_DIR_ABS $*"
+                "$f" add "$KERNEL_VERSION" "$ENTRY_DIR_ABS" "$@"
+            fi
+
             err=$?
             [ $err -eq $skip_remaining ] && break
             ret=$(( ret + err ))