From b50c79e71cfa820bb7e8286a96298bd06f57af00 Mon Sep 17 00:00:00 2001 From: Javier Martinez Canillas Date: Mon, 17 Jun 2019 17:20:17 +0200 Subject: [PATCH] Add a kernel-install plugin to execute hook scripts in /etc/kernel/ The kernel hook scripts in /etc/kernel/postinst.d and /etc/kernel/prerm.d were executed by the new-kernel-pkg --rpmposttrans and --remove options. But with a BLS configuration the new-kernel-pkg script isn't executed and instead the kernel-install plugins are used. Add a kernel-install plugin that executes the hooks since packages like dkms and akmod make use of it. Resolves: rhbz#1696202 Signed-off-by: Javier Martinez Canillas --- 95-kernel-hooks.install | 33 +++++++++++++++++++++++++++++++++ grubby.spec | 9 ++++++++- 2 files changed, 41 insertions(+), 1 deletion(-) create mode 100755 95-kernel-hooks.install diff --git a/95-kernel-hooks.install b/95-kernel-hooks.install new file mode 100755 index 0000000..1313556 --- /dev/null +++ b/95-kernel-hooks.install @@ -0,0 +1,33 @@ +#!/usr/bin/bash + +if ! [[ $KERNEL_INSTALL_MACHINE_ID ]]; then + exit 0 +fi + +COMMAND="$1" +KERNEL_VERSION="$2" +BOOT_DIR_ABS="$3" + +# If $BOOT_DIR_ABS exists, some other boot loader is active. +[[ -d "$BOOT_DIR_ABS" ]] && exit 0 + +run_hooks() +{ + local f + local files="$1" + for f in $files ; do + [ -x "$f" ] || continue + "$f" "$KERNEL_VERSION" "/boot/vmlinuz-$KERNEL_VERSION" + done +} + +case "$COMMAND" in + add) + run_hooks "/etc/kernel/postinst.d/*[^~] /etc/kernel/postinst.d/$KERNEL_VERSION/*[^~]" + ;; + remove) + run_hooks "/etc/kernel/prerm.d/*[^~] /etc/kernel/prerm.d/$KERNEL_VERSION/*[^~]" + ;; + *) + exit 0 +esac diff --git a/grubby.spec b/grubby.spec index 5bd679c..6134415 100644 --- a/grubby.spec +++ b/grubby.spec @@ -1,6 +1,6 @@ Name: grubby Version: 8.40 -Release: 33%{?dist} +Release: 34%{?dist} Summary: Command line tool for updating bootloader configs License: GPLv2+ URL: https://github.com/rhinstaller/grubby @@ -13,6 +13,7 @@ Source1: grubby-bls Source2: grubby.in Source3: installkernel.in Source4: installkernel-bls +Source5: 95-kernel-hooks.install Patch0001: 0001-remove-the-old-crufty-u-boot-support.patch Patch0002: 0002-Change-return-type-in-getRootSpecifier.patch Patch0003: 0003-Add-btrfs-subvolume-support-for-grub2.patch @@ -81,6 +82,7 @@ sed -e "s,@@LIBEXECDIR@@,%{_libexecdir}/grubby,g" %{SOURCE2} \ > %{buildroot}%{_sbindir}/grubby sed -e "s,@@LIBEXECDIR@@,%{_libexecdir}/installkernel,g" %{SOURCE3} \ > %{buildroot}%{_sbindir}/installkernel +install -D -m 0755 -t %{buildroot}%{_prefix}/lib/kernel/install.d/ %{SOURCE5} %post if [ "$1" = 2 ]; then @@ -113,6 +115,7 @@ current boot environment. %attr(0755,root,root) %{_sbindir}/grubby %attr(0755,root,root) %{_libexecdir}/installkernel/installkernel-bls %attr(0755,root,root) %{_sbindir}/installkernel +%attr(0755,root,root) %{_prefix}/lib/kernel/install.d/95-kernel-hooks.install %{_mandir}/man8/[gi]*.8* %files deprecated @@ -128,6 +131,10 @@ current boot environment. %{_mandir}/man8/*.8* %changelog +* Mon Jun 17 2019 Javier Martinez Canillas - 8.40-34 +- Add a kernel-install plugin to execute hook scripts in /etc/kernel/ + Resolves: rhbz#1696202 + * Mon Jun 10 22:13:19 CET 2019 Igor Gnatenko - 8.40-33 - Rebuild for RPM 4.15