plymouth/scripts/plymouth-update-initrd
Ray Strode 9d9018ac1b Change heuristics in update script for finding which initrd to repack
Before we were using the current initrd, now we use the default initrd
This will hopefully prevent the mismatched kernel/initrd problem.
2008-06-10 10:36:53 -04:00

87 lines
3.4 KiB
Bash
Executable file

#!/bin/bash
[ -z "$DESTDIR" ] || exit 0
set -e
[ -z "$LIBEXECDIR" ] && LIBEXECDIR="/usr/libexec"
[ -z "$DATADIR" ] && DATADIR="/usr/share"
[ -z "$INITRD" ] && INITRD="/boot/initrd-$(/sbin/grubby --default-kernel | sed 's/.*vmlinuz-//g').img"
[ -z "$SYSTEMMAP" ] && SYSTEM_MAP="/boot/System.map-$(/bin/uname -r)"
[ -z "$LIB" ] && [ $(head -n1 $SYSTEM_MAP | awk '{print $1}' | wc -c) -lt 16 ] && LIB="lib" || LIB="lib64"
[ -z "$LIBDIR" ] && LIBDIR="/usr/$LIB"
[ -z "$BINDIR" ] && BINDIR="/usr/bin"
[ -z "$GRUB_MENU_TITLE" ] && GRUB_MENU_TITLE="Graphical Bootup"
[ -z "$PLYMOUTH_LOGO_FILE" ] && PLYMOUTH_LOGO_FILE="/usr/share/pixmaps/system-logo-white.png"
if [ -z "$NEW_INITRD" ]; then
NEW_INITRD="$(dirname $INITRD)/$(basename $INITRD .img)-plymouth.img"
fi
function get_lib_deps()
{
while [ $# -gt 0 ]; do
/usr/bin/ldd $1 | sed -n 's/.*=> \?\([^ ]*\) (.*$/\1/p'
shift
done | sort -u
}
TMPDIR="$(mktemp -d $PWD/initrd.XXXXXXXXXX)"
(cd $TMPDIR
zcat $INITRD | cpio --quiet -Hnewc -i --make-directories
sed -i -e 's@mknod /dev/ttyS3 c 4 67@&\nmknod /dev/fb c 29 0\nmknod /dev/fb0 c 29 0\ndaemonize /bin/plymouthd\n/bin/plymouth --show-splash\n@' init
sed -i -e 's@switchroot@&\n/bin/plymouth --newroot /sysroot\n&\n@' init
(cd $LIBDIR
DEPS=$(get_lib_deps ${LIBEXECDIR}/plymouth/plymouthd ${BINDIR}/plymouth ${LIBDIR}/plymouth/spinfinity.so ${LIBDIR}/plymouth/text.so ${LIBDIR}/plymouth/details.so)
for dep in $DEPS; do
install -D -m755 $dep ${TMPDIR}$(dirname $dep)
done
)
/sbin/ldconfig -n $LIB
/sbin/ldconfig -n .${LIBDIR}
install -m755 ${LIBEXECDIR}/plymouth/plymouthd bin
install -m755 ${BINDIR}/plymouth bin
mkdir -p ${TMPDIR}${DATADIR}/plymouth/spinfinity
install -m644 ${DATADIR}/plymouth/spinfinity/lock.png ${TMPDIR}${DATADIR}/plymouth/spinfinity
install -m644 ${DATADIR}/plymouth/spinfinity/entry.png ${TMPDIR}${DATADIR}/plymouth/spinfinity
install -m644 ${DATADIR}/plymouth/spinfinity/bullet.png ${TMPDIR}${DATADIR}/plymouth/spinfinity
install -m644 ${DATADIR}/plymouth/spinfinity/box.png ${TMPDIR}${DATADIR}/plymouth/spinfinity
install -m644 ${DATADIR}/plymouth/spinfinity/throbber-[0-3][0-9].png ${TMPDIR}${DATADIR}/plymouth/spinfinity
mkdir -p ${TMPDIR}${LIBDIR}/plymouth
install -m755 ${LIBDIR}/plymouth/spinfinity.so ${TMPDIR}${LIBDIR}/plymouth
install -m755 ${LIBDIR}/plymouth/text.so ${TMPDIR}${LIBDIR}/plymouth
install -m755 ${LIBDIR}/plymouth/details.so ${TMPDIR}${LIBDIR}/plymouth
install -D -m644 ${PLYMOUTH_LOGO_FILE} ${TMPDIR}${PLYMOUTH_LOGO_FILE}
rm -f $NEW_INITRD
find | cpio --quiet -Hnewc -o | gzip -9 > $NEW_INITRD
[ $? -eq 0 ] && echo "Wrote $NEW_INITRD"
)
rm -rf "$TMPDIR"
# XXX: Hack to clean out old entry since grubby doesn't deal with dupes too well
if fgrep -q "title $GRUB_MENU_TITLE" /etc/grub.conf; then
TMPFILE="$(mktemp /etc/grub.conf.XXXXXXXXXX)"
if [ -L /etc/grub.conf ]; then
GRUB_CONF="$(readlink /etc/grub.conf)"
else
GRUB_CONF="/etc/grub.conf"
fi
(cd /etc; awk '$1 != "'"$GRUB_MENU_TITLE"'" { printf $0 RT }' RS="title " FS="\n" $GRUB_CONF > $TMPFILE \
&& mv $TMPFILE $GRUB_CONF || rm -f $TMPFILE)
fi
CURRENT_KERNEL=$(/sbin/grubby --default-kernel)
/sbin/grubby --title="$GRUB_MENU_TITLE" \
--add-kernel="$CURRENT_KERNEL" \
--copy-default \
--args="vga=0x318 rhgb quiet" \
--initrd="$NEW_INITRD"