Subject: [bug#70148] [PATCH v2] guix-install.sh: Add unique requirement for sysv init system

From: Ludovic Courtès <[email-masked]>
Date: Sun, 02 Jun 2024 11:45:27 +0200

Hi Richard,

Richard Sent <[email-masked]> skribis:

> 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.

Neat!  I have one concern though:

> +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

‘local’, [[, and arrays are probably Bash-specific.  However this is a
#!/bin/sh script, and some systems such as Debian use Dash as /bin/sh.
So I’m afraid the script would break on such systems.

WDYT?  Do you think we can avoid those features?

So much for a script.  :-)

Thanks!

Ludo’.