summaryrefslogtreecommitdiffstats
path: root/scripts/plymouth-update-initrd
blob: 39b80ea4e99df14e33966a94b521bddc16cfc5f2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
#!/bin/bash

[ -z "$DESTDIR" ] || exit 0

set -e

[ -z "$LIBEXECDIR" ] && LIBEXECDIR="/usr/libexec"
[ -z "$DATADIR" ] && DATADIR="/usr/share"
[ -z "$INITRD" ] && INITRD="/boot/initrd-$(/bin/uname -r).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"

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@^#!\(.*\)@#!/bin/plymouthd \1\n@' init 
    sed -i -e 's@setquiet@&\n/bin/plymouth --show-splash\n/bin/plymouth --ask-for-password\n@' init
    (cd $LIBDIR
        DEPS=$(get_lib_deps ${LIBEXECDIR}/plymouth/plymouthd ${BINDIR}/plymouth ${LIBDIR}/plymouth/fedora-fade-in.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

    install -m644 ${DATADIR}/pixmaps/fedora-logo.png ${TMPDIR}${DATADIR}/plymouth
    install -m644 ${DATADIR}/plymouth/star.png ${TMPDIR}${DATADIR}/plymouth
    install -m644 ${DATADIR}/plymouth/lock.png ${TMPDIR}${DATADIR}/plymouth
    install -m644 ${DATADIR}/plymouth/entry.png ${TMPDIR}${DATADIR}/plymouth
    install -m644 ${DATADIR}/plymouth/bullet.png ${TMPDIR}${DATADIR}/plymouth

    mkdir -p ${TMPDIR}${LIBDIR}/plymouth
    install -m755 ${LIBDIR}/plymouth/fedora-fade-in.so ${TMPDIR}${LIBDIR}/plymouth
    install -m755 ${LIBDIR}/plymouth/text.so ${TMPDIR}${LIBDIR}/plymouth
    install -m755 ${LIBDIR}/plymouth/details.so ${TMPDIR}${LIBDIR}/plymouth

    rm -f $NEW_INITRD
    find | cpio --quiet -Hnewc -o | gzip -9 > $NEW_INITRD
    [ $? -eq 0 ] && echo "Wrote $NEW_INITRD"
)

rm -rf "$TMPDIR"

CURRENT_KERNEL=$(/sbin/grubby --default-kernel)

# 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

/sbin/grubby --title="$GRUB_MENU_TITLE"       \
             --add-kernel="$CURRENT_KERNEL"   \
	     --copy-default                   \
	     --args="vga=0x318 rhgb quiet"    \
	     --initrd="$NEW_INITRD"