From jprvita at gmail.com Fri Apr 7 14:01:15 2017 From: jprvita at gmail.com (=?UTF-8?q?Jo=C3=A3o=20Paulo=20Rechi=20Vita?=) Date: Fri, 7 Apr 2017 10:01:15 -0400 Subject: [PATCH 0/2] Look for config and theme in runtime dir first Message-ID: <20170407140117.6062-1-jprvita@endlessm.com> As I have mentioned in a previous email (subject: "Shipping a theme only in the initramfs"), at Endless we want to have boot splash animation customization in a self-contained initrd. For that to work, we need to make it available after the initrd is gone as well, because 1) plymouth may show the splash only after the switch root has already happened; and 2) we want to use the same theme for the shutdown splash animation. To achieve that we ship a service in the initrd which copy the custom config file and theme (if they are found) to /run/plymouth. This patchset makes plymouth look for these files in /run before checking their default locations. I'm sending these for feedback and in case there is interest in having this mechanism upstream. I can send the service files as well if there is interest, but in that case we'll need to agree on what is a good generic trigger mechanism (we ship these in a Endless-specific path, and use that as the trigger). João Paulo Rechi Vita (2): main: Look for theme in runtime dir first main: Look for config in runtime dir first configure.ac | 3 +++ src/Makefile.am | 3 ++- src/main.c | 29 ++++++++++++++++++++++++----- 3 files changed, 29 insertions(+), 6 deletions(-) -- 2.11.0 From jprvita at gmail.com Fri Apr 7 14:01:17 2017 From: jprvita at gmail.com (=?UTF-8?q?Jo=C3=A3o=20Paulo=20Rechi=20Vita?=) Date: Fri, 7 Apr 2017 10:01:17 -0400 Subject: [PATCH 2/2] main: Look for config in runtime dir first In-Reply-To: <20170407140117.6062-1-jprvita@endlessm.com> References: <20170407140117.6062-1-jprvita@endlessm.com> Message-ID: <20170407140117.6062-3-jprvita@endlessm.com> This makes possible to support shipping a self-contained initrd which completely overrides the plymouth theme. The configuration and theme are copied to /run by a custom service before plymouth starts, so plymouth can load the correct config from /run both during bootup and shutdown. This commit changes the routine which resolves plymouth.defaults' path, to have it look first in plymouth's runtime directory. Signed-off-by: João Paulo Rechi Vita https://phabricator.endlessm.com/T15989 --- src/main.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/main.c b/src/main.c index 50d1921..eeb4e20 100644 --- a/src/main.c +++ b/src/main.c @@ -488,9 +488,12 @@ find_distribution_default_splash (state_t *state) if (state->distribution_default_splash_path != NULL) return; - if (!load_settings (state, PLYMOUTH_POLICY_DIR "plymouthd.defaults", &state->distribution_default_splash_path)) { - ply_trace ("failed to load " PLYMOUTH_POLICY_DIR "plymouthd.defaults"); - return; + if (!load_settings (state, PLYMOUTH_RUNTIME_DIR "/plymouthd.defaults", &state->distribution_default_splash_path)) { + ply_trace ("failed to load " PLYMOUTH_RUNTIME_DIR "/plymouthd.defaults, trying " PLYMOUTH_POLICY_DIR); + if (!load_settings (state, PLYMOUTH_POLICY_DIR "plymouthd.defaults", &state->distribution_default_splash_path)) { + ply_trace ("failed to load " PLYMOUTH_POLICY_DIR "plymouthd.defaults"); + return; + } } ply_trace ("Distribution default theme file is '%s'", state->distribution_default_splash_path); -- 2.11.0 From jprvita at gmail.com Fri Apr 7 14:01:16 2017 From: jprvita at gmail.com (=?UTF-8?q?Jo=C3=A3o=20Paulo=20Rechi=20Vita?=) Date: Fri, 7 Apr 2017 10:01:16 -0400 Subject: [PATCH 1/2] main: Look for theme in runtime dir first In-Reply-To: <20170407140117.6062-1-jprvita@endlessm.com> References: <20170407140117.6062-1-jprvita@endlessm.com> Message-ID: <20170407140117.6062-2-jprvita@endlessm.com> When a theme is shipped exclusively in the initrd, plymouth will not be able to load is if it starts the boot splash after the bootup process already switched from the initrd. One way to make it work is to copy the theme to plymouth's runtime directory in /run, which is preserved during switch root. This commit changes the routine which resolves a theme's path to have it look first in themes/ under plymouth's runtime directory. Signed-off-by: João Paulo Rechi Vita https://phabricator.endlessm.com/T15989 --- configure.ac | 3 +++ src/Makefile.am | 3 ++- src/main.c | 20 ++++++++++++++++++-- 3 files changed, 23 insertions(+), 3 deletions(-) diff --git a/configure.ac b/configure.ac index 97cdfa0..87035c1 100644 --- a/configure.ac +++ b/configure.ac @@ -269,6 +269,9 @@ PLYMOUTH_CFLAGS="$PLYMOUTH_CFLAGS $WARN_CFLAGS" plymouththemedir=$datadir/plymouth/themes AS_AC_EXPAND(PLYMOUTH_THEME_PATH, $plymouththemedir) +plymouthruntimethemedir=$plymouthruntimedir/themes +AS_AC_EXPAND(PLYMOUTH_RUNTIME_THEME_PATH, $plymouthruntimethemedir) + plymouthplugindir=$libdir/plymouth/ AS_AC_EXPAND(PLYMOUTH_PLUGIN_PATH, $plymouthplugindir) diff --git a/src/Makefile.am b/src/Makefile.am index ceb72ba..95ed019 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -20,7 +20,8 @@ plymouthd_CFLAGS = $(PLYMOUTH_CFLAGS) \ -DPLYMOUTH_THEME_PATH=\"$(PLYMOUTH_THEME_PATH)/\" \ -DPLYMOUTH_POLICY_DIR=\"$(PLYMOUTH_POLICY_DIR)/\" \ -DPLYMOUTH_RUNTIME_DIR=\"$(PLYMOUTH_RUNTIME_DIR)\" \ - -DPLYMOUTH_CONF_DIR=\"$(PLYMOUTH_CONF_DIR)/\" + -DPLYMOUTH_CONF_DIR=\"$(PLYMOUTH_CONF_DIR)/\" \ + -DPLYMOUTH_RUNTIME_THEME_PATH=\"$(PLYMOUTH_RUNTIME_THEME_PATH)/\" 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 02e0082..50d1921 100644 --- a/src/main.c +++ b/src/main.c @@ -311,8 +311,16 @@ load_settings (state_t *state, goto out; asprintf (theme_path, - PLYMOUTH_THEME_PATH "%s/%s.plymouth", + PLYMOUTH_RUNTIME_THEME_PATH "%s/%s.plymouth", splash_string, splash_string); + ply_trace ("Checking if %s exists", *theme_path); + if (!ply_file_exists (*theme_path)) { + ply_trace ("%s not found, fallbacking to " PLYMOUTH_THEME_PATH, + *theme_path); + asprintf (theme_path, + PLYMOUTH_THEME_PATH "%s/%s.plymouth", + splash_string, splash_string); + } if (isnan (state->splash_delay)) { const char *delay_string; @@ -427,8 +435,16 @@ find_override_splash (state_t *state) ply_trace ("Splash is configured to be '%*.*s'", length, length, splash_string); asprintf (&state->override_splash_path, - PLYMOUTH_THEME_PATH "%*.*s/%*.*s.plymouth", + PLYMOUTH_RUNTIME_THEME_PATH "%*.*s/%*.*s.plymouth", length, length, splash_string, length, length, splash_string); + ply_trace ("Checking if %s exists", state->override_splash_path); + if (!ply_file_exists (state->override_splash_path)) { + ply_trace ("%s not found, fallbacking to " PLYMOUTH_THEME_PATH, + state->override_splash_path); + asprintf (&state->override_splash_path, + PLYMOUTH_THEME_PATH "%*.*s/%*.*s.plymouth", + length, length, splash_string, length, length, splash_string); + } } if (isnan (state->splash_delay)) { -- 2.11.0 From jprvita at gmail.com Fri Apr 7 14:08:05 2017 From: jprvita at gmail.com (=?UTF-8?Q?Jo=C3=A3o_Paulo_Rechi_Vita?=) Date: Fri, 7 Apr 2017 10:08:05 -0400 Subject: [PATCH 1/2] main: Look for theme in runtime dir first In-Reply-To: <20170407140117.6062-2-jprvita@endlessm.com> References: <20170407140117.6062-1-jprvita@endlessm.com> <20170407140117.6062-2-jprvita@endlessm.com> Message-ID: On Fri, Apr 7, 2017 at 10:01 AM, João Paulo Rechi Vita wrote: (...) > > https://phabricator.endlessm.com/T15989 Sorry, I forgot to remove this link before sending. Feel free to drop it from both patches, as this is only accessible to Endless employees. -- João Paulo Rechi Vita http://about.me/jprvita From halfline at gmail.com Fri Apr 7 15:56:32 2017 From: halfline at gmail.com (Ray Strode) Date: Fri, 7 Apr 2017 11:56:32 -0400 Subject: [PATCH 0/2] Look for config and theme in runtime dir first In-Reply-To: <20170407140117.6062-1-jprvita@endlessm.com> References: <20170407140117.6062-1-jprvita@endlessm.com> Message-ID: Hey, > As I have mentioned in a previous email (subject: "Shipping a theme only in the > initramfs"), at Endless we want to have boot splash animation customization in > a self-contained initrd. For that to work, we need to make it available after > the initrd is gone as well, because 1) plymouth may show the splash only after > the switch root has already happened; and 2) we want to use the same theme for > the shutdown splash animation. Sorry for not replying to that. I read the message and then took a mental note to reply and forgot. > I'm sending these for feedback and in case there is interest in having this > mechanism upstream. I've pushed this. At some point I think it would make sense to switch to a systemd style conf_files_list/ config_parse api where higher precedence dirs override lower precedence files on a per-key basis, but that's really neither here nor there. thanks for the patch Ray