GNU bug report logs - #42816
[PATCH] guix-install.sh: Add support for openrc

Previous Next

Package: guix-patches;

Reported by: Morgan.J.Smith <at> outlook.com

Date: Tue, 11 Aug 2020 20:37:02 UTC

Severity: normal

Tags: fixed, patch

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

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 42816 in the body.
You can then email your comments to 42816 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to guix-patches <at> gnu.org:
bug#42816; Package guix-patches. (Tue, 11 Aug 2020 20:37:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to Morgan.J.Smith <at> outlook.com:
New bug report received and forwarded. Copy sent to guix-patches <at> gnu.org. (Tue, 11 Aug 2020 20:37:02 GMT) Full text and rfc822 format available.

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

From: Morgan.J.Smith <at> outlook.com
To: guix-patches <at> gnu.org
Cc: Morgan Smith <Morgan.J.Smith <at> outlook.com>
Subject: [PATCH] guix-install.sh: Add support for openrc
Date: Tue, 11 Aug 2020 16:36:17 -0400
From: Morgan Smith <Morgan.J.Smith <at> 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

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"
-- 
2.27.0





Information forwarded to guix-patches <at> gnu.org:
bug#42816; Package guix-patches. (Tue, 11 Aug 2020 21:27:02 GMT) Full text and rfc822 format available.

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

From: Tobias Geerinckx-Rice <me <at> tobias.gr>
To: Morgan.J.Smith <at> outlook.com
Cc: 42816 <at> debbugs.gnu.org
Subject: Re: [bug#42816] [PATCH] guix-install.sh: Add support for openrc
Date: Tue, 11 Aug 2020 23:26:55 +0200
[Message part 1 (text/plain, inline)]
Morgan,

Morgan.J.Smith <at> 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
[signature.asc (application/pgp-signature, inline)]

Information forwarded to guix-patches <at> gnu.org:
bug#42816; Package guix-patches. (Wed, 12 Aug 2020 03:40:02 GMT) Full text and rfc822 format available.

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

From: Morgan.J.Smith <at> outlook.com
To: me <at> tobias.gr
Cc: Morgan Smith <Morgan.J.Smith <at> outlook.com>, 42816 <at> debbugs.gnu.org
Subject: [PATCH 1/2] guix-install.sh: Increase compatibility
Date: Tue, 11 Aug 2020 23:38:41 -0400
From: Morgan Smith <Morgan.J.Smith <at> outlook.com>

These fixes allow the script to be run using the binaries found on Alpine
Linux 3.12.0-x86_64.

* etc/guix-install.sh (guix_get_bin_list): Change grep to use extended regex
instead of perl regex. Grep using extended regex is POSIX while grep using
perl regex is not.

* etc/guix-install.sh (sys_create_store): Remove --warning flag as it is
unavailable on Alpine Linux
---

So for this change I had to learn perl regex. Then, once I understood
exactly what it did I recreated it from scratch not realizing that it
was almost the same as what was there before. I'm pretty sure there
are no differences between [[:digit:]] and [0-9], I just tend to use
[[:digit:]] because it's flashy

 etc/guix-install.sh | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/etc/guix-install.sh b/etc/guix-install.sh
index 72dc3839e8..06edbaaffd 100755
--- a/etc/guix-install.sh
+++ b/etc/guix-install.sh
@@ -212,7 +212,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 "([0-9]{1,2}\.){2}[0-9]{1,2}" \
                        | tail -n1)"
 
     default_ver="guix-binary-${latest_ver}.${ARCH_OS}"
@@ -268,8 +268,7 @@ sys_create_store()
     _debug "--- [ $FUNCNAME ] ---"
 
     cd "$tmp_path"
-    tar --warning=no-timestamp \
-        --extract \
+    tar --extract \
         --file "$pkg" &&
     _msg "${PAS}unpacked archive"
 
-- 
2.28.0





Information forwarded to guix-patches <at> gnu.org:
bug#42816; Package guix-patches. (Wed, 12 Aug 2020 03:40:02 GMT) Full text and rfc822 format available.

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

From: Morgan.J.Smith <at> outlook.com
To: me <at> tobias.gr
Cc: Morgan Smith <Morgan.J.Smith <at> outlook.com>, 42816 <at> debbugs.gnu.org
Subject: [PATCH 2/2] guix-install.sh: Add openrc support
Date: Tue, 11 Aug 2020 23:38:42 -0400
From: Morgan Smith <Morgan.J.Smith <at> outlook.com>

Tested and working on Alpine Linux 3.12.0-x86_64

* etc/guix-install.sh: Add openrc support
* etc/openrc/guix-daemon.in: New file - openrc service file
* nix/local.mk (etc/openrc/guix-daemon): New rule.
(nodist_openrcservice_DATA): Add etc/openrc/guix-daemon.in .
(CLEANFILES): Add etc/openrc/guix-daemon .
* .gitignore: Add etc/openrc/guix-daemon .
---

I'm pretty far out of comfort zone on these changes so please let me
know how this works. I basically guessed what needed to be changed in
local.mk.

---
 .gitignore          |  1 +
 etc/guix-install.sh | 15 +++++++++++++++
 nix/local.mk        | 17 +++++++++++++++--
 3 files changed, 31 insertions(+), 2 deletions(-)

diff --git a/.gitignore b/.gitignore
index f630444a0f..e2f745b42a 100644
--- a/.gitignore
+++ b/.gitignore
@@ -74,6 +74,7 @@
 /etc/guix-publish.conf
 /etc/guix-publish.service
 /etc/init.d/guix-daemon
+/etc/openrc/guix-daemon
 /guix-daemon
 /guix/config.scm
 /libformat.a
diff --git a/etc/guix-install.sh b/etc/guix-install.sh
index 06edbaaffd..ff4b95f124 100755
--- a/etc/guix-install.sh
+++ b/etc/guix-install.sh
@@ -4,6 +4,7 @@
 # Copyright © 2018 Ricardo Wurmus <rekado <at> elephly.net>
 # Copyright © 2018 Efraim Flashner <efraim <at> flashner.co.il>
 # Copyright © 2019, 2020 Tobias Geerinckx-Rice <me <at> tobias.gr>
+# Copyright © 2020 Morgan Smith <Morgan.J.Smith <at> outlook.com>
 #
 # This file is part of GNU Guix.
 #
@@ -150,6 +151,10 @@ 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"
+        return 0
     else
         INIT_SYS="NA"
         _err "${ERR}Init system could not be detected."
@@ -383,6 +388,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/nix/local.mk b/nix/local.mk
index 005cde5563..2bb01041b9 100644
--- a/nix/local.mk
+++ b/nix/local.mk
@@ -180,6 +180,17 @@ etc/init.d/guix-daemon: etc/init.d/guix-daemon.in	\
 	       "$<" > "$@.tmp";		\
 	mv "$@.tmp" "$@"
 
+# The service script for openrc.
+openrcservicedir = $(sysconfdir)/init.d
+nodist_openrcservice_DATA = etc/openrc/guix-daemon
+
+etc/openrc/guix-daemon: etc/openrc/guix-daemon.in	\
+			 $(top_builddir)/config.status
+	$(AM_V_GEN)$(MKDIR_P) "`dirname $@`";	\
+	$(SED) -e 's|@''localstatedir''@|$(localstatedir)|' <	\
+	       "$<" > "$@.tmp";		\
+	mv "$@.tmp" "$@"
+
 # The '.conf' jobs for Upstart.
 upstartjobdir = $(libdir)/upstart/system
 nodist_upstartjob_DATA = etc/guix-daemon.conf etc/guix-publish.conf
@@ -194,7 +205,8 @@ etc/guix-%.conf: etc/guix-%.conf.in	\
 CLEANFILES +=					\
   $(nodist_systemdservice_DATA)			\
   $(nodist_upstartjob_DATA)			\
-  $(nodist_sysvinitservice_DATA)
+  $(nodist_sysvinitservice_DATA)		\
+  $(nodist_openrcservice_DATA)
 
 EXTRA_DIST +=					\
   %D%/AUTHORS					\
@@ -203,7 +215,8 @@ EXTRA_DIST +=					\
   etc/guix-daemon.conf.in			\
   etc/guix-publish.service.in			\
   etc/guix-publish.conf.in			\
-  etc/init.d/guix-daemon.in
+  etc/init.d/guix-daemon.in			\
+  etc/openrc/guix-daemon.in
 
 if CAN_RUN_TESTS
 
-- 
2.28.0





Information forwarded to guix-patches <at> gnu.org:
bug#42816; Package guix-patches. (Wed, 12 Aug 2020 03:59:02 GMT) Full text and rfc822 format available.

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

From: Morgan.J.Smith <at> outlook.com
To: me <at> tobias.gr
Cc: Morgan Smith <Morgan.J.Smith <at> outlook.com>, 42816 <at> debbugs.gnu.org
Subject: [PATCH 3/2] Oops, please merge this patch with the last one. My bad
Date: Tue, 11 Aug 2020 23:58:08 -0400
From: Morgan Smith <Morgan.J.Smith <at> outlook.com>

---
Oops, please merge this patch with the last one. My bad

 etc/openrc/guix-daemon.in | 28 ++++++++++++++++++++++++++++
 1 file changed, 28 insertions(+)
 create mode 100644 etc/openrc/guix-daemon.in

diff --git a/etc/openrc/guix-daemon.in b/etc/openrc/guix-daemon.in
new file mode 100644
index 0000000000..110a58b88d
--- /dev/null
+++ b/etc/openrc/guix-daemon.in
@@ -0,0 +1,28 @@
+#!/sbin/openrc-run
+# GNU Guix --- Functional package management for GNU
+# Copyright © 2020 Morgan Smith <Morgan.J.Smith <at> outlook.com>
+#
+# This file is part of GNU Guix.
+#
+# GNU Guix is free software; you can redistribute it and/or modify it
+# under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or (at
+# your option) any later version.
+#
+# GNU Guix is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with GNU Guix.  If not, see <http://www.gnu.org/licenses/>.
+
+export GUIX_LOCPATH=@localstatedir@/guix/profiles/per-user/root/guix-profile/lib/locale
+export LC_ALL=en_US.utf8
+command="@localstatedir@/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"
-- 
2.28.0





Information forwarded to guix-patches <at> gnu.org:
bug#42816; Package guix-patches. (Tue, 18 Aug 2020 20:53:02 GMT) Full text and rfc822 format available.

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

From: Tobias Geerinckx-Rice <me <at> tobias.gr>
To: 42816 <at> debbugs.gnu.org
Cc: GNU bug tracker automated control server <control <at> debbugs.gnu.org>
Subject: This is just a test
Date: Tue, 18 Aug 2020 22:52:39 +0200
User: guix
Usertag: notdeadjusttestin




Information forwarded to guix-patches <at> gnu.org:
bug#42816; Package guix-patches. (Fri, 04 Sep 2020 08:59:02 GMT) Full text and rfc822 format available.

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

From: Ludovic Courtès <ludo <at> gnu.org>
To: Morgan.J.Smith <at> outlook.com
Cc: me <at> tobias.gr, 42816 <at> debbugs.gnu.org
Subject: Re: [bug#42816] [PATCH 1/2] guix-install.sh: Increase compatibility
Date: Fri, 04 Sep 2020 10:57:50 +0200
Hi!

Morgan.J.Smith <at> outlook.com skribis:

> From: Morgan Smith <Morgan.J.Smith <at> outlook.com>
>
> These fixes allow the script to be run using the binaries found on Alpine
> Linux 3.12.0-x86_64.
>
> * etc/guix-install.sh (guix_get_bin_list): Change grep to use extended regex
> instead of perl regex. Grep using extended regex is POSIX while grep using
> perl regex is not.
>
> * etc/guix-install.sh (sys_create_store): Remove --warning flag as it is
> unavailable on Alpine Linux

[...]

> From: Morgan Smith <Morgan.J.Smith <at> outlook.com>
>
> ---
> Oops, please merge this patch with the last one. My bad
>
>  etc/openrc/guix-daemon.in | 28 ++++++++++++++++++++++++++++

Tobias, I think these patches fell through the cracks.  Could you apply
them if everything looks good to you?  :-)

Thanks,
Ludo’.




Information forwarded to guix-patches <at> gnu.org:
bug#42816; Package guix-patches. (Thu, 17 Sep 2020 12:14:02 GMT) Full text and rfc822 format available.

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

From: Tobias Geerinckx-Rice <me <at> tobias.gr>
To: 42816 <at> debbugs.gnu.org
Subject: [PATCH] guix-install.sh: Add support for openrc
Date: Thu, 17 Sep 2020 14:13:21 +0200
[Message part 1 (text/plain, inline)]
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
[signature.asc (application/pgp-signature, inline)]

Added tag(s) fixed. Request was from Ludovic Courtès <ludo <at> gnu.org> to control <at> debbugs.gnu.org. (Sat, 19 Sep 2020 20:42:01 GMT) Full text and rfc822 format available.

bug closed, send any further explanations to 42816 <at> debbugs.gnu.org and Morgan.J.Smith <at> outlook.com Request was from Ludovic Courtès <ludo <at> gnu.org> to control <at> debbugs.gnu.org. (Sat, 19 Sep 2020 20:42:01 GMT) Full text and rfc822 format available.

bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Sun, 18 Oct 2020 11:24:05 GMT) Full text and rfc822 format available.

This bug report was last modified 3 years and 188 days ago.

Previous Next


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