Blame SOURCES/ship-label-plugin-in-initrd.patch

01552a
From 68f14b8a0163d688ca36541bc1e28173b0b62317 Mon Sep 17 00:00:00 2001
01552a
From: Ray Strode <rstrode@redhat.com>
01552a
Date: Mon, 20 Jul 2015 09:24:27 -0400
01552a
Subject: [PATCH] populate-initrd: ship label plugin / font in initrd
01552a
01552a
Some customers require showing text in the initrd, so
01552a
this commit goes ahead and ships label.so (and all its
01552a
dependencies) and one font in the initrd.
01552a
---
01552a
 scripts/plymouth-populate-initrd.in | 19 +++++++++++++++++++
01552a
 1 file changed, 19 insertions(+)
01552a
01552a
diff --git a/scripts/plymouth-populate-initrd.in b/scripts/plymouth-populate-initrd.in
01552a
index d25ab07..da55318 100755
01552a
--- a/scripts/plymouth-populate-initrd.in
01552a
+++ b/scripts/plymouth-populate-initrd.in
01552a
@@ -1,47 +1,48 @@
01552a
 #!/bin/bash
01552a
 #
01552a
 # inst bits ruthlessly and viciously stolen from dracut
01552a
 
01552a
 [ -z "$DESTDIR" ] || exit 0
01552a
 
01552a
 [ -z "$PLYMOUTH_LIBEXECDIR" ] && PLYMOUTH_LIBEXECDIR="@PLYMOUTH_LIBEXECDIR@"
01552a
 [ -z "$PLYMOUTH_DATADIR" ] && PLYMOUTH_DATADIR="@PLYMOUTH_DATADIR@"
01552a
 [ -z "$PLYMOUTH_PLUGIN_PATH" ] && PLYMOUTH_PLUGIN_PATH="$(plymouth --get-splash-plugin-path)"
01552a
 [ -z "$PLYMOUTH_LOGO_FILE" ] && PLYMOUTH_LOGO_FILE="@PLYMOUTH_LOGO_FILE@"
01552a
 [ -n "$PLYMOUTH_THEME_NAME" ] && THEME_OVERRIDE=1
01552a
 [ -z "$PLYMOUTH_THEME_NAME" ] && PLYMOUTH_THEME_NAME=$(plymouth-set-default-theme)
01552a
 [ -z "$PLYMOUTH_CONFDIR" ] && PLYMOUTH_CONFDIR="@PLYMOUTH_CONF_DIR@"
01552a
 [ -z "$PLYMOUTH_POLICYDIR" ] && PLYMOUTH_POLICYDIR="@PLYMOUTH_POLICY_DIR@"
01552a
 [ -z "$PLYMOUTH_DAEMON_PATH" ] && PLYMOUTH_DAEMON_PATH="@PLYMOUTH_DAEMON_DIR@/plymouthd"
01552a
 [ -z "$PLYMOUTH_CLIENT_PATH" ] && PLYMOUTH_CLIENT_PATH="@PLYMOUTH_CLIENT_DIR@/plymouth"
01552a
 [ -z "$SYSTEMD_UNIT_DIR" ] && SYSTEMD_UNIT_DIR="@SYSTEMD_UNIT_DIR@"
01552a
+[ -z "$SUPPORTED_LANGUAGES" ] && SUPPORTED_LANGUAGES="pt fr de it ru es en zh ja ko zh as bn gu hi kn ml mr or pa ta te"
01552a
 
01552a
 # Generic substring function.  If $2 is in $1, return 0.
01552a
 strstr() { [ "${1#*$2*}" != "$1" ]; }
01552a
 
01552a
 ddebug() {
01552a
     [ "$verbose" = "true" ] && echo "$@"
01552a
 }
01552a
 
01552a
 # normalize_path <path>
01552a
 # Prints the normalized path, where it removes any duplicated
01552a
 # and trailing slashes.
01552a
 # Example:
01552a
 # $ normalize_path ///test/test//
01552a
 # /test/test
01552a
 normalize_path() {
01552a
     shopt -q -s extglob
01552a
     set -- "${1//+(\/)//}"
01552a
     shopt -q -u extglob
01552a
     echo "${1%/}"
01552a
 }
01552a
 
01552a
 # convert_abs_rel <from> <to>
01552a
 # Prints the relative path, when creating a symlink to <to> from <from>.
01552a
 # Example:
01552a
 # $ convert_abs_rel /usr/bin/test /bin/test-2
01552a
 # ../../bin/test-2
01552a
 # $ ln -s $(convert_abs_rel /usr/bin/test /bin/test-2) /usr/bin/test
01552a
 convert_abs_rel() {
01552a
     local __current __absolute __abssize __cursize __newpath
01552a
     local -i __i __level
01552a
@@ -387,59 +388,77 @@ inst ${PLYMOUTH_CONFDIR}/plymouthd.conf $INITRDDIR
01552a
 if [ -z "$PLYMOUTH_THEME_NAME" ]; then
01552a
     echo "No default plymouth plugin is set" > /dev/stderr
01552a
     exit 1
01552a
 fi
01552a
 
01552a
 if [ $THEME_OVERRIDE ]; then
01552a
     conf=$INITRDDIR/${PLYMOUTH_CONFDIR}/plymouthd.conf
01552a
     echo "modifying plymouthd.conf: Theme=$PLYMOUTH_THEME_NAME" > /dev/stderr
01552a
     sed -i "s/^ *Theme *=.*/# theme modified by plymouth-populate-initrd\nTheme=$PLYMOUTH_THEME_NAME/" $conf
01552a
 fi
01552a
 
01552a
 PLYMOUTH_MODULE_NAME=$(grep "ModuleName *= *" ${PLYMOUTH_DATADIR}/plymouth/themes/${PLYMOUTH_THEME_NAME}/${PLYMOUTH_THEME_NAME}.plymouth | sed 's/ModuleName *= *//')
01552a
 
01552a
 if [ ! -f ${PLYMOUTH_PLUGIN_PATH}/${PLYMOUTH_MODULE_NAME}.so ]; then
01552a
     echo "The default plymouth plugin (${PLYMOUTH_MODULE_NAME}) doesn't exist" > /dev/stderr
01552a
     exit 1
01552a
 fi
01552a
 
01552a
 inst ${PLYMOUTH_PLUGIN_PATH}/${PLYMOUTH_MODULE_NAME}.so $INITRDDIR
01552a
 
01552a
 [ -f "${PLYMOUTH_PLUGIN_PATH}/renderers/drm.so" ] && inst ${PLYMOUTH_PLUGIN_PATH}/renderers/drm.so $INITRDDIR
01552a
 inst ${PLYMOUTH_PLUGIN_PATH}/renderers/frame-buffer.so $INITRDDIR
01552a
 
01552a
 if [ -d ${PLYMOUTH_DATADIR}/plymouth/themes/${PLYMOUTH_THEME_NAME} ]; then
01552a
     for x in ${PLYMOUTH_DATADIR}/plymouth/themes/${PLYMOUTH_THEME_NAME}/* ; do
01552a
         [ ! -f "$x" ] && continue
01552a
         inst $x $INITRDDIR
01552a
     done
01552a
 fi
01552a
 
01552a
+fonts=""
01552a
+needs_graphics="$(find ${INITRDDIR} -name 'libply-splash-graphics.so*' -print -quit | grep -q libply-splash-graphics.so && echo -n 1)"
01552a
+
01552a
+if [ -n "$needs_graphics" ]; then
01552a
+    for lang in $SUPPORTED_LANGUAGES; do
01552a
+        font=$(fc-match "":lang="$lang" file | awk -F= '{ print $2}')
01552a
+        echo $fonts | grep -q "$font" && continue
01552a
+        fonts="$fonts $font"
01552a
+    done
01552a
+
01552a
+    if [ -n "$fonts" ]; then
01552a
+        inst ${PLYMOUTH_PLUGIN_PATH}/label.so $INITRDDIR
01552a
+        for font in $fonts; do
01552a
+            inst $font $INITRDDIR
01552a
+        done
01552a
+    fi
01552a
+fi
01552a
+
01552a
 if [ -L ${PLYMOUTH_DATADIR}/plymouth/themes/default.plymouth ]; then
01552a
     cp -a ${PLYMOUTH_DATADIR}/plymouth/themes/default.plymouth $INITRDDIR${PLYMOUTH_DATADIR}/plymouth/themes
01552a
 fi
01552a
 
01552a
 if [ -n "$SYSTEMD_UNIT_DIR" -a -d "$SYSTEMD_UNIT_DIR" ]; then
01552a
     inst $SYSTEMD_UNIT_DIR/systemd-ask-password-plymouth.path $INITRDDIR
01552a
     inst $SYSTEMD_UNIT_DIR/systemd-ask-password-plymouth.service $INITRDDIR
01552a
 
01552a
     inst $SYSTEMD_UNIT_DIR/plymouth-switch-root.service $INITRDDIR
01552a
     inst $SYSTEMD_UNIT_DIR/plymouth-start.service $INITRDDIR
01552a
     inst $SYSTEMD_UNIT_DIR/plymouth-quit.service $INITRDDIR
01552a
     inst $SYSTEMD_UNIT_DIR/plymouth-quit-wait.service $INITRDDIR
01552a
     inst $SYSTEMD_UNIT_DIR/plymouth-reboot.service $INITRDDIR
01552a
     inst $SYSTEMD_UNIT_DIR/plymouth-kexec.service $INITRDDIR
01552a
     inst $SYSTEMD_UNIT_DIR/plymouth-poweroff.service $INITRDDIR
01552a
     inst $SYSTEMD_UNIT_DIR/plymouth-halt.service $INITRDDIR
01552a
 
01552a
     inst $SYSTEMD_UNIT_DIR/initrd-switch-root.target.wants/plymouth-switch-root.service $INITRDDIR
01552a
     inst $SYSTEMD_UNIT_DIR/initrd-switch-root.target.wants/plymouth-start.service $INITRDDIR
01552a
     inst $SYSTEMD_UNIT_DIR/sysinit.target.wants/plymouth-start.service $INITRDDIR
01552a
     inst $SYSTEMD_UNIT_DIR/multi-user.target.wants/plymouth-quit.service $INITRDDIR
01552a
     inst $SYSTEMD_UNIT_DIR/multi-user.target.wants/plymouth-quit-wait.service $INITRDDIR
01552a
     inst $SYSTEMD_UNIT_DIR/reboot.target.wants/plymouth-reboot.service $INITRDDIR
01552a
     inst $SYSTEMD_UNIT_DIR/kexec.target.wants/plymouth-kexec.service $INITRDDIR
01552a
     inst $SYSTEMD_UNIT_DIR/poweroff.target.wants/plymouth-poweroff.service $INITRDDIR
01552a
     inst $SYSTEMD_UNIT_DIR/halt.target.wants/plymouth-halt.service $INITRDDIR
01552a
 fi
01552a
 
01552a
 # vim:ts=8:sw=4:sts=4:et
01552a
-- 
01552a
2.3.7
01552a