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

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