2
0

Accepting request 229466 from Base:System

- weak-modules2: Run mkinitrd in posttrans if $INITRD_IN_POSTTRANS
  is set (fate#313506)

- regenerate-initrd-posttrans: Run mkinitrd_setup

- Add macros for regenerating the initrd in %posttrans
  (fate#313506). (forwarded request 229365 from michal-m)

OBS-URL: https://build.opensuse.org/request/show/229466
OBS-URL: https://build.opensuse.org/package/show/openSUSE:Factory/suse-module-tools?expand=0&rev=9
This commit is contained in:
Stephan Kulow 2014-04-11 12:40:26 +00:00 committed by Git OBS Bridge
commit 49332bbb4e
5 changed files with 116 additions and 8 deletions

15
macros.initrd Normal file
View File

@ -0,0 +1,15 @@
# Packages installing files and binaries that end up in the initrd should
# call these macros in their post(trans) scriptlets to have the initrd
# regenerated
# See also fate#313506
%regenerate_initrd_post \
mkdir -p /var/run/regenerate-initrd/ \
touch /var/run/regenerate-initrd/all \
%nil
%regenerate_initrd_posttrans \
if test -x /usr/lib/module-init-tools/regenerate-initrd-posttrans; then \
/bin/bash -${-/e/} /usr/lib/module-init-tools/regenerate-initrd-posttrans \
fi \
%nil

View File

@ -0,0 +1,63 @@
#!/bin/bash
#
# Packages that install kernels or kernel-modules create a flag
#
# /var/run/regenerate-initrd/<kernel image>
#
# to have the initrd for <kernel image> generated, or
#
# /var/run/regenerate-initrd/all
#
# to have all initrds generated. This script is called from posttrans
# and takes care of generating the initrds
shopt -s nullglob
dir=/var/run/regenerate-initrd
did_mkinitrd_setup=false
run_mkinitrd_setup()
{
if ! $did_mkinitrd_setup; then
if test -x /sbin/mkinitrd_setup; then
/sbin/mkinitrd_setup
fi
did_mkinitrd_setup=true
fi
}
if ! test -d "$dir"; then
exit 0
fi
for f in "$dir"/*; do
# check if we are in a build chroot
if ! [ -f /etc/fstab -a ! -e /.buildenv -a -x /sbin/mkinitrd ] ; then
echo "Please run mkinitrd as soon as your system is complete." >&2
rm "$dir"/*
exit 0
fi
break
done
if test -e "$dir/all"; then
rm "$dir"/*
run_mkinitrd_setup
mkinitrd
exit
fi
err=0
for f in "$dir"/*; do
rm "$f"
image=${f##*/}
initrd=initrd-${image#*-}
if ! test -e "/boot/$image"; then
echo "$0: /boot/$image does not exist, initrd won't be generated"
continue
fi
run_mkinitrd_setup
if ! mkinitrd -k "/boot/$image" -i "/boot/$initrd"; then
err=$?
fi
done
exit $err

View File

@ -1,3 +1,20 @@
-------------------------------------------------------------------
Fri Apr 4 14:32:48 UTC 2014 - mmarek@suse.cz
- weak-modules2: Run mkinitrd in posttrans if $INITRD_IN_POSTTRANS
is set (fate#313506)
-------------------------------------------------------------------
Fri Apr 4 13:34:09 UTC 2014 - mmarek@suse.cz
- regenerate-initrd-posttrans: Run mkinitrd_setup
-------------------------------------------------------------------
Fri Apr 4 12:13:18 UTC 2014 - mmarek@suse.cz
- Add macros for regenerating the initrd in %posttrans
(fate#313506).
-------------------------------------------------------------------
Mon Mar 31 09:11:16 UTC 2014 - mmarek@suse.cz

View File

@ -39,6 +39,8 @@ Source7: driver-check.sh
Source8: suse-module-tools.rpmlintrc
Source9: modsign-verify
Source10: kmp-install
Source11: macros.initrd
Source12: regenerate-initrd-posttrans
BuildRoot: %{_tmppath}/%{name}-%{version}-build
%description
@ -78,6 +80,11 @@ install -d -m 755 "$b/usr/lib/module-init-tools"
install -pm 755 %_sourcedir/weak-modules{,2} "$b/usr/lib/module-init-tools/"
install -pm 755 %_sourcedir/driver-check.sh "$b/usr/lib/module-init-tools/"
# rpm macros and helper
install -d -m 755 "$b/etc/rpm"
install -pm 644 "%_sourcedir/macros.initrd" "$b/etc/rpm/"
install -pm 755 "%_sourcedir/regenerate-initrd-posttrans" "$b/usr/lib/module-init-tools/"
# modsign-verify for verifying module signatures
install -d -m 755 "$b/usr/bin"
install -pm 755 %_sourcedir/modsign-verify "$b/usr/bin/"
@ -145,6 +152,7 @@ fi
%config(noreplace) /etc/modprobe.d/99-local.conf
%dir /etc/depmod.d
%config /etc/depmod.d/00-system.conf
%config /etc/rpm/macros.initrd
%_docdir/module-init-tools
/usr/bin/kmp-install
/usr/bin/modsign-verify

View File

@ -355,14 +355,19 @@ run_depmod_and_mkinitrd() {
fi
done
if [ -n "$image" ]; then
doit /sbin/mkinitrd -k /boot/$image-$krel -i /boot/initrd-$krel
status=$?
# mkinitrd fails with status 10 if any required kernel modules
# missing. We expect those modules to be added later (by one of
# the other kernel-$flavor packages).
if [ $status -eq 10 ]; then
log "mkinitrd failed with status 10 (module missing), proceeding"
status=0
if test -n "$INITRD_IN_POSTTRANS"; then
mkdir -p /var/run/regenerate-initrd
touch /var/run/regenerate-initrd/$image-$krel
else
doit /sbin/mkinitrd -k /boot/$image-$krel -i /boot/initrd-$krel
status=$?
# mkinitrd fails with status 10 if any required kernel modules
# missing. We expect those modules to be added later (by one of
# the other kernel-$flavor packages).
if [ $status -eq 10 ]; then
log "mkinitrd failed with status 10 (module missing), proceeding"
status=0
fi
fi
else
echo "WARNING: kernel image for $krel not found!" >&2