kernel posttrans and preun hooks for other packages

Matt Domsch Matt_Domsch at dell.com
Sat Feb 16 15:53:26 UTC 2008


https://bugzilla.redhat.com/show_bug.cgi?id=433121

DKMS would like to have the opportunity to run it's
auto-rebuilder/installer after a new kernel RPM has been installed,
without having to wait for a system restart to run it.  Likewise, when
a kernel RPM is removed, it would like to be able to run to remove
modules managed by it.

Debian kernels intentionally run scripts located in
/etc/kernel/postinst.d/ following new kernel package installation,
/etc/kernel/prerm.d/ before kernel package removal.  DKMS drops a
script into these directories, to perform the appropriate actions.

I want Fedora and RHEL kernels to do likewise.  Patch attached.
This patch implements the same interface as that used for Debian and
Ubuntu kernels.  The scripts are invoked with $1 = kernel version, and
$2 = path to vmlinuz file.  (DKMS doesn't need $2, but I'm keeping the
interface the same to match so people can reuse their scriptlets.)


-- 
Matt Domsch
Linux Technology Strategist, Dell Office of the CTO
linux.dell.com & www.dell.com/linux

--- kernel.spec.orig	2008-02-15 21:06:33.000000000 -0600
+++ kernel.spec	2008-02-16 00:07:36.000000000 -0600
@@ -1610,11 +1610,35 @@
 %{nil}
 
 #
+# This macro defines a %%posttrans script for a kernel package.
+#	%%kernel_variant_posttrans [-v <subpackage>] [-s <s> -r <r>] <mkinitrd-args>
+# More text can follow to go at the end of this variant's %%posttrans.
+#
+%define kernel_variant_posttrans(v:) \
+%{expand:%%posttrans %{?-v*}}\
+for d in /etc/kernel/postinst.d /etc/kernel/postinst.d/%{KVERREL}%{?-v*} ; do \
+    if [ -d "${d}" ]; then \
+       for f in $(ls ${d}/); do \
+       	   [ -x "${d}/${f}" ] && "${d}/${f}" %{KVERREL}%{?-v*} /boot/vmlinuz-%{KVERREL}%{?-v*} \
+       done \
+    fi \
+done \
+exit 0\
+%{nil}
+
+#
 # This macro defines a %%preun script for a kernel package.
 #	%%kernel_variant_preun <subpackage>
 #
 %define kernel_variant_preun() \
 %{expand:%%preun %{?1}}\
+for d in /etc/kernel/prerm.d /etc/kernel/prerm.d/%{KVERREL}%{?1} ; do \
+    if [ -d "${d}" ]; then \
+       for f in $(ls ${d}/); do \
+       	   [ -x "${d}/${f}" ] && "${d}/${f}" %{KVERREL}%{?1} /boot/vmlinuz-%{KVERREL}%{?1} \
+       done \
+    fi \
+done \
 /sbin/new-kernel-pkg --rminitrd --rmmoddep --remove %{KVERREL}%{?1} || exit $?\
 #if [ -x /sbin/weak-modules ]\
 #then\
@@ -1624,12 +1648,15 @@
 
 %kernel_variant_preun
 %kernel_variant_post -s kernel-smp -r kernel
+%kernel_variant_posttrans
 
 %kernel_variant_preun smp
 %kernel_variant_post -v smp
+%kernel_variant_posttrans -v smp
 
 %kernel_variant_preun PAE
 %kernel_variant_post -v PAE -s kernel-smp -r kernel-PAE
+%kernel_variant_posttrans -v PAE
 
 %kernel_variant_preun debug
 %kernel_variant_post -v debug
@@ -1644,6 +1671,8 @@
     /sbin/ldconfig -X || exit $?
 fi
 
+%kernel_variant_posttrans -v xen
+
 ###
 ### file lists
 ###




More information about the Fedora-kernel-list mailing list