kernel posttrans and preun hooks for other packages
Matt Domsch
Matt_Domsch at dell.com
Mon Feb 18 15:49:44 UTC 2008
On Mon, Feb 18, 2008 at 09:36:49AM -0500, Jeremy Katz wrote:
> On Sun, 2008-02-17 at 20:16 -0600, Matt Domsch wrote:
> > is there any reason why we can't just move %post to %posttrans?
>
> %posttrans breaks the way we do bootloader config updating as it leaves
> around no entries in the bootloader config after all the %preuns have
> been processed. I looked at this a few months ago and thought we talked
> about it here, but it might have just been mail between davej and myself
ok, new-kernel-pkg grows a --rpmposttrans mode then to call these
hooks, and we add a %posttrans to each kernel RPM.
--
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-18 09:12:02.000000000 -0600
@@ -1590,12 +1590,23 @@ fi\
%{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 %%post.
+#
+%define kernel_variant_posttrans(s:r:v:) \
+%{expand:%%posttrans %{?-v*}}\
+/sbin/new-kernel-pkg --package kernel%{?-v:-%{-v*}} --rpmposttrans %{?1} %{KVERREL}%{?-v*} || exit $?\
+%{nil}
+
+#
# This macro defines a %%post script for a kernel package and its devel package.
# %%kernel_variant_post [-v <subpackage>] [-s <s> -r <r>] <mkinitrd-args>
# More text can follow to go at the end of this variant's %%post.
#
%define kernel_variant_post(s:r:v:) \
%{expand:%%kernel_devel_post %{?-v*}}\
+%{expand:%%kernel_variant_posttrans %{?-v*}}\
%{expand:%%post %{?-v*}}\
%{-s:\
if [ `uname -i` == "x86_64" -o `uname -i` == "i386" ] &&\
--- new-kernel-pkg.orig 2008-02-15 13:22:46.000000000 -0600
+++ new-kernel-pkg 2008-02-18 09:04:44.000000000 -0600
@@ -96,7 +96,7 @@ usage() {
echo " [--kernel-args=<args>] [--remove-args=<args>]" >&2
echo " [--banner=<banner>] [--multiboot=multiboot]" >&2
echo " [--mbargs=mbargs] [--make-default]" >&2
- echo " <--install | --remove | --update> <kernel-version>" >&2
+ echo " <--install | --remove | --update | --rpmposttrans> <kernel-version>" >&2
echo " (ex: `basename $0` --mkinitrd --depmod --install 2.4.7-2)" >&2
exit 1
}
@@ -185,6 +185,19 @@ install() {
}
+rpmposttrans()
+{
+ local d
+ local f
+ for d in /etc/kernel/postinst.d /etc/kernel/postinst.d/$version ; do
+ if [ -d $d ]; then
+ for f in $(ls $d/); do
+ [ -x $d/$f ] && $d/$f $version $bootPrefix/$kernelName-$version
+ done
+ fi
+ done
+}
+
remove() {
# FIXME: is this a good heuristic to find out if we're on iSeries?
if [ -d /proc/iSeries ]; then
@@ -193,6 +206,16 @@ remove() {
return
fi
+ local d
+ local f
+ for d in /etc/kernel/prerm.d /etc/kernel/prerm.d/$version ; do
+ if [ -d $d ]; then
+ for f in $(ls $d/); do
+ [ -x $d/$f ] && $d/$f $version $bootPrefix/$kernelName-$version
+ done
+ fi
+ done
+
if [ -n "$cfgGrub" ]; then
[ -n "$verbose" ] && echo "removing $version from $grubConfig"
$grubby --remove-kernel=$bootPrefix/$kernelName-$version
@@ -379,7 +402,7 @@ while [ $# -gt 0 ]; do
done
# make sure the mode is valid
-if [ "$mode" != "--install" -a "$mode" != "--remove" -a "$mode" != "--update" ] ; then
+if [ "$mode" != "--install" -a "$mode" != "--remove" -a "$mode" != "--update" -a "$mode" != "--rpmposttrans" ] ; then
usage
fi
@@ -451,6 +474,8 @@ elif [ "$mode" == "--remove" ]; then
remove
elif [ "$mode" == "--update" ]; then
update
+elif [ "$mode" == "--rpmposttrans" ]; then
+ rpmposttrans
fi
exit 0
More information about the Fedora-kernel-list
mailing list