Please read this before reporting a bug:
https://wiki.archlinux.org/title/Bug_reporting_guidelines
Do NOT report bugs when a package is just outdated, or it is in the AUR. Use the 'flag out of date' link on the package page, or the Mailing List.
REPEAT: Do NOT report bugs for outdated packages!
https://wiki.archlinux.org/title/Bug_reporting_guidelines
Do NOT report bugs when a package is just outdated, or it is in the AUR. Use the 'flag out of date' link on the package page, or the Mailing List.
REPEAT: Do NOT report bugs for outdated packages!
FS#77050 - [mkinitcpio] kernel-install unified kernel image escaping issue
Attached to Project:
Arch Linux
Opened by Florian (nougad) - Sunday, 08 January 2023, 19:01 GMT
Last edited by Toolybird (Toolybird) - Sunday, 08 January 2023, 22:01 GMT
Opened by Florian (nougad) - Sunday, 08 January 2023, 19:01 GMT
Last edited by Toolybird (Toolybird) - Sunday, 08 January 2023, 22:01 GMT
|
DetailsDescription:
/usr/lib/kernel/install.d/50-mkinitcpio.install contains an encoding issue when building unified kernel image: Current behavior: ``` $ kernel-install add 6.1.3-arch1-1 /usr/lib/modules/6.1.3-arch1-1/vmlinuz ==> Generating module dependencies ==> Creating zstd-compressed initcpio image: /tmp/mkinitcpio.fatqlo ==> Image generation successful ==> Creating unified kernel image: /boot/EFI/Linux/aee901b403f349d492561b8addecc2a8-6.1.3-arch1-1.efi -> Using UEFI stub: /usr/lib/systemd/boot/efi/linuxx64.efi.stub ==> ERROR: Kernel image '' not found /boot/EFI/Linux/aee901b403f349d492561b8addecc2a8-6.1.3-arch1-1.efi does not exist (6/7) Refreshing PackageKit... ``` This is because of the line: ``` mkinitcpio -k "$KERNEL_VERSION" $KERNEL_IMAGE_FLAGS $MICROCODE $IMAGE_GENERATION_FLAG "$IMAGE_PATH" ``` adding a `set -x` before it expands to ``` mkinitcpio -k 6.1.3-arch1-1 --kernelimage ''\''/usr/lib/modules/6.1.3-arch1-1/vmlinuz'\''' --microcode ''\''/boot/intel-ucode.img'\''' -U /boot/EFI/Linux/aee901b403f349d492561b8addecc2a8-6.1.3-arch1-1.efi ``` Because `MICROCODE` and `KERNEL_IMAGE_FLAGS` contain `'` which is taken literally: ``` $ shellcheck /usr/lib/kernel/install.d/50-mkinitcpio.install In /usr/lib/kernel/install.d/50-mkinitcpio.install line 32: MICROCODE="--microcode '$KERNEL_INSTALL_BOOT_ROOT/$ucode_name'" ^-----------^ SC2089 (warning): Quotes/backslashes will be treated literally. Rewrite using set/"$@" or functions. In /usr/lib/kernel/install.d/50-mkinitcpio.install line 37: KERNEL_IMAGE_FLAGS="--kernelimage '$KERNEL_IMAGE'" ^-------------^ SC2089 (warning): Quotes/backslashes will be treated literally. Rewrite using set/"$@" or functions. In /usr/lib/kernel/install.d/50-mkinitcpio.install line 54: mkinitcpio -k "$KERNEL_VERSION" $KERNEL_IMAGE_FLAGS $MICROCODE $IMAGE_GENERATION_FLAG "$IMAGE_PATH" ^-----------------^ SC2090 (warning): Quotes/backslashes in this variable will not be respected. ^-----------------^ SC2086 (info): Double quote to prevent globbing and word splitting. ^--------^ SC2090 (warning): Quotes/backslashes in this variable will not be respected. ``` Additional info: * package version(s) ``` $ kernel-install --version kernel-install 252 (252.4-2-arch) $ mkinitcpio --version mkinitcpio 34 ``` * config and/or log files etc. ``` $ cat /etc/kernel/install.conf layout=uki ``` * link to upstream bug report, if any Steps to reproduce: * Follow configuration in https://wiki.archlinux.org/title/Unified_kernel_image#kernel-install * Build kernel using `kernel-install` Proposed patch: ``` :! diff -u /usr/lib/kernel/install.d/50-mkinitcpio.install /tmp/50-mkinitcpio.install --- /usr/lib/kernel/install.d/50-mkinitcpio.install 2022-12-08 10:14:41.000000000 +0100 +++ /tmp/50-mkinitcpio.install 2023-01-08 20:00:38.969012186 +0100 @@ -1,4 +1,4 @@ -#!/bin/sh +#!/bin/bash # SPDX-License-Identifier: GPL-2.0-only COMMAND="${1:?}" @@ -25,16 +25,16 @@ for ucode_name in "intel-ucode.img" "amd-ucode.img" "intel-uc.img" "amd-uc.img" "early_ucode.cpio" "microcode.cpio"; do if [ -e "/boot/$ucode_name" ]; then [ "$KERNEL_INSTALL_VERBOSE" -gt 0 ] && echo "Found microcode image /boot/$ucode_name" - MICROCODE="--microcode '/boot/$ucode_name'" + MICROCODE=(--microcode "/boot/$ucode_name") break elif [ -e "$KERNEL_INSTALL_BOOT_ROOT/$ucode_name" ]; then [ "$KERNEL_INSTALL_VERBOSE" -gt 0 ] && echo "Found microcode image /boot/$ucode_name" - MICROCODE="--microcode '$KERNEL_INSTALL_BOOT_ROOT/$ucode_name'" + MICROCODE=(--microcode "$KERNEL_INSTALL_BOOT_ROOT/$ucode_name") break fi done - KERNEL_IMAGE_FLAGS="--kernelimage '$KERNEL_IMAGE'" + KERNEL_IMAGE_FLAGS=(--kernelimage "$KERNEL_IMAGE") ;; bls) IMAGE_GENERATION_FLAG="-g" @@ -47,9 +47,10 @@ case $COMMAND in add) - [ "$KERNEL_INSTALL_VERBOSE" -gt 0 ] && echo "+ mkinitcpio -k $KERNEL_VERSION $KERNEL_IMAGE_FLAGS $MICROCODE $IMAGE_GENERATION_FLAG $IMAGE_PATH" + [ "$KERNEL_INSTALL_VERBOSE" -gt 0 ] && echo "+ mkinitcpio -k $KERNEL_VERSION ${KERNEL_IMAGE_FLAGS[*]} ${MICROCODE[*]} $IMAGE_GENERATION_FLAG $IMAGE_PATH" #shellcheck disable=SC2046 - mkinitcpio -k "$KERNEL_VERSION" $KERNEL_IMAGE_FLAGS $MICROCODE $IMAGE_GENERATION_FLAG "$IMAGE_PATH" + set -x + mkinitcpio -k "$KERNEL_VERSION" "${KERNEL_IMAGE_FLAGS[@]}" "${MICROCODE[@]}" $IMAGE_GENERATION_FLAG "$IMAGE_PATH" ;; remove) ``` |
This task depends upon
Closed by Toolybird (Toolybird)
Sunday, 08 January 2023, 22:01 GMT
Reason for closing: Upstream
Additional comments about closing: Should be fixed in next release.
Sunday, 08 January 2023, 22:01 GMT
Reason for closing: Upstream
Additional comments about closing: Should be fixed in next release.
[1] https://gitlab.archlinux.org/archlinux/mkinitcpio/mkinitcpio