diff --git a/src/etc/kernel-install-mkinitcpio.conf b/src/etc/kernel-install-mkinitcpio.conf deleted file mode 100644 index b0f10b3..0000000 --- a/src/etc/kernel-install-mkinitcpio.conf +++ /dev/null @@ -1,4 +0,0 @@ -# This config file controls the automation provided by kernel-install-mkinitcpio - -# When NO_FALLBACK is set to true, no fallback initrd will be generated -#KIM_NO_FALLBACK="false" diff --git a/src/etc/kernel/install.d/40-microcode.install b/src/etc/kernel/install.d/40-microcode.install new file mode 100755 index 0000000..259d583 --- /dev/null +++ b/src/etc/kernel/install.d/40-microcode.install @@ -0,0 +1,26 @@ +#!/bin/bash +# SPDX-License-Identifier: GPL-2.0-only + +COMMAND="${1:?}" +# shellcheck disable=SC2034 +KERNEL_VERSION="${2:?}" +# shellcheck disable=SC2034 +ENTRY_DIR_ABS="$3" +# shellcheck disable=SC2034 +KERNEL_IMAGE="$4" + +set -e + +[[ "$COMMAND" = "add" ]] || exit 0 + +for dir in "${KERNEL_INSTALL_BOOT_ROOT}" "/boot"; do + for microcode in "intel-ucode.img" "amd-ucode.img"; do + if [[ -f "${dir}/${microcode}" ]]; then + install -m 0644 "${dir}/${microcode}" "${KERNEL_INSTALL_STAGING_AREA}/microcode-${microcode}" || { + echo "Error: could not copy '$microcode' to the staging area." >&2 + exit 1 + } + (( KERNEL_INSTALL_VERBOSE )) && printf "+ Found microcode image %s\n" "$microcode" || exit 0 + fi + done +done diff --git a/src/usr/lib/kernel/install.d/50-mkinitcpio-fallback.install b/src/usr/lib/kernel/install.d/50-mkinitcpio-fallback.install index 662fbbd..775945a 100755 --- a/src/usr/lib/kernel/install.d/50-mkinitcpio-fallback.install +++ b/src/usr/lib/kernel/install.d/50-mkinitcpio-fallback.install @@ -11,12 +11,6 @@ KERNEL_IMAGE="$4" [[ "$COMMAND" == "add" ]] || exit 0 -# Read the optional config file -[[ -f /etc/kernel-install-mkinitcpio.conf ]] && source /etc/kernel-install-mkinitcpio.conf - -# Do nothing if the user has elected to omit the fallback initrd -[[ ${KIM_NO_FALLBACK} == "true" ]] && exit 0 - GENERATOR_CMD=(mkinitcpio -k "$KERNEL_VERSION") BLS_ARGS=(-g "$KERNEL_INSTALL_STAGING_AREA/initrd-fallback") diff --git a/src/usr/lib/kernel/install.d/90-loaderentry-fallback.install b/src/usr/lib/kernel/install.d/90-loaderentry-fallback.install index ed64335..9839e72 100755 --- a/src/usr/lib/kernel/install.d/90-loaderentry-fallback.install +++ b/src/usr/lib/kernel/install.d/90-loaderentry-fallback.install @@ -28,10 +28,6 @@ INITRD_OPTIONS_SHIFT=4 [ "$KERNEL_INSTALL_LAYOUT" = "bls" ] || exit 0 - -# Read the optional config file -[[ -f /etc/kernel-install-mkinitcpio.conf ]] && source /etc/kernel-install-mkinitcpio.conf - MACHINE_ID="${KERNEL_INSTALL_MACHINE_ID:?}" ENTRY_TOKEN="${KERNEL_INSTALL_ENTRY_TOKEN:?}" BOOT_ROOT="${KERNEL_INSTALL_BOOT_ROOT:?}" @@ -62,9 +58,6 @@ case "$COMMAND" in ;; esac -# Do nothing if the user has elected to omit the fallback initrd -[[ ${KIM_NO_FALLBACK} == "true" ]] && exit 0 - if [ -f /etc/os-release ]; then # shellcheck source=/dev/null . /etc/os-release diff --git a/src/usr/share/libalpm/hooks/90-kernel-install.hook b/src/usr/share/libalpm/hooks/90-kernel-install.hook index a7b3de4..9f895d1 100644 --- a/src/usr/share/libalpm/hooks/90-kernel-install.hook +++ b/src/usr/share/libalpm/hooks/90-kernel-install.hook @@ -2,7 +2,7 @@ Type = Path Operation = Install Operation = Upgrade -Operation = Remove +Target = usr/lib/modules/*/vmlinuz Target = usr/lib/initcpio/* Target = usr/lib/firmware/* Target = usr/src/*/dkms.conf @@ -15,12 +15,6 @@ Operation = Remove Target = amd-ucode Target = intel-ucode -[Trigger] -Type = Path -Operation = Install -Operation = Upgrade -Target = usr/lib/modules/*/vmlinuz - [Action] Description = Installing kernel... When = PostTransaction diff --git a/src/usr/share/libalpm/scripts/kernel-install b/src/usr/share/libalpm/scripts/kernel-install index 50bcb8c..39ef3af 100755 --- a/src/usr/share/libalpm/scripts/kernel-install +++ b/src/usr/share/libalpm/scripts/kernel-install @@ -1,8 +1,4 @@ #!/usr/bin/env bash -if [ "$(stat -c %d:%i /)" != "$(stat -c %d:%i /proc/1/root/.)" ]; then - echo "Skipping hook execution in chroot." - exit 0 -fi while read -r line; do version=$(basename "${line%/vmlinuz}") @@ -10,22 +6,14 @@ while read -r line; do echo ":: kernel-install removing kernel $version" kernel-install remove "${version}" elif [[ $1 == "add" ]]; then - if [[ line =~ ".*vmlinuz$" ]]; then - echo ":: kernel-install installing kernel $version" - kernel-install add "${version}" "${line}" - else - install_all=1 - break - fi + echo ":: kernel-install installing kernel $version" + kernel-install add "${version}" "${line}" else echo ":: Invalid option passed to kernel-install script" fi + version=$(basename "${line%/vmlinuz}") done -if [[ $install_all == 1 ]]; then - reinstall-kernels -fi - # first check if we are running in a chroot if [ "$(stat -c %d:%i /)" != "$(stat -c %d:%i /proc/1/root/.)" ]; then echo 'Running in a chroot, skipping cmdline generation'