summaryrefslogtreecommitdiffstats
path: root/scripts/plymouth-populate-initrd.in
blob: e584ee6adbf77165a4667cb7415d32abb1cd2c66 (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
86
87
88
89
90
91
92
93
94
95
96
97
98
#!/bin/bash

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

set -e

[ -z "$LIBEXECDIR" ] && LIBEXECDIR="/usr/libexec"
[ -z "$DATADIR" ] && DATADIR="/usr/share"
[ -z "$SYSTEMMAP" ] && SYSTEM_MAP="/boot/System.map-$(/bin/uname -r)"
[ -z "$LIB" ] && $(echo nash-showelfinterp /usr/bin/plymouth | /sbin/nash --forcequiet | grep -q lib64) && LIB="lib64" || LIB="lib"
[ -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="@logofile@"

if [ -f "${LIBEXECDIR}/initrd-functions" ]; then
    . "${LIBEXECDIR}/initrd-functions"
else
    echo "Couldn't import initrd functions." > /dev/stderr
    exit 1
fi

function usage() {
    local output="/dev/stdout"
    local rc=0
    if [ "$1" == "error" ]; then
        output="/dev/stderr"
        rc=1
    fi

    echo "usage: plymouth [ --verbose | -v ] { --targetdir | -t } <initrd_directory>" > $output
    exit $rc
}

verbose=false
INITRDDIR=""
while [ $# -gt 0 ]; do
    case $1 in
        --verbose|-v)
            verbose=true
            ;;
        --targetdir|-t)
            shift
            INITRDDIR="$1"
            ;;
        --help|-h)
            usage normal
            ;;
        *)
            usage error
            break
            ;;
    esac
    shift
done
set_verbose $verbose

[ -z "$INITRDDIR" ] && usage error

(cd $LIBDIR
    BINS="${LIBEXECDIR}/plymouth/plymouthd ${BINDIR}/plymouth ${LIBDIR}/plymouth/spinfinity.so ${LIBDIR}/plymouth/text.so ${LIBDIR}/plymouth/details.so"
    for bin in $BINS ; do
        DEPS=$(get_dso_deps $bin)
        for dep in $DEPS; do
            inst $dep $INITRDDIR
        done
    done
)

inst ${LIBEXECDIR}/plymouth/plymouthd $INITRDDIR /bin/plymouthd
inst ${BINDIR}/plymouth $INITRDDIR
inst ${LIBDIR}/plymouth/text.so $INITRDDIR
inst ${LIBDIR}/plymouth/details.so $INITRDDIR
inst ${PLYMOUH_LOGO_FILE} $INITRDDIR
mkdir -p ${INITRDDIR}${DATADIR}/plymouth

PLUGIN_NAME=$(plymouth-set-default-plugin)

if [ -z "$PLUGIN_NAME" ]; then
    echo "No default plymouth plugin is set" > /dev/stderr
    exit 1
fi

if [ ! -f ${LIBDIR}/plymouth/${PLUGIN_NAME}.so ]; then
    echo "The default plymouth plugin (${PLUGIN_NAME}) doesn't exist" > /dev/stderr
    exit 1
fi

inst ${LIBDIR}/plymouth/${PLUGIN_NAME}.so $INITRDDIR
inst ${LIBDIR}/plymouth/default.so $INITRDIR
if [ -d ${DATADIR}/plymouth/${PLUGIN_NAME} ]; then
    for x in ${DATADIR}/plymouth/${PLUGIN_NAME}/* ; do
        [ ! -f "$x" ] && break
        inst $x $INITRDDIR
    done
fi

# vim:ts=8:sw=4:sts=4:et