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

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