diff mbox series

[bug#42816] guix-install.sh: Add support for openrc

Message ID DM5PR1001MB2105C215AA5E05D4DAA5F64CC5450@DM5PR1001MB2105.namprd10.prod.outlook.com
State Accepted
Headers show
Series [bug#42816] guix-install.sh: Add support for openrc | expand

Checks

Context Check Description
cbaines/comparison success View comparision
cbaines/git branch success View Git branch
cbaines/applying patch success View Laminar job
cbaines/comparison success View comparision
cbaines/git branch success View Git branch
cbaines/applying patch success View Laminar job

Commit Message

Morgan Smith Aug. 11, 2020, 8:36 p.m. UTC
From: Morgan Smith <Morgan.J.Smith@outlook.com>

* etc/guix-install.sh: Add support for openrc

I also removed the --warning=no-timestamp tar flag and changed grep to use
extended regex instead of perl regex since these flags where not supported on
the alpine linux image I was using to test (3.12.0-x86_64).
---
 etc/guix-install.sh    | 18 +++++++++++++++---
 etc/openrc/guix-daemon | 11 +++++++++++
 2 files changed, 26 insertions(+), 3 deletions(-)
 create mode 100644 etc/openrc/guix-daemon

Comments

ashish.is--- via Guix-patches" via Aug. 11, 2020, 9:26 p.m. UTC | #1
Morgan,

Morgan.J.Smith@outlook.com 写道:
> * etc/guix-install.sh: Add support for openrc

\o/ thanks!

> I also removed the --warning=no-timestamp tar flag

My understanding was that this silenced a scary but harmless 
warning from older (GNU?) tar versions.  I'm happy to see it go if 
it actually breaks others.

> and changed grep to use
> extended regex instead of perl regex since these flags where not 
> supported on
> the alpine linux image I was using to test (3.12.0-x86_64).

Both Alpine compatibility changes are very welcome but should be 
in a separate commit.  Keep commits confined to one logical change 
whenever possible.

> --- a/etc/guix-install.sh
> +++ b/etc/guix-install.sh
> @@ -150,6 +150,9 @@ chk_init_sys()
>          _msg "${INF}init system is: sysv-init"
>          INIT_SYS="sysv-init"
>          return 0
> +    elif [[ $(openrc --version 2>/dev/null) =~ \(OpenRC\) ]]; 
> then

OK.  I didn't realise the script still had severe bashism.

> +        _msg "${INF}init system is: OpenRC"
> +        INIT_SYS="openrc"

Add a ‘return 0’ line here for consistency with the rest of the 
code.

>      latest_ver="$(echo "$bin_ver_ls" \
> -                       | grep -oP "([0-9]{1,2}\.){2}[0-9]{1,2}" 
> \
> +                       | grep -oE 
> "([[:digit:]]{1,2}\.){2}[[:digit:]]{1,2}" \

[[:digit:]] wasn't strictly required here, right?  I understand 
that it's more ‘correct’ but can't imagine any locale actually 
breaking either one.

Is there a practical chance that some ancient-but-supported grep 
out there supports [0-9] but *not* [[:digit:]]?

If not: OK!

> @@ -384,6 +386,16 @@ sys_enable_guix_daemon()
>                    service guix-daemon start; } &&
>                  _msg "${PAS}enabled Guix daemon via sysv"
>              ;;
> +        openrc)
> +            { mkdir -p /etc/init.d;
> +              cp 
> "${ROOT_HOME}/.config/guix/current/etc/openrc/guix-daemon" \
> +                 /etc/init.d/guix-daemon;
> +              chmod 775 /etc/init.d/guix-daemon;
> +
> +              rc-update add guix-daemon default &&
> +                  rc-service guix-daemon start;} &&
> +                _msg "${PAS}enabled Guix daemon via OpenRC"
> +            ;;

I'll defer to your expertise on the OpenRC incantations :-)

Minor nitpick: ‘; }’.

> diff --git a/etc/openrc/guix-daemon b/etc/openrc/guix-daemon

I like the subdirectory.

> new file mode 100644
> index 0000000000..436673f169
> --- /dev/null
> +++ b/etc/openrc/guix-daemon
> @@ -0,0 +1,11 @@
> +#!/sbin/openrc-run
> +
> +export 
> GUIX_LOCPATH=/var/guix/profiles/per-user/root/guix-profile/lib/locale
> +export LC_ALL=en_US.utf8
> +command="/var/guix/profiles/per-user/root/current-guix/bin/guix-daemon"
> +command_args="--build-users-group=guixbuild"
> +command_background="yes"
> +pidfile="/var/run/guix-daemon.pid"
> +
> +output_log="/var/log/guix-daemon-stdout.log"
> +error_log="/var/log/guix-daemon-stderr.log"

Please rename this to guix-daemon.in & add it to nix/local.mk so 
we can use @localstatedir@ here.

If you could send a revised patch series it would be much 
appreciated; otherwise I'll make the above changes when I get 
around to it (...).

Thanks!

T G-R
ashish.is--- via Guix-patches" via Aug. 18, 2020, 8:52 p.m. UTC | #2
User: guix
Usertag: notdeadjusttestin
ashish.is--- via Guix-patches" via Sept. 17, 2020, 12:13 p.m. UTC | #3
Morgan, civodul,

> Tobias, I think these patches fell through the cracks.

I think so too.  Thanks for your patience, Morgan, and enjoy 
commits cabac732 et al.

Closing,

T G-R
diff mbox series

Patch

diff --git a/etc/guix-install.sh b/etc/guix-install.sh
index 72dc3839e8..9e9f8470d8 100755
--- a/etc/guix-install.sh
+++ b/etc/guix-install.sh
@@ -150,6 +150,9 @@  chk_init_sys()
         _msg "${INF}init system is: sysv-init"
         INIT_SYS="sysv-init"
         return 0
+    elif [[ $(openrc --version 2>/dev/null) =~ \(OpenRC\) ]]; then
+        _msg "${INF}init system is: OpenRC"
+        INIT_SYS="openrc"
     else
         INIT_SYS="NA"
         _err "${ERR}Init system could not be detected."
@@ -212,7 +215,7 @@  guix_get_bin_list()
         | sort -Vu)")
 
     latest_ver="$(echo "$bin_ver_ls" \
-                       | grep -oP "([0-9]{1,2}\.){2}[0-9]{1,2}" \
+                       | grep -oE "([[:digit:]]{1,2}\.){2}[[:digit:]]{1,2}" \
                        | tail -n1)"
 
     default_ver="guix-binary-${latest_ver}.${ARCH_OS}"
@@ -268,8 +271,7 @@  sys_create_store()
     _debug "--- [ $FUNCNAME ] ---"
 
     cd "$tmp_path"
-    tar --warning=no-timestamp \
-        --extract \
+    tar --extract \
         --file "$pkg" &&
     _msg "${PAS}unpacked archive"
 
@@ -384,6 +386,16 @@  sys_enable_guix_daemon()
                   service guix-daemon start; } &&
                 _msg "${PAS}enabled Guix daemon via sysv"
             ;;
+        openrc)
+            { mkdir -p /etc/init.d;
+              cp "${ROOT_HOME}/.config/guix/current/etc/openrc/guix-daemon" \
+                 /etc/init.d/guix-daemon;
+              chmod 775 /etc/init.d/guix-daemon;
+
+              rc-update add guix-daemon default &&
+                  rc-service guix-daemon start;} &&
+                _msg "${PAS}enabled Guix daemon via OpenRC"
+            ;;
         NA|*)
             _msg "${ERR}unsupported init system; run the daemon manually:"
             echo "  ${ROOT_HOME}/.config/guix/current/bin/guix-daemon --build-users-group=guixbuild"
diff --git a/etc/openrc/guix-daemon b/etc/openrc/guix-daemon
new file mode 100644
index 0000000000..436673f169
--- /dev/null
+++ b/etc/openrc/guix-daemon
@@ -0,0 +1,11 @@ 
+#!/sbin/openrc-run
+
+export GUIX_LOCPATH=/var/guix/profiles/per-user/root/guix-profile/lib/locale
+export LC_ALL=en_US.utf8
+command="/var/guix/profiles/per-user/root/current-guix/bin/guix-daemon"
+command_args="--build-users-group=guixbuild"
+command_background="yes"
+pidfile="/var/run/guix-daemon.pid"
+
+output_log="/var/log/guix-daemon-stdout.log"
+error_log="/var/log/guix-daemon-stderr.log"