Skip to content

Commit

Permalink
build: Add patch to fix kernel installations to allow use of auto-gen…
Browse files Browse the repository at this point in the history
…erated install scripts
  • Loading branch information
pojntfx committed Apr 10, 2024
1 parent cb78e06 commit 388584c
Show file tree
Hide file tree
Showing 3 changed files with 54 additions and 5 deletions.
2 changes: 1 addition & 1 deletion base/3-patch.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ set -ex

cd ./base/linux

git apply ../add-typedefs.patch
git apply ../*.patch
52 changes: 52 additions & 0 deletions base/fix-installkernel.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
From ce51995ff400267d1b6fab18ba45c35b630347a6 Mon Sep 17 00:00:00 2001
From: Jose Ignacio Tornos Martinez <[email protected]>
Date: Tue, 12 Dec 2023 18:10:44 +0100
Subject: [PATCH] rpm-pkg: simplify installkernel %post

A new installkernel application is now included in systemd-udev package
and it has been improved to allow simplifications.

For the new installkernel application, as Davide says:
<<The %post currently does a shuffling dance before calling installkernel.
This isn't actually necessary afaict, and the current implementation
ends up triggering downstream issues such as
https://github.com/systemd/systemd/issues/29568
This commit simplifies the logic to remove the shuffling. For reference,
the original logic was added in commit 3c9c7a14b627("rpm-pkg: add %post
section to create initramfs and grub hooks").>>

But we need to keep the old behavior as well, because the old installkernel
application from grubby package, does not allow this simplification and
we need to be backward compatible to avoid issues with the different
packages. So the easiest solution is to check the package that provides
the installkernel application, and simplify (and fix for this
application at the same time), only if the package is systemd-udev.

cc: [email protected]
Co-Developed-by: Davide Cavalca <[email protected]>
Signed-off-by: Jose Ignacio Tornos Martinez <[email protected]>
---
scripts/package/kernel.spec | 4 ++++
1 file changed, 4 insertions(+)

diff --git a/scripts/package/kernel.spec b/scripts/package/kernel.spec
index 3eee0143e0c5cc..d4276ddb66450c 100644
--- a/scripts/package/kernel.spec
+++ b/scripts/package/kernel.spec
@@ -77,12 +77,16 @@ rm -rf %{buildroot}

%post
if [ -x /sbin/installkernel -a -r /boot/vmlinuz-%{KERNELRELEASE} -a -r /boot/System.map-%{KERNELRELEASE} ]; then
+if [ $(rpm -qf /sbin/installkernel --queryformat "%{n}") = systemd-udev ];then
+/sbin/installkernel %{KERNELRELEASE} /boot/vmlinuz-%{KERNELRELEASE} /boot/System.map-%{KERNELRELEASE}
+else
cp /boot/vmlinuz-%{KERNELRELEASE} /boot/.vmlinuz-%{KERNELRELEASE}-rpm
cp /boot/System.map-%{KERNELRELEASE} /boot/.System.map-%{KERNELRELEASE}-rpm
rm -f /boot/vmlinuz-%{KERNELRELEASE} /boot/System.map-%{KERNELRELEASE}
/sbin/installkernel %{KERNELRELEASE} /boot/.vmlinuz-%{KERNELRELEASE}-rpm /boot/.System.map-%{KERNELRELEASE}-rpm
rm -f /boot/.vmlinuz-%{KERNELRELEASE}-rpm /boot/.System.map-%{KERNELRELEASE}-rpm
fi
+fi

%preun
if [ -x /sbin/new-kernel-pkg ]; then
5 changes: 1 addition & 4 deletions fedora-hetzner/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,11 @@

```shell
sudo dnf config-manager --add-repo 'https://loopholelabs.github.io/linux-pvm-ci/repodata/linux-pvm-ci.repo'
sudo dnf install -y --setopt=tsflags=noscripts kernel-6.7.0_rc6_pvm_host_fedora_hetzner-1.x86_64
sudo dnf install -y kernel-6.7.0_rc6_pvm_host_fedora_hetzner-1.x86_64
```

```shell
sudo grubby --add-kernel /boot/vmlinuz-6.7.0-rc6-pvm-host-fedora-hetzner --title /boot/vmlinuz-6.7.0-rc6-pvm-host-fedora-hetzner --copy-default --args="pti=off"
sudo grubby --set-default /boot/vmlinuz-6.7.0-rc6-pvm-host-fedora-hetzner
sudo grub2-mkconfig -o /boot/efi/EFI/fedora/grub.cfg
```

```shell
Expand All @@ -17,7 +15,6 @@ blacklist kvm-intel
blacklist kvm-amd
EOF
echo "kvm-pvm" | sudo tee /etc/modules-load.d/kvm-pvm.conf
sudo dracut --regenerate-all --force
```

```shell
Expand Down

0 comments on commit 388584c

Please sign in to comment.