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 <javierm@redhat.com>
This commit is contained in:
Javier Martinez Canillas 2019-06-17 17:20:17 +02:00
parent 7c6e97e809
commit b50c79e71c
No known key found for this signature in database
GPG Key ID: C751E590D63F3D69
2 changed files with 41 additions and 1 deletions

33
95-kernel-hooks.install Executable file
View File

@ -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

View File

@ -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 <javierm@redhat.com> - 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 <ignatenkobrain@fedoraproject.org> - 8.40-33
- Rebuild for RPM 4.15