From fd0679e1ff52e115e3868c609dfe74142d01b6c7 Mon Sep 17 00:00:00 2001 From: Javier Martinez Canillas Date: Tue, 27 Feb 2018 21:16:15 +0100 Subject: [PATCH] Add patch to install kernel images for GRUB BootLoaderSpec support GRUB now has BootLoaderSpec support, the user can choose to use this by setting GRUB_ENABLE_BLSCFG to true in /etc/default/grub. On this setup, grubby isn't used to generate the kernel modules dependencies, instead the depmod install script could be used. But the BLS support in GRUB uses the config snippets that are generated at build time and included in the kernel package, so the loaderentry install script shouldn't be executed when using GRUB. Signed-off-by: Javier Martinez Canillas --- ...on-t-install-BLS-kernel-images-if-de.patch | 33 +++++++++++++ 20-grubby.install | 46 ++++++++++++++++--- systemd.spec | 6 ++- 3 files changed, 78 insertions(+), 7 deletions(-) create mode 100644 0999-kernel-install-Don-t-install-BLS-kernel-images-if-de.patch diff --git a/0999-kernel-install-Don-t-install-BLS-kernel-images-if-de.patch b/0999-kernel-install-Don-t-install-BLS-kernel-images-if-de.patch new file mode 100644 index 0000000..c26ec4f --- /dev/null +++ b/0999-kernel-install-Don-t-install-BLS-kernel-images-if-de.patch @@ -0,0 +1,33 @@ +From cc3fa810197881a48c3fa8a1e6a1f97f5c251581 Mon Sep 17 00:00:00 2001 +From: Javier Martinez Canillas +Date: Tue, 27 Feb 2018 21:18:55 +0100 +Subject: [PATCH 1/1] kernel-install: Don't install BLS kernel images if dest + dir doesn't exist + +The script shouldn't rely on a previous script exiting with a status code +that prevents it to be executed. Instead, should check if the destination +directory for the BLS kernel image exists and exit otherwise. + +Signed-off-by: Javier Martinez Canillas +--- + src/kernel-install/90-loaderentry.install | 4 ++++ + 1 file changed, 4 insertions(+) + +diff --git a/src/kernel-install/90-loaderentry.install b/src/kernel-install/90-loaderentry.install +index 305ea8f5c97f..a271cdb8a03e 100644 +--- a/src/kernel-install/90-loaderentry.install ++++ b/src/kernel-install/90-loaderentry.install +@@ -11,6 +11,10 @@ if ! [[ $KERNEL_INSTALL_MACHINE_ID ]]; then + exit 0 + fi + ++if ! [[ -d "$BOOT_DIR_ABS" ]]; then ++ exit 0 ++fi ++ + MACHINE_ID=$KERNEL_INSTALL_MACHINE_ID + + BOOT_DIR="/$MACHINE_ID/$KERNEL_VERSION" +-- +2.14.3 + diff --git a/20-grubby.install b/20-grubby.install index e059125..4e9797a 100755 --- a/20-grubby.install +++ b/20-grubby.install @@ -1,15 +1,30 @@ #!/bin/bash -if [[ ! -x /sbin/new-kernel-pkg ]]; then +if [[ ! -f /etc/default/grub ]]; then exit 0 fi +. /etc/default/grub + +[[ -f /etc/os-release ]] && . /etc/os-release + COMMAND="$1" KERNEL_VERSION="$2" BOOT_DIR_ABS="$3" KERNEL_IMAGE="$4" KERNEL_DIR="${KERNEL_IMAGE%/*}" + +MACHINE_ID=$KERNEL_INSTALL_MACHINE_ID + +# Remove it, since for grub2 the images are always installed in /boot +rm -rf "${BOOT_DIR_ABS%/*}" + +BLS_DIR="/boot/loader/entries" +if [ -d /sys/firmware/efi ]; then + BLS_DIR="/boot/efi/EFI/${ID}/loader/entries" +fi + [[ "$KERNEL_VERSION" == *\+* ]] && flavor=-"${KERNEL_VERSION##*+}" case "$COMMAND" in add) @@ -34,18 +49,37 @@ case "$COMMAND" in restorecon "/boot/.${KERNEL_IMAGE##*/}-${KERNEL_VERSION}.hmac" fi fi + + if [ "x${GRUB_ENABLE_BLSCFG}" = "xtrue" ]; then + [[ -d "$BLS_DIR" ]] || mkdir -p "$BLS_DIR" + cp -aT "${KERNEL_DIR}/bls.conf" "${BLS_DIR}/${MACHINE_ID}-${KERNEL_VERSION}.conf" || exit $? + exit 0 + fi + /sbin/new-kernel-pkg --package "kernel${flavor}" --install "$KERNEL_VERSION" || exit $? /sbin/new-kernel-pkg --package "kernel${flavor}" --mkinitrd --dracut --depmod --update "$KERNEL_VERSION" || exit $? /sbin/new-kernel-pkg --package "kernel${flavor}" --rpmposttrans "$KERNEL_VERSION" || exit $? + # If grubby is used there's no need to run other installation plugins + exit 77 ;; remove) + + if [ "x${GRUB_ENABLE_BLSCFG}" = "xtrue" ]; then + rm -f "${BLS_DIR}/${MACHINE_ID}-${KERNEL_VERSION}.conf" + + for i in vmlinuz System.map config zImage.stub dtb; do + rm -rf "/boot/${i}-${KERNEL_VERSION}" + done + # hmac is .vmlinuz-.hmac so needs a special treatment + rm -f "/boot/.vmlinuz-${KERNEL_VERSION}.hmac" + + exit 0 + fi + /sbin/new-kernel-pkg --package "kernel${flavor+-$flavor}" --rminitrd --rmmoddep --remove "$KERNEL_VERSION" || exit $? + # If grubby is used there's no need to run other installation plugins + exit 77 ;; *) ;; esac - -# skip other installation plugins, if we can't find a boot loader spec conforming setup -if ! [[ -d /boot/loader/entries || -L /boot/loader/entries ]]; then - exit 77 -fi diff --git a/systemd.spec b/systemd.spec index fcd1511..fcc8ab0 100644 --- a/systemd.spec +++ b/systemd.spec @@ -13,7 +13,7 @@ Name: systemd Url: http://www.freedesktop.org/wiki/Software/systemd Version: 237 -Release: 6%{?gitcommit:.git%{gitcommitshort}}%{?dist} +Release: 7%{?gitcommit:.git%{gitcommitshort}}%{?dist} # For a breakdown of the licensing, see README License: LGPLv2+ and MIT and GPLv2+ Summary: System and Service Manager @@ -51,6 +51,7 @@ GIT_DIR=../../src/systemd/.git git diffab -M v233..master@{2017-06-15} -- hwdb/[ Patch1: systemd-typecast-usbids.patch Patch0998: 0998-resolved-create-etc-resolv.conf-symlink-at-runtime.patch +Patch0999: 0999-kernel-install-Don-t-install-BLS-kernel-images-if-de.patch %global num_patches %{lua: c=0; for i,p in ipairs(patches) do c=c+1; end; print(c);} @@ -711,6 +712,9 @@ fi %files tests -f .file-list-tests %changelog +* Tue Feb 27 2018 Javier Martinez Canillas - 234-7.git84c8da5 +- Add patch to install kernel images for GRUB BootLoaderSpec support + * Sat Feb 24 2018 Zbigniew Jędrzejewski-Szmek - 237-6.git84c8da5 - Create /etc/systemd in %%post libs if necessary (#1548607)