1
0
suse-module-tools/regenerate-initrd-posttrans
Stephan Kulow 58d0049314 Accepting request 329708 from home:trenn:branches:Base:System
- Use /run instead of deprecated /var/run
  This can have sever consequences if this package uses /var/run. It may
  be installed before filesystem package generating the /run tmpfs and
  predict it to generate the link /var/run -> /run. Later dracut convertfs
  kicks in to generate it, but it has issues. bsc#922676

OBS-URL: https://build.opensuse.org/request/show/329708
OBS-URL: https://build.opensuse.org/package/show/Base:System/suse-module-tools?expand=0&rev=25
2015-09-19 06:10:30 +00:00

64 lines
1.2 KiB
Bash

#!/bin/bash
#
# Packages that install kernels or kernel-modules create a flag
#
# /run/regenerate-initrd/<kernel image>
#
# to have the initrd for <kernel image> generated, or
#
# /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=/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
/sbin/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 ! /sbin/mkinitrd -k "/boot/$image" -i "/boot/$initrd"; then
err=$?
fi
done
exit $err