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

f67285
From f72cdd6969c483d7811e5684fa3143deff55a0c7 Mon Sep 17 00:00:00 2001
2836bb
From: Ray Strode <rstrode@redhat.com>
2836bb
Date: Mon, 17 Jun 2019 13:54:42 -0400
f67285
Subject: [PATCH] populate-initrd: ship label plugin
2836bb
f67285
This gives us font rendering at early boot.
2836bb
---
f67285
 scripts/plymouth-populate-initrd.in | 23 +++++++++++++++++++++--
f67285
 1 file changed, 21 insertions(+), 2 deletions(-)
2836bb
2836bb
diff --git a/scripts/plymouth-populate-initrd.in b/scripts/plymouth-populate-initrd.in
f67285
index 616ecc4..60fd063 100755
2836bb
--- a/scripts/plymouth-populate-initrd.in
2836bb
+++ b/scripts/plymouth-populate-initrd.in
f67285
@@ -1,55 +1,56 @@
2836bb
 #!/bin/bash
2836bb
 #
2836bb
 # inst bits ruthlessly and viciously stolen from dracut
2836bb
 
2836bb
 [ -z "$DESTDIR" ] || exit 0
2836bb
 
f67285
 # For running on a (cross-compiled) sysroot, the following
f67285
 # settings are needed:
f67285
 # PLYMOUTH_SYSROOT - the sysroot directory
f67285
 # PLYMOUTH_LDD - an optional ldd command that works on foreign binaries
f67285
 # PLYMOUTH_LDD_PATH - optional PATH ldd is run with
f67285
 
f67285
 [ -z "$PLYMOUTH_LDD" ] && PLYMOUTH_LDD="ldd"
f67285
 [ -z "$PLYMOUTH_LDD_PATH" ] && PLYMOUTH_LDD_PATH="$PATH"
2836bb
 [ -z "$PLYMOUTH_LIBEXECDIR" ] && PLYMOUTH_LIBEXECDIR="@PLYMOUTH_LIBEXECDIR@"
2836bb
 [ -z "$PLYMOUTH_DATADIR" ] && PLYMOUTH_DATADIR="@PLYMOUTH_DATADIR@"
2836bb
 [ -z "$PLYMOUTH_PLUGIN_PATH" ] && PLYMOUTH_PLUGIN_PATH="$(plymouth --get-splash-plugin-path)"
2836bb
 [ -z "$PLYMOUTH_LOGO_FILE" ] && PLYMOUTH_LOGO_FILE="@PLYMOUTH_LOGO_FILE@"
2836bb
 [ -n "$PLYMOUTH_THEME_NAME" ] && THEME_OVERRIDE=1
2836bb
 [ -z "$PLYMOUTH_THEME_NAME" ] && PLYMOUTH_THEME_NAME=$(plymouth-set-default-theme)
2836bb
 [ -z "$PLYMOUTH_CONFDIR" ] && PLYMOUTH_CONFDIR="@PLYMOUTH_CONF_DIR@"
2836bb
 [ -z "$PLYMOUTH_POLICYDIR" ] && PLYMOUTH_POLICYDIR="@PLYMOUTH_POLICY_DIR@"
2836bb
 [ -z "$PLYMOUTH_DAEMON_PATH" ] && PLYMOUTH_DAEMON_PATH="@PLYMOUTH_DAEMON_DIR@/plymouthd"
2836bb
 [ -z "$PLYMOUTH_CLIENT_PATH" ] && PLYMOUTH_CLIENT_PATH="@PLYMOUTH_CLIENT_DIR@/plymouth"
2836bb
 [ -z "$SYSTEMD_UNIT_DIR" ] && SYSTEMD_UNIT_DIR="@SYSTEMD_UNIT_DIR@"
2836bb
+[ -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"
2836bb
 
2836bb
 # Generic substring function.  If $2 is in $1, return 0.
2836bb
 strstr() { [ "${1#*$2*}" != "$1" ]; }
2836bb
 
2836bb
 ddebug() {
2836bb
     [ "$verbose" = "true" ] && echo "$@"
2836bb
 }
2836bb
 
2836bb
 # normalize_path <path>
2836bb
 # Prints the normalized path, where it removes any duplicated
2836bb
 # and trailing slashes.
2836bb
 # Example:
2836bb
 # $ normalize_path ///test/test//
2836bb
 # /test/test
2836bb
 normalize_path() {
2836bb
     shopt -q -s extglob
2836bb
     set -- "${1//+(\/)//}"
2836bb
     shopt -q -u extglob
2836bb
     echo "${1%/}"
2836bb
 }
2836bb
 
2836bb
 # convert_abs_rel <from> <to>
2836bb
 # Prints the relative path, when creating a symlink to <to> from <from>.
2836bb
 # Example:
2836bb
 # $ convert_abs_rel /usr/bin/test /bin/test-2
2836bb
 # ../../bin/test-2
2836bb
 # $ ln -s $(convert_abs_rel /usr/bin/test /bin/test-2) /usr/bin/test
2836bb
 convert_abs_rel() {
2836bb
     local __current __absolute __abssize __cursize __newpath
2836bb
     local -i __i __level
f67285
@@ -434,59 +435,77 @@ if [ $THEME_OVERRIDE ]; then
2836bb
     conf=$INITRDDIR/${PLYMOUTH_CONFDIR}/plymouthd.conf
f67285
     echo "modifying plymouthd.conf: Theme=$PLYMOUTH_THEME_NAME" >&2
2836bb
     # make sure the section and key exist so we can modify them
2836bb
     grep -q "^ *\[Daemon\]" $conf || echo "[Daemon]" >> $conf
2836bb
     grep -q "^ *Theme *=" $conf || echo "Theme=fade-in" >> $conf
2836bb
     sed -i "s/^ *Theme *=.*/# theme modified by plymouth-populate-initrd\nTheme=$PLYMOUTH_THEME_NAME/" $conf
2836bb
 fi
2836bb
 
f67285
 PLYMOUTH_MODULE_NAME=$(grep "ModuleName *= *" ${PLYMOUTH_SYSROOT}${PLYMOUTH_DATADIR}/plymouth/themes/${PLYMOUTH_THEME_NAME}/${PLYMOUTH_THEME_NAME}.plymouth | sed 's/ModuleName *= *//')
f67285
 PLYMOUTH_THEME_DIR="${PLYMOUTH_DATADIR}/plymouth/themes/${PLYMOUTH_THEME_NAME}"
f67285
 PLYMOUTH_IMAGE_DIR=$(grep "ImageDir *= *" ${PLYMOUTH_SYSROOT}${PLYMOUTH_THEME_DIR}/${PLYMOUTH_THEME_NAME}.plymouth | sed 's/ImageDir *= *//')
2836bb
 
f67285
 if [ ! -f ${PLYMOUTH_SYSROOT}${PLYMOUTH_PLUGIN_PATH}/${PLYMOUTH_MODULE_NAME}.so ]; then
f67285
     echo "The default plymouth plugin (${PLYMOUTH_MODULE_NAME}) doesn't exist" >&2
2836bb
     exit 1
2836bb
 fi
2836bb
 
2836bb
 inst ${PLYMOUTH_PLUGIN_PATH}/${PLYMOUTH_MODULE_NAME}.so $INITRDDIR
2836bb
 
f67285
 [ -f "${PLYMOUTH_SYSROOT}${PLYMOUTH_PLUGIN_PATH}/renderers/drm.so" ] && inst ${PLYMOUTH_PLUGIN_PATH}/renderers/drm.so $INITRDDIR
2836bb
 inst ${PLYMOUTH_PLUGIN_PATH}/renderers/frame-buffer.so $INITRDDIR
2836bb
 
f67285
 if [ -d "${PLYMOUTH_SYSROOT}${PLYMOUTH_THEME_DIR}" ]; then
f67285
      inst_recur "${PLYMOUTH_THEME_DIR}"
f67285
 fi
f67285
 
f67285
 if [ "${PLYMOUTH_IMAGE_DIR}" != "${PLYMOUTH_THEME_DIR}" -a -d "${PLYMOUTH_SYSROOT}${PLYMOUTH_IMAGE_DIR}" ]; then
f67285
      inst_recur "${PLYMOUTH_IMAGE_DIR}"
2836bb
 fi
2836bb
 
f67285
-if [ -L ${PLYMOUTH_SYSROOT}${PLYMOUTH_DATADIR}/plymouth/themes/default.plymouth ]; then
f67285
-    cp -a ${PLYMOUTH_SYSROOT}${PLYMOUTH_DATADIR}/plymouth/themes/default.plymouth $INITRDDIR${PLYMOUTH_DATADIR}/plymouth/themes
2836bb
+fonts=""
2836bb
+needs_graphics="$(find ${INITRDDIR} -name 'libply-splash-graphics.so*' -print -quit | grep -q libply-splash-graphics.so && echo -n 1)"
2836bb
+
2836bb
+if [ -n "$needs_graphics" ]; then
2836bb
+    for lang in $SUPPORTED_LANGUAGES; do
2836bb
+        font=$(fc-match "":lang="$lang" file | awk -F= '{ print $2}')
2836bb
+        echo $fonts | grep -q "$font" && continue
2836bb
+        fonts="$fonts $font"
2836bb
+    done
2836bb
+
2836bb
+    if [ -n "$fonts" ]; then
2836bb
+        inst ${PLYMOUTH_PLUGIN_PATH}/label.so $INITRDDIR
2836bb
+        for font in $fonts; do
2836bb
+            inst $font $INITRDDIR
2836bb
+        done
2836bb
+    fi
2836bb
+fi
2836bb
+
f67285
+if [ -L ${PLYMOUTH_DATADIR}/plymouth/themes/default.plymouth ]; then
f67285
+    cp -a ${PLYMOUTH_DATADIR}/plymouth/themes/default.plymouth $INITRDDIR${PLYMOUTH_DATADIR}/plymouth/themes
2836bb
 fi
2836bb
 
f67285
 if [ -n "$SYSTEMD_UNIT_DIR" -a -d "${PLYMOUTH_SYSROOT}$SYSTEMD_UNIT_DIR" ]; then
2836bb
     inst $SYSTEMD_UNIT_DIR/systemd-ask-password-plymouth.path $INITRDDIR
2836bb
     inst $SYSTEMD_UNIT_DIR/systemd-ask-password-plymouth.service $INITRDDIR
2836bb
 
2836bb
     inst $SYSTEMD_UNIT_DIR/plymouth-switch-root.service $INITRDDIR
2836bb
     inst $SYSTEMD_UNIT_DIR/plymouth-start.service $INITRDDIR
2836bb
     inst $SYSTEMD_UNIT_DIR/plymouth-quit.service $INITRDDIR
2836bb
     inst $SYSTEMD_UNIT_DIR/plymouth-quit-wait.service $INITRDDIR
2836bb
     inst $SYSTEMD_UNIT_DIR/plymouth-reboot.service $INITRDDIR
2836bb
     inst $SYSTEMD_UNIT_DIR/plymouth-kexec.service $INITRDDIR
2836bb
     inst $SYSTEMD_UNIT_DIR/plymouth-poweroff.service $INITRDDIR
2836bb
     inst $SYSTEMD_UNIT_DIR/plymouth-halt.service $INITRDDIR
2836bb
 
2836bb
     inst $SYSTEMD_UNIT_DIR/initrd-switch-root.target.wants/plymouth-switch-root.service $INITRDDIR
2836bb
     inst $SYSTEMD_UNIT_DIR/initrd-switch-root.target.wants/plymouth-start.service $INITRDDIR
2836bb
     inst $SYSTEMD_UNIT_DIR/sysinit.target.wants/plymouth-start.service $INITRDDIR
2836bb
     inst $SYSTEMD_UNIT_DIR/multi-user.target.wants/plymouth-quit.service $INITRDDIR
2836bb
     inst $SYSTEMD_UNIT_DIR/multi-user.target.wants/plymouth-quit-wait.service $INITRDDIR
2836bb
     inst $SYSTEMD_UNIT_DIR/reboot.target.wants/plymouth-reboot.service $INITRDDIR
2836bb
     inst $SYSTEMD_UNIT_DIR/kexec.target.wants/plymouth-kexec.service $INITRDDIR
2836bb
     inst $SYSTEMD_UNIT_DIR/poweroff.target.wants/plymouth-poweroff.service $INITRDDIR
2836bb
     inst $SYSTEMD_UNIT_DIR/halt.target.wants/plymouth-halt.service $INITRDDIR
2836bb
 fi
2836bb
 
2836bb
 # vim:ts=8:sw=4:sts=4:et
2836bb
-- 
2836bb
2.21.0
2836bb