From cf0119ed4aa4e3d816077a6f6312172ef643526b Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Fri, 16 Apr 2021 10:20:47 +0200 Subject: [PATCH] [initcpiocfg][plymouthcfg] Consistent find-plymouth code - drop the debugging line because that has already been logged by the call to `runCommand()` that backs `target_env_call()`. - use the same (top-level) function rather than having a function and elsewhere a very-similar method. --- src/modules/initcpiocfg/main.py | 5 ++--- src/modules/plymouthcfg/main.py | 18 +++++++++++------- 2 files changed, 13 insertions(+), 10 deletions(-) diff --git a/src/modules/initcpiocfg/main.py b/src/modules/initcpiocfg/main.py index cdfeadd0f..4fb0923cd 100644 --- a/src/modules/initcpiocfg/main.py +++ b/src/modules/initcpiocfg/main.py @@ -92,6 +92,7 @@ def write_mkinitcpio_lines(hooks, modules, files, root_mount_point): with open(path, "w") as mkinitcpio_file: mkinitcpio_file.write("\n".join(mklins) + "\n") + def detect_plymouth(): """ Checks existence (runnability) of plymouth in the target system. @@ -99,10 +100,8 @@ def detect_plymouth(): @return True if plymouth exists in the target, False otherwise """ # Used to only check existence of path /usr/bin/plymouth in target - isPlymouth = target_env_call(["sh", "-c", "which plymouth"]) - debug("which plymouth exit code: {!s}".format(isPlymouth)) + return target_env_call(["sh", "-c", "which plymouth"]) == 0 - return isPlymouth == 0 def modify_mkinitcpio_conf(partitions, root_mount_point): """ diff --git a/src/modules/plymouthcfg/main.py b/src/modules/plymouthcfg/main.py index c51314e7f..5e66fce67 100644 --- a/src/modules/plymouthcfg/main.py +++ b/src/modules/plymouthcfg/main.py @@ -27,6 +27,16 @@ def pretty_name(): return _("Configure Plymouth theme") +def detect_plymouth(): + """ + Checks existence (runnability) of plymouth in the target system. + + @return True if plymouth exists in the target, False otherwise + """ + # Used to only check existence of path /usr/bin/plymouth in target + return target_env_call(["sh", "-c", "which plymouth"]) == 0 + + class PlymouthController: def __init__(self): @@ -42,14 +52,8 @@ class PlymouthController: plymouth_theme + '|', "-i", "/etc/plymouth/plymouthd.conf"]) - def detect(self): - isPlymouth = target_env_call(["sh", "-c", "which plymouth"]) - debug("which plymouth exit code: {!s}".format(isPlymouth)) - - return isPlymouth - def run(self): - if self.detect() == 0: + if detect_plymouth(): if (("plymouth_theme" in libcalamares.job.configuration) and (libcalamares.job.configuration["plymouth_theme"] is not None)): self.setTheme()