GNU bug report logs - #70148
[PATCH] guix-install.sh: Add daemonize to requirements.

Previous Next

Package: guix-patches;

Reported by: Richard Sent <richard <at> freakingpenguin.com>

Date: Tue, 2 Apr 2024 16:23:01 UTC

Severity: normal

Tags: patch

Done: Ludovic Courtès <ludo <at> gnu.org>

Bug is archived. No further changes may be made.

Full log


Message #20 received at 70148 <at> debbugs.gnu.org (full text, mbox):

From: Richard Sent <richard <at> freakingpenguin.com>
To: 70148 <at> debbugs.gnu.org
Cc: ludo <at> gnu.org, Richard Sent <richard <at> freakingpenguin.com>,
 zimon.toutoune <at> gmail.com
Subject: [PATCH v2] guix-install.sh: Add unique requirement for sysv init
 system
Date: Tue, 28 May 2024 20:36:06 -0400
This improves the installer's ability to detect that all requirements are
present regardless of init system. It also avoids performing the requirement
check twice (printing excessively to the console) and provides a framework for
adding new init system specific requirements if it's needed in the future.

* etc/guix-install.sh (add_init_sys_require): Create.
(SYSV_INIT_REQUIRE): Create.
(main_install): Reorder installer steps so all requirements are checked in one
pass.

Change-Id: Ic541c1b90499d504642b7ab4ae595501b1a37b0d
---
Hi all,

Here's an updated patch that is more selective about only checking for
dependencies when it's required. It might be a touch overengineered,
but I felt this was a better solution compared to hardcoding a
daemonize requirement check in chk_init_sys or similar.

I wanted to avoid calling chk_require twice. Because chk_require
outputs to the console, calling it multiple times will either a) print
multiple "verification of blah blah blah" messages to the user or b)
cause the user to fix the generic requirements, then need to fix init
system specific requirements as a two step process.

If it's ever relevant, this patch will make it quite easy to add
additional checks for specific init systems.

 etc/guix-install.sh | 22 +++++++++++++++++++++-
 1 file changed, 21 insertions(+), 1 deletion(-)

diff --git a/etc/guix-install.sh b/etc/guix-install.sh
index 82accfd5d5..09a7ca3ae8 100755
--- a/etc/guix-install.sh
+++ b/etc/guix-install.sh
@@ -15,6 +15,7 @@
 # Copyright © 2020 David A. Redick <david.a.redick <at> gmail.com>
 # Copyright © 2024 Janneke Nieuwenhuizen <janneke <at> gnu.org>
 # Copyright © 2024 Tomas Volf <~@wolfsden.cz>
+# Copyright © 2024 Richard Sent <richard <at> freakingpenguin.com>
 #
 # This file is part of GNU Guix.
 #
@@ -81,6 +82,12 @@ REQUIRE=(
     "xz"
 )
 
+# Add variables using form FOO_INIT_REQUIRE when init system FOO dependencies
+# should be checked.
+SYSV_INIT_REQUIRE=(
+    "daemonize"
+)
+
 PAS=$'[ \033[32;1mPASS\033[0m ] '
 ERR=$'[ \033[31;1mFAIL\033[0m ] '
 WAR=$'[ \033[33;1mWARN\033[0m ] '
@@ -148,6 +155,18 @@ chk_require()
     _msg "${PAS}verification of required commands completed"
 }
 
+add_init_sys_require()
+{ # Add the elements of FOO_INIT_SYS to REQUIRE
+    local init_require="${INIT_SYS}_REQUIRE[@]"
+    if [[ ! -z "$init_require" ]]; then
+        # Have to add piecemeal because ${!foo[@]} performs direct array key
+        # expansion, not indirect plain array expansion.
+        for r in "${!init_require}"; do
+            REQUIRE+=("$r")
+        done
+    fi
+}
+
 chk_gpg_keyring()
 { # Check whether the Guix release signing public key is present.
     _debug "--- [ ${FUNCNAME[0]} ] ---"
@@ -793,9 +812,10 @@ main_install()
     _msg "Starting installation ($(date))"
 
     chk_term
+    chk_init_sys
+    add_init_sys_require
     chk_require "${REQUIRE[@]}"
     chk_gpg_keyring
-    chk_init_sys
     chk_sys_arch
     chk_sys_nscd
 

base-commit: 542b18709a46e361de8f25e3fece29860532743c
-- 
2.41.0





This bug report was last modified 353 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.