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