From 65550c2d5d465f70e90cbe1f40c3520a243473f5 Mon Sep 17 00:00:00 2001 From: Ray Strode Date: Tue, 23 Mar 2010 16:35:42 -0400 Subject: [PATCH 1/4] [configure] drop --with-default-plugin-link It's an old interface that I don't think anyone is using. --- configure.ac | 10 ---------- src/plugins/splash/Makefile.am | 5 ----- 2 files changed, 15 deletions(-) diff --git a/configure.ac b/configure.ac index 70b3c684..a8ac587d 100644 --- a/configure.ac +++ b/configure.ac @@ -110,16 +110,6 @@ AC_SUBST(background_start_color) AC_ARG_WITH(background-end-color-stop, AS_HELP_STRING([--with-background-end-color-stop],[first color end in background gradients used by boot splash plugins]),background_end_color=${withval},background_end_color=0x3a362f) AC_SUBST(background_end_color) -AC_ARG_WITH(default-plugin, AS_HELP_STRING([--with-default-plugin=fade-throbber],[Plugin to use by default]),default_plugin_name=${withval},default_plugin_name=fade-throbber) -AM_CONDITIONAL(ADD_DEFAULT_PLUGIN_LINK, - [test "$default_plugin_name" = "spinfinity" \ - -o "$default_plugin_name" = "fade-throbber" \ - -o "$default_plugin_name" = "text" \ - -o "$default_plugin_name" = "glow" \ - -o "$default_plugin_name" = "solar" \ - -o "$default_plugin_name" = "details"]) -AC_SUBST(default_plugin_name) - AC_ARG_WITH(release-file, AS_HELP_STRING([--with-release-file=],[Release File to use to detect distribution (by default /etc/system-reelase)]),RELEASE_FILE=${withval},RELEASE_FILE=/etc/system-release) AC_SUBST(RELEASE_FILE) diff --git a/src/plugins/splash/Makefile.am b/src/plugins/splash/Makefile.am index 3510531d..02f94faf 100644 --- a/src/plugins/splash/Makefile.am +++ b/src/plugins/splash/Makefile.am @@ -1,7 +1,2 @@ SUBDIRS = throbgress fade-throbber text details space-flares two-step script MAINTAINERCLEANFILES = Makefile.in - -if ADD_DEFAULT_PLUGIN_LINK -install-data-hook: - (cd $(DESTDIR)$(libdir)/plymouth; ln -sf $(default_plugin_name).so default.so) -endif From 27562c4f69fd084afc2d5961005c7cc2dbf6995c Mon Sep 17 00:00:00 2001 From: Ray Strode Date: Tue, 23 Mar 2010 16:46:56 -0400 Subject: [PATCH 2/4] [main] Try getting default theme from config file Right now we figure out the default theme via a symlink. This apprach is very simple, but is also a little cumbersome. It means as the default theme is changed around we have to move the symlink around. The symlink is in /usr. We really shouldn't be mucking with /usr when changing defaults. This commit checks the filesystem for two config files: /usr/share/plymouth/plymouthd.defaults and /etc/plymouth/plymouthd.conf The first one is for distributions to use. This is how they can manage which splash to show from release to release. The second one is for system administrators. This is how they can override distribution policy. We don't actually ship these files yet. In the mean time, (and even after for the forseeable future) the old symlink method will still work. --- configure.ac | 6 ++++ src/Makefile.am | 4 ++- src/main.c | 82 +++++++++++++++++++++++++++++++++++++++++++++++-- 3 files changed, 88 insertions(+), 4 deletions(-) diff --git a/configure.ac b/configure.ac index a8ac587d..b78e21f9 100644 --- a/configure.ac +++ b/configure.ac @@ -204,6 +204,12 @@ AS_AC_EXPAND(PLYMOUTH_THEME_PATH, $plymouththemedir) plymouthplugindir=$libdir/plymouth/ AS_AC_EXPAND(PLYMOUTH_PLUGIN_PATH, $plymouthplugindir) +plymouthpolicydir=$datadir/plymouth/ +AS_AC_EXPAND(PLYMOUTH_POLICY_DIR, $plymouthpolicydir) + +plymouthconfdir=$sysconfdir/plymouth/ +AS_AC_EXPAND(PLYMOUTH_CONF_DIR, $plymouthconfdir) + AS_AC_EXPAND(PLYMOUTH_LIBDIR, $libdir) AS_AC_EXPAND(PLYMOUTH_LIBEXECDIR, $libexecdir) AS_AC_EXPAND(PLYMOUTH_DATADIR, $datadir) diff --git a/src/Makefile.am b/src/Makefile.am index 3f6e4ff5..249a6940 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -13,7 +13,9 @@ plymouthdbin_PROGRAMS = plymouthd plymouthd_CFLAGS = $(PLYMOUTH_CFLAGS) \ -DPLYMOUTH_PLUGIN_PATH=\"$(PLYMOUTH_PLUGIN_PATH)\" \ - -DPLYMOUTH_THEME_PATH=\"$(PLYMOUTH_THEME_PATH)/\" + -DPLYMOUTH_THEME_PATH=\"$(PLYMOUTH_THEME_PATH)/\" \ + -DPLYMOUTH_POLICY_DIR=\"$(PLYMOUTH_POLICY_DIR)/\" \ + -DPLYMOUTH_CONF_DIR=\"$(PLYMOUTH_CONF_DIR)/\" plymouthd_LDADD = $(PLYMOUTH_LIBS) libply/libply.la libply-splash-core/libply-splash-core.la plymouthd_SOURCES = \ ply-boot-protocol.h \ diff --git a/src/main.c b/src/main.c index ac10a789..b823f8b4 100644 --- a/src/main.c +++ b/src/main.c @@ -111,6 +111,8 @@ typedef struct char *kernel_console_tty; char *override_splash_path; + char *system_default_splash_path; + char *distribution_default_splash_path; const char *default_tty; int number_of_errors; @@ -213,6 +215,64 @@ find_override_splash (state_t *state) } } +static void +find_system_default_splash (state_t *state) +{ + ply_key_file_t *key_file; + char *splash_string; + + if (state->system_default_splash_path != NULL) + return; + + ply_trace ("Trying to load " PLYMOUTH_CONF_DIR "plymouthd.conf"); + key_file = ply_key_file_new (PLYMOUTH_CONF_DIR "plymouthd.conf"); + + if (ply_key_file_load (key_file)) + { + ply_trace ("failed to load " PLYMOUTH_CONF_DIR "plymouthd.conf"); + ply_key_file_free (key_file); + return; + } + + splash_string = ply_key_file_get_value (key_file, "Daemon", "Theme"); + + ply_trace ("System default splash is configured to be '%s'", splash_string); + + asprintf (&state->override_splash_path, + PLYMOUTH_THEME_PATH "%s/%s.plymouth", + splash_string, splash_string); + free (splash_string); +} + +static void +find_distribution_default_splash (state_t *state) +{ + ply_key_file_t *key_file; + char *splash_string; + + if (state->distribution_default_splash_path != NULL) + return; + + ply_trace ("Trying to load " PLYMOUTH_POLICY_DIR "plymouthd.defaults"); + key_file = ply_key_file_new (PLYMOUTH_POLICY_DIR "plymouthd.defaults"); + + if (ply_key_file_load (key_file)) + { + ply_trace ("failed to load " PLYMOUTH_POLICY_DIR "plymouthd.conf"); + ply_key_file_free (key_file); + return; + } + + splash_string = ply_key_file_get_value (key_file, "Daemon", "Theme"); + + ply_trace ("Distribution default splash is configured to be '%s'", splash_string); + + asprintf (&state->override_splash_path, + PLYMOUTH_THEME_PATH "%s/%s.plymouth", + splash_string, splash_string); + free (splash_string); +} + static void show_default_splash (state_t *state) { @@ -223,21 +283,37 @@ show_default_splash (state_t *state) find_override_splash (state); if (state->override_splash_path != NULL) { - ply_trace ("Starting override splash at '%s'", state->override_splash_path); + ply_trace ("Trying override splash at '%s'", state->override_splash_path); state->boot_splash = start_boot_splash (state, state->override_splash_path); } + find_system_default_splash (state); if (state->boot_splash == NULL) { - ply_trace ("Starting default splash"); + ply_trace ("Trying system default splash"); + state->boot_splash = start_boot_splash (state, + state->system_default_splash_path); + } + + find_distribution_default_splash (state); + if (state->boot_splash == NULL) + { + ply_trace ("Trying distribution default splash"); + state->boot_splash = start_boot_splash (state, + state->distribution_default_splash_path); + } + + if (state->boot_splash == NULL) + { + ply_trace ("Trying old scheme for default splash"); state->boot_splash = start_boot_splash (state, PLYMOUTH_THEME_PATH "default.plymouth"); } if (state->boot_splash == NULL) { - ply_trace ("Could not start graphical splash screen," + ply_trace ("Could not start default splash screen," "showing text splash screen"); state->boot_splash = start_boot_splash (state, PLYMOUTH_THEME_PATH "text/text.plymouth"); From 5baed15f096fa9457a4f1e0f2be36ee155099fe8 Mon Sep 17 00:00:00 2001 From: Ray Strode Date: Tue, 23 Mar 2010 17:48:48 -0400 Subject: [PATCH 3/4] [set-default-theme] Write plymouthd.conf instead of symlink Now that the daemon looks for the default theme in configuration files, we should make plymouth-set-default-theme write the configuration files instead of doing symlinks. That's what this commit does. --- scripts/plymouth-set-default-theme.in | 43 ++++++++++++++++++--------- 1 file changed, 29 insertions(+), 14 deletions(-) diff --git a/scripts/plymouth-set-default-theme.in b/scripts/plymouth-set-default-theme.in index 21549726..732f8ad2 100755 --- a/scripts/plymouth-set-default-theme.in +++ b/scripts/plymouth-set-default-theme.in @@ -4,6 +4,8 @@ set -e [ -z "$PLYMOUTH_LIBEXECDIR" ] && PLYMOUTH_LIBEXECDIR="@PLYMOUTH_LIBEXECDIR@" [ -z "$PLYMOUTH_DATADIR" ] && PLYMOUTH_DATADIR="@PLYMOUTH_DATADIR@" +[ -z "$PLYMOUTH_CONFDIR" ] && PLYMOUTH_CONFDIR="@PLYMOUTH_CONF_DIR@" +[ -z "$PLYMOUTH_POLICYDIR" ] && PLYMOUTH_POLICYDIR="@PLYMOUTH_POLICY_DIR@" if [ -z "$PLYMOUTH_PLUGIN_PATH" ]; then if [ -z "$LIB" ]; then PLYMOUTH_PLUGIN_PATH="$(plymouth --get-splash-plugin-path)" @@ -40,14 +42,27 @@ function list_themes () done } +function read_theme_name_from_file () +{ + echo $(grep -v '^#' $1 2> /dev/null | + awk ' + BEGIN { + RS="[[][[:blank:]]*[^[:space:]]+[:blank:]*[]\n]"; + FS="[=[:space:]]+"; + OFS=""; + ORS="" + } + $1 ~/Theme/ { print $2 } + ') +} + function get_default_theme () { - THEME_NAME=$(basename $(readlink ${PLYMOUTH_DATADIR}/plymouth/themes/default.plymouth) .plymouth) - if [ "$THEME_NAME" = ".plymouth" ]; then - $0 --reset - THEME_NAME=$(basename $(readlink ${PLYMOUTH_DATADIR}/plymouth/themes/default.plymouth) .plymouth) + THEME_NAME=$(read_theme_name_from_file ${PLYMOUTH_CONFDIR}/plymouthd.conf) + if [ -z "$THEME_NAME" ]; then + THEME_NAME=$(read_theme_name_from_file ${PLYMOUTH_POLICYDIR}/plymouthd.defaults) fi - [ "$THEME_NAME" = ".so" ] || echo $THEME_NAME && exit 1 + [ -z "$THEME_NAME" ] || echo $THEME_NAME && exit 1 } DO_RESET=0 @@ -144,11 +159,9 @@ if [ `id -u` -ne 0 ]; then fi if [ $DO_RESET -ne 0 ]; then - THEME_NAME=$(basename $(ls -1 -t ${PLYMOUTH_DATADIR}/plymouth/themes/*/*.plymouth 2> /dev/null | tail -n 1) .plymouth) - if [ $THEME_NAME = .plymouth ]; then - rm -f ${PLYMOUTH_DATADIR}/plymouth/themes/default.plymouth - exit 0 - fi + [ -f ${PLYMOUTH_CONFDIR}/plymouthd.conf ] || exit 0 + sed -i -e '/^Theme[[:blank:]]*=.*/d' ${PLYMOUTH_CONFDIR}/plymouthd.conf + exit $? fi if [ ! -e ${PLYMOUTH_DATADIR}/plymouth/themes/${THEME_NAME}/${THEME_NAME}.plymouth ]; then @@ -163,8 +176,10 @@ if [ ! -e ${PLYMOUTH_PLUGIN_PATH}${MODULE_NAME}.so ]; then exit 1 fi -(cd ${PLYMOUTH_DATADIR}/plymouth/themes; - ln -sf ${THEME_NAME}/${THEME_NAME}.plymouth default.plymouth && \ - ([ $DO_INITRD_REBUILD -ne 0 ] && \ - ${PLYMOUTH_LIBEXECDIR}/plymouth/plymouth-update-initrd) || :) +[ -d ${PLYMOUTH_CONFDIR} ] || mkdir -p ${PLYMOUTH_CONFDIR} +fgrep -q '[Daemon]' ${PLYMOUTH_CONFDIR}/plymouthd.conf 2> /null || echo '[Daemon]' >> ${PLYMOUTH_CONFDIR}/plymouthd.conf +sed -i -e '/^Theme[[:blank:]]*=.*/d' ${PLYMOUTH_CONFDIR}/plymouthd.conf +sed -i -e "s/\([[]Daemon[]]\)\n*/\1\nTheme=${THEME_NAME}/" ${PLYMOUTH_CONFDIR}/plymouthd.conf + +[ $DO_INITRD_REBUILD -ne 0 ] && (${PLYMOUTH_LIBEXECDIR}/plymouth/plymouth-update-initrd) From cf766763f26ad0bb8e001a9ecf65b00f4c766e3c Mon Sep 17 00:00:00 2001 From: Ray Strode Date: Tue, 23 Mar 2010 17:54:32 -0400 Subject: [PATCH 4/4] [daemon] Ship default configuration files This commit adds plymouthd.defaults and plymouthd.conf. The former is for distributions to override, and the latter is for administrators to change. --- scripts/plymouth-populate-initrd.in | 4 ++++ src/plymouthd.conf | 3 +++ src/plymouthd.defaults | 8 ++++++++ 3 files changed, 15 insertions(+) create mode 100644 src/plymouthd.conf create mode 100644 src/plymouthd.defaults diff --git a/scripts/plymouth-populate-initrd.in b/scripts/plymouth-populate-initrd.in index 0214ee3c..7f0c3416 100755 --- a/scripts/plymouth-populate-initrd.in +++ b/scripts/plymouth-populate-initrd.in @@ -7,6 +7,8 @@ [ -z "$PLYMOUTH_PLUGIN_PATH" ] && PLYMOUTH_PLUGIN_PATH="$(plymouth --get-splash-plugin-path)" [ -z "$PLYMOUTH_LOGO_FILE" ] && PLYMOUTH_LOGO_FILE="@logofile@" [ -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@" if [ -z "$PLYMOUTH_POPULATE_SOURCE_FUNCTIONS" ]; then @@ -78,6 +80,8 @@ inst ${PLYMOUTH_DATADIR}/plymouth/themes/details/details.plymouth $INITRDDIR inst ${PLYMOUTH_PLUGIN_PATH}/details.so $INITRDDIR inst ${PLYMOUTH_LOGO_FILE} $INITRDDIR inst @RELEASE_FILE@ $INITRDDIR +inst ${PLYMOUTH_POLICYDIR}/plymouthd.defaults $INITRDDIR +inst ${PLYMOUTH_CONFDIR}/plymouthd.conf $INITRDDIR if [ -z "$PLYMOUTH_THEME_NAME" ]; then echo "No default plymouth plugin is set" > /dev/stderr diff --git a/src/plymouthd.conf b/src/plymouthd.conf new file mode 100644 index 00000000..66a92d21 --- /dev/null +++ b/src/plymouthd.conf @@ -0,0 +1,3 @@ +# Administrator customizations go in this file +#[Daemon] +#Theme=fade-in diff --git a/src/plymouthd.defaults b/src/plymouthd.defaults new file mode 100644 index 00000000..a1654918 --- /dev/null +++ b/src/plymouthd.defaults @@ -0,0 +1,8 @@ +# Distribution defaults. Changes to this file will get overwritten during +# upgrades. +[Daemon] +Theme=fade-in +Foo=bar + +[z] +ffoo=yo