Mkinitcpio 39 is buggy

No I think as it was not installed was the problem.
I guess its happend due to the changes on the patch at mkinitcpio.
Otherwise something goes wrong as I stored the vm to another storage.

Can you try to reproduce it in a VM from stable or testing branch to update that system to unstable to see if you can trigger it? maybe also do snapshots before the update of mkinitcpio. Including the preset files.

I have setup where I have modified /etc/mkinitcpio.d/linux69.preset

On May 9. I removed linux69 which created a linux69.preset.pacsave.

I remember being puzzled by the lack of kernel version in the files - thinking ‘hmm - I messed something’ - now I understand that I didn’t.

The content of the linux69.preset.pacsave at May 9. 08.29 CEST

nix@black mkinitcpio.d]$ cat linux69.preset.pacsave 
# mkinitcpio preset file for the '%PKGBASE%' package

#ALL_config="/etc/mkinitcpio.conf"
ALL_kver="/boot/vmlinuz-"

PRESETS=('default' 'fallback')

#default_config="/etc/mkinitcpio.conf"
default_image="/boot/initramfs-.img"
#default_uki="/efi/EFI/Linux/manjaro-.efi"
#default_options="--splash /usr/share/systemd/bootctl/splash-manjaro.bmp"

#fallback_config="/etc/mkinitcpio.conf"
fallback_image="/boot/initramfs--fallback.img"
#fallback_uki="/efi/EFI/Linux/manjaro--fallback.efi"
fallback_options="-S autodetect"

How is any script supposed to use this file as a template when there is no variables to replace?

1 Like

I had no .pacsave the presets got modified on the fly during the update to 38.x to 39.x

38.x is fine.

I am currently on travel so I have to check a new vm later.

I originated the other thread mentioning this issue, and I’ve never had kernel-alive installed. However, I’ve looked through my pacman.log, and the first time this issue occurred for me was just after mkinitcpio got upgraded from 38.1-1 to 39-1.

I think due to the script change our kernelbase variable never gets populated when the template gets created. Will check that later and try to fix that for 39

1 Like

I found the issue. The logic on how the preset files get generated changed with 39:

--- script-38.1	2024-03-12 23:51:43.000000000 +0700
+++ script-39	2024-05-03 20:24:32.000000000 +0700
@@ -6,7 +6,34 @@ set -e
 args=()
 package=0
 
-process_preset() {
+install_preset() {
+    local pkgbase="$1" preset="$2"
+
+    if [[ ! -e "$preset" ]]; then
+        if [[ -e "$preset.pacsave" ]]; then
+            # move the pacsave to the template
+            mv -- "${preset}.pacsave" "$preset"
+        else
+            # create the preset from the template
+            sed "s|%PKGBASE%|${pkgbase}|g" /usr/share/mkinitcpio/hook.preset \
+                | install -Dm644 /dev/stdin "$preset"
+        fi
+    fi
+}
+
+generate_presets() {
+    local preset pkgbase pkgbase_path
+
+    # only make presets for kernels with a pkgbase
+    for pkgbase_path in /usr/lib/modules/*/pkgbase; do
+        if read -r pkgbase &>/dev/null <"$pkgbase_path"; then
+            preset="/etc/mkinitcpio.d/${pkgbase}.preset"
+            install_preset "$pkgbase" "$preset"
+        fi
+    done
+}
+
+remove_preset() {
     if [[ -n "$pkgbase" && -e "$preset" ]]; then
         if ! cmp "$preset" <(sed "s|%PKGBASE%|${pkgbase}|g" /usr/share/mkinitcpio/hook.preset) &>/dev/null; then
             if [[ ! -e "$preset.pacsave" ]]; then
@@ -98,17 +125,7 @@ install_kernel() {
     local pkgbase="$1"
     local kernel preset="/etc/mkinitcpio.d/${pkgbase}.preset"
 
-    if [[ ! -e "$preset" ]]; then
-        if [[ -e "$preset.pacsave" ]]; then
-            # move the pacsave to the template
-            mv -- "${preset}.pacsave" "$preset"
-        else
-            # create the preset from the template
-            sed "s|%PKGBASE%|${pkgbase}|g" /usr/share/mkinitcpio/hook.preset \
-                | install -Dm644 /dev/stdin "$preset"
-        fi
-    fi
-
+    install_preset "$pkgbase" "$preset"
     (
         # source the preset to get the kernel and image locations
         # shellcheck disable=SC1090
@@ -145,10 +162,17 @@ remove_kernel() {
         rm -f -- "${filelist[@]}"
     ) || return
     # remove the preset
-    process_preset "$pkgbase" "$preset"
+    remove_preset "$pkgbase" "$preset"
 }
 
 while read -r line; do
+    if [[ "${line%%-git}" == "mkinitcpio" && "$1" == "install" ]]; then
+        # generate presets for each kernel on package install
+        generate_presets
+        package=1
+        continue
+    fi
+
     if [[ "$line" != */vmlinuz ]]; then
         # triggers when it's a change to usr/lib/initcpio/*
         package=1
@@ -177,7 +201,7 @@ if (( package )) && compgen -G /etc/mkin
             for preset in /etc/mkinitcpio.d/*.preset; do
                 pkgbase=${preset##*/}
                 pkgbase=${pkgbase%.preset}
-                process_preset "$pkgbase" "$preset"
+                remove_preset "$pkgbase" "$preset"
             done
             shopt -u nullglob
             ;;

This got added:

@@ -145,10 +162,17 @@ remove_kernel() {
         rm -f -- "${filelist[@]}"
     ) || return
     # remove the preset
-    process_preset "$pkgbase" "$preset"
+    remove_preset "$pkgbase" "$preset"
 }
 
 while read -r line; do
+    if [[ "${line%%-git}" == "mkinitcpio" && "$1" == "install" ]]; then
+        # generate presets for each kernel on package install
+        generate_presets
+        package=1
+        continue
+    fi
+
     if [[ "$line" != */vmlinuz ]]; then
         # triggers when it's a change to usr/lib/initcpio/*
         package=1

Which is before we define KERNELBASE value. Hence the value is empty.

3 Likes

@scarwire and @pheiduck please check if it is fixed now: [pkg-upd] 39-6 (b78889ad) · Commits · Packages / Core / mkinitcpio · GitLab

Just built the package and installed it, and got the same result with missing version numbers:

(4/6) Updating linux initcpios...
==> Building image from preset: /etc/mkinitcpio.d/linux66.preset: 'default'
==> Using default configuration file: '/etc/mkinitcpio.conf'
  -> -k /boot/vmlinuz- -g /boot/initramfs-.img
==> Starting build: '6.6.30-2-MANJARO'
  -> Running build hook: [base]
  -> Running build hook: [udev]
  -> Running build hook: [autodetect]
  -> Running build hook: [kms]
  -> Running build hook: [modconf]
  -> Running build hook: [block]
==> WARNING: Possibly missing firmware for module: 'xhci_pci'
  -> Running build hook: [keyboard]
  -> Running build hook: [keymap]
  -> Running build hook: [consolefont]
  -> Running build hook: [plymouth]
  -> Running build hook: [encrypt]
  -> Running build hook: [openswap]
  -> Running build hook: [resume]
  -> Running build hook: [filesystems]
==> Generating module dependencies
==> Creating zstd-compressed initcpio image: '/boot/initramfs-.img'
  -> Early uncompressed CPIO image generation successful
==> Initcpio image generation successful
==> Building image from preset: /etc/mkinitcpio.d/linux66.preset: 'fallback'
==> Using default configuration file: '/etc/mkinitcpio.conf'
  -> -k /boot/vmlinuz- -g /boot/initramfs--fallback.img -S autodetect
==> Starting build: '6.6.30-2-MANJARO'
  -> Running build hook: [base]
  -> Running build hook: [udev]
  -> Running build hook: [kms]
==> WARNING: Possibly missing firmware for module: 'ast'
  -> Running build hook: [modconf]
  -> Running build hook: [block]
==> WARNING: Possibly missing firmware for module: 'aic94xx'
==> WARNING: Possibly missing firmware for module: 'bfa'
==> WARNING: Possibly missing firmware for module: 'qed'
==> WARNING: Possibly missing firmware for module: 'qla1280'
==> WARNING: Possibly missing firmware for module: 'qla2xxx'
==> WARNING: Possibly missing firmware for module: 'wd719x'
==> WARNING: Possibly missing firmware for module: 'xhci_pci'
  -> Running build hook: [keyboard]
  -> Running build hook: [keymap]
  -> Running build hook: [consolefont]
  -> Running build hook: [plymouth]
  -> Running build hook: [encrypt]
  -> Running build hook: [openswap]
  -> Running build hook: [resume]
  -> Running build hook: [filesystems]
==> Generating module dependencies
==> Creating zstd-compressed initcpio image: '/boot/initramfs--fallback.img'
  -> Early uncompressed CPIO image generation successful
==> Initcpio image generation successful
==> Building image from preset: /etc/mkinitcpio.d/linux68.preset: 'default'
==> Using default configuration file: '/etc/mkinitcpio.conf'
  -> -k /boot/vmlinuz- -g /boot/initramfs-.img
==> Starting build: '6.6.30-2-MANJARO'
  -> Running build hook: [base]
  -> Running build hook: [udev]
  -> Running build hook: [autodetect]
  -> Running build hook: [kms]
  -> Running build hook: [modconf]
  -> Running build hook: [block]
==> WARNING: Possibly missing firmware for module: 'xhci_pci'
  -> Running build hook: [keyboard]
  -> Running build hook: [keymap]
  -> Running build hook: [consolefont]
  -> Running build hook: [plymouth]
  -> Running build hook: [encrypt]
  -> Running build hook: [openswap]
  -> Running build hook: [resume]
  -> Running build hook: [filesystems]
==> Generating module dependencies
==> Creating zstd-compressed initcpio image: '/boot/initramfs-.img'
  -> Early uncompressed CPIO image generation successful
==> Initcpio image generation successful
==> Building image from preset: /etc/mkinitcpio.d/linux68.preset: 'fallback'
==> Using default configuration file: '/etc/mkinitcpio.conf'
  -> -k /boot/vmlinuz- -g /boot/initramfs-.img -S autodetect
==> Starting build: '6.6.30-2-MANJARO'
  -> Running build hook: [base]
  -> Running build hook: [udev]
  -> Running build hook: [kms]
==> WARNING: Possibly missing firmware for module: 'ast'
  -> Running build hook: [modconf]
  -> Running build hook: [block]
==> WARNING: Possibly missing firmware for module: 'aic94xx'
==> WARNING: Possibly missing firmware for module: 'bfa'
==> WARNING: Possibly missing firmware for module: 'qed'
==> WARNING: Possibly missing firmware for module: 'qla1280'
==> WARNING: Possibly missing firmware for module: 'qla2xxx'
==> WARNING: Possibly missing firmware for module: 'wd719x'
==> WARNING: Possibly missing firmware for module: 'xhci_pci'
  -> Running build hook: [keyboard]
  -> Running build hook: [keymap]
  -> Running build hook: [consolefont]
  -> Running build hook: [plymouth]
  -> Running build hook: [encrypt]
  -> Running build hook: [openswap]
  -> Running build hook: [resume]
  -> Running build hook: [filesystems]
==> Generating module dependencies
==> Creating zstd-compressed initcpio image: '/boot/initramfs-.img'
  -> Early uncompressed CPIO image generation successful
==> Initcpio image generation successful
> ls /boot/
efi/   initramfs--fallback.img  intel-ucode.img      linux68-x86_64.kver  vmlinuz-
grub/  initramfs-.img           linux66-x86_64.kver  memtest86+/

Or am I still missing something?

Also, this may not be helpful, but I just noticed that even when I explicitly run sudo mkinitcpio -p linux68, it’s still building the image for linux 6.6:

==> Starting build: '6.6.30-2-MANJARO'

i get a complete different error now:

==> Building image from preset: /etc/mkinitcpio.d/linux66.preset: 'default'
==> Using default configuration file: '/etc/mkinitcpio.conf'
  -> -k /boot/vmlinuz-6.6-x86_64 -g /boot/initramfs-6.6-x86_64.img
==> ERROR: '/lib/modules/6.6.30-2-MANJARO' is not a valid kernel module directory
==> Building image from preset: /etc/mkinitcpio.d/linux66.preset: 'fallback'
==> Using default configuration file: '/etc/mkinitcpio.conf'
  -> -k /boot/vmlinuz-6.6-x86_64 -g /boot/initramfs-6.6-x86_64-fallback.img -S autodetect
==> ERROR: '/lib/modules/6.6.30-2-MANJARO' is not a valid kernel module directory
==> Building image from preset: /etc/mkinitcpio.d/linux68.preset: 'default'
==> Using default configuration file: '/etc/mkinitcpio.conf'
  -> -k /boot/vmlinuz-6.8-x86_64 -g /boot/initramfs-6.8-x86_64.img
==> Starting build: '6.8.9-3-MANJARO'
  -> Running build hook: [plymouth]
  -> Running build hook: [base]
  -> Running build hook: [udev]
  -> Running build hook: [autodetect]
  -> Running build hook: [microcode]
  -> Running build hook: [modconf]
  -> Running build hook: [kms]
  -> Running build hook: [keyboard]
  -> Running build hook: [keymap]
  -> Running build hook: [consolefont]
  -> Running build hook: [block]
  -> Running build hook: [filesystems]
  -> Running build hook: [fsck]
==> Generating module dependencies
==> Creating zstd-compressed initcpio image: '/boot/initramfs-6.8-x86_64.img'
  -> Early uncompressed CPIO image generation successful
==> Initcpio image generation successful
==> Building image from preset: /etc/mkinitcpio.d/linux68.preset: 'fallback'
==> Using default configuration file: '/etc/mkinitcpio.conf'
  -> -k /boot/vmlinuz-6.8-x86_64 -g /boot/initramfs-6.8-x86_64-fallback.img -S autodetect
==> Starting build: '6.8.9-3-MANJARO'
  -> Running build hook: [plymouth]
  -> Running build hook: [base]
  -> Running build hook: [udev]
  -> Running build hook: [microcode]
  -> Running build hook: [modconf]
  -> Running build hook: [kms]
  -> Running build hook: [keyboard]
  -> Running build hook: [keymap]
  -> Running build hook: [consolefont]
  -> Running build hook: [block]
  -> Running build hook: [filesystems]
  -> Running build hook: [fsck]
==> Generating module dependencies
==> Creating zstd-compressed initcpio image: '/boot/initramfs-6.8-x86_64-fallback.img'
  -> Early uncompressed CPIO image generation successful
==> Initcpio image generation successful
Fehler: Befehl konnte nicht korrekt ausgeführt werden

Solved by reinstall of linux66

Is solving the issue on my side good job @philm :+1:

$ ls | sort
amd-ucode.img
grub
initramfs-6.6-x86_64-fallback.img
initramfs-6.6-x86_64.img
initramfs-6.8-x86_64-fallback.img
initramfs-6.8-x86_64.img
intel-ucode.img
linux66-x86_64.kver
linux68-x86_64.kver
memtest86+
vmlinuz-6.6-x86_64
vmlinuz-6.8-x86_64

Reinstalling linux68 and linux66 hasn’t done anything for me, even after deleting linux66.preset and linux68.preset in /etc/mkinitcpio.d/.

Ensure you have mkinitcpio 39-6

Yes, I cloned the git commit sent by @philm and ran makepkg -si. Even after a reboot, mkinitcpio -P produces images without any version numbers.

@scarwire can you try the package from a repo and try that so we test the same build? I will try to install another kernel on my end and try more stuff. If you still have issues we can add some debug lines to the script.

Just installed 39-6 from the repo, deleted the preset files, and reinstalled linux66. Still no version number on the image that was generated. Also the newly generated preset file is clearly picking up an empty kernelbase variable:

# mkinitcpio preset file for the '' package

#ALL_config="/etc/mkinitcpio.conf"
ALL_kver="/boot/vmlinuz-"

PRESETS=('default' 'fallback')

#default_config="/etc/mkinitcpio.conf"
default_image="/boot/initramfs-.img"
#default_uki="/efi/EFI/Linux/manjaro-.efi"
#default_options="--splash /usr/share/systemd/bootctl/splash-manjaro.bmp"

#fallback_config="/etc/mkinitcpio.conf"
fallback_image="/boot/initramfs--fallback.img"
#fallback_uki="/efi/EFI/Linux/manjaro--fallback.efi"
fallback_options="-S autodetect"

If there’s any way you can help me get more verbose output that would be great!

Thanks again

How do you reinstalled the kernel? With pacman -Syu or mhwd-kernel?

But last will only work when you boot into a different kernel.

I’ve tried both! No luck with either one.

Not sure if this is relevant but my vm is in bios mode. Maybe EFI behavior is different.

Yes but it’s not obsolete. If it will become this state I will switch to kernel-modules-hook