[PATCH v1 0/2] Add perp support in guix-install.sh for Dragora.

  • Open
  • quality assurance status badge
Details
2 participants
  • Denis 'GNUtoo' Carikli
  • Vincent Legoll
Owner
unassigned
Submitted by
Denis 'GNUtoo' Carikli
Severity
normal
D
D
Denis 'GNUtoo' Carikli wrote on 7 Aug 2024 17:00
(name . Denis 'GNUtoo' Carikli)(address . GNUtoo@cyberdimension.org)
cover.1723041383.git.GNUtoo@cyberdimension.org
Hi,

When installing guix through guix-install.sh in Dragora the init system is not
detected, so this serie fixes that.

I also included a package for perp itself in case that can help getting
familiar with it to review the patch for guix-install.sh. I've not tested if
it works on top of Guix though, but it's handy as the manuals are present for
instance.

Also note that for the perp service for guix-install.sh, I took inspiration
from the perp services inside the examples directory in perp source code.

As for the guix-install.sh I've tested various pieces separately but not
together as doing that would require the patch to be in Guix in the fist
place:

* I've tested that the guix daemon is started and stopped correctly by
guix-install.sh once the files are in the right place.

* I've tested that the logs are produced. They end up in
/var/log/guix-daemon/current.

* I've also tested (without guix-install.sh) that 'perpctl A guix-daemon'
really starts the service and that then at the next boot the service is
running too. I also tested 'perpctl X guix-daemon' in the same way.

* I've tested that /etc/perp/guix-daemon/{rc.main,rc.log} are in the right
place.

* I've tested that the variables are passed to the guix-daemon by replacing it
with very simple C code below that prints variables, and by also exporting
TESTGNUTOO (and assigining it some value) to make sure that the variable is
really passed by /etc/perp/rc.main and not by something else like bashrc.

/*
* Copyright © 2024 Denis 'GNUtoo' Carikli <GNUtoo@cyberdimension.org>
*
* This file 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.
*
* This file 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 this file. If not, see http://www.gnu.org/licenses/.
*/
#include <stdio.h>
#include <string.h>
#include <unistd.h>
extern char **environ;
int print_entry(char *var1, char *var2)
{
int i;
char *curr;
for (i=0; ; i++) {
curr = environ[i];
if (curr == NULL)
break;
if (!strncmp(var1, curr, strlen(var1)))
printf("%s: [%s]\n", var1, curr);
else if (!strncmp(var2, curr, strlen(var2)))
printf("%s: [%s]\n", var2, curr);
}
}
int main()
{
while(1) {
print_entry("GUIX_LOCPATH", "TESTGNUTOO");
sleep(1);
}
}

Denis 'GNUtoo' Carikli (2):
gnu: Add perp.
guix-install.sh: Support perp.

.gitignore | 2 ++
etc/guix-install.sh | 25 +++++++++++++++++++++++
etc/perp/rc.log.in | 24 ++++++++++++++++++++++
etc/perp/rc.main.in | 45 ++++++++++++++++++++++++++++++++++++++++++
gnu/packages/admin.scm | 33 +++++++++++++++++++++++++++++++
nix/local.mk | 17 +++++++++++++++-
6 files changed, 145 insertions(+), 1 deletion(-)
create mode 100644 etc/perp/rc.log.in
create mode 100644 etc/perp/rc.main.in


base-commit: 5e567587dd4abf51f9a6fa44f5a852dde1115ce9
--
2.45.2
D
D
Denis 'GNUtoo' Carikli wrote on 7 Aug 2024 17:39
[PATCH v1 1/2] gnu: Add perp.
(name . Denis 'GNUtoo' Carikli)(address . GNUtoo@cyberdimension.org)
ffba3508180b0b973b8b9982263d58d177c2dd4c.1723041383.git.GNUtoo@cyberdimension.org
* gnu/packages/admin.scm (perp): New variable.

Signed-off-by: Denis 'GNUtoo' Carikli <GNUtoo@cyberdimension.org>
Change-Id: I6a20a7f1f7103eeea980612a046531d556192356
---
gnu/packages/admin.scm | 33 +++++++++++++++++++++++++++++++++
1 file changed, 33 insertions(+)

Toggle diff (46 lines)
diff --git a/gnu/packages/admin.scm b/gnu/packages/admin.scm
index 113b8e2481..71149393ae 100644
--- a/gnu/packages/admin.scm
+++ b/gnu/packages/admin.scm
@@ -727,6 +727,39 @@ (define-public facter
(home-page "https://github.com/puppetlabs/facter")
(license license:expat)))
+(define-public perp
+ (package
+ (name "perp")
+ (version "2.07")
+ (source
+ (origin
+ (method url-fetch)
+ (uri
+ (string-append
+ "http://b0llix.net/perp/distfiles/perp-" version ".tar.gz"))
+ (sha256
+ (base32 "05aq8xj9fpgs468dq6iqpkfixhzqm4xzj5l4lyrdh530q4qzw8hj"))))
+ (build-system gnu-build-system)
+ (arguments
+ (list
+ #:tests? #f ;no tests
+ #:make-flags
+ #~(list
+ "BINDIR = /bin"
+ "SBINDIR = /sbin"
+ "MANDIR = /share/man"
+ (string-append "DESTDIR=" #$output))
+ #:phases #~(modify-phases %standard-phases (delete 'configure))))
+ (home-page "http://b0llix.net/perp/")
+ (synopsis "Persistent process supervisor and service managment framework")
+ (description
+ "The perp package provides a set of daemons and utilities to reliably
+start, monitor, log, and control a collection of persistent processes. It is
+portable across a wide variety of unix-like operating systems. It does not
+replace the Process 1 (/sbin/init).")
+ (license
+ (license:fsdg-compatible "http://b0llix.net/perp/site.cgi?page=LICENSE"))))
+
(define-public ttyload
(let ((revision "1")
(commit "f9495372801ce4b4dad98ad854203e694c31c1eb"))
--
2.45.2
D
D
Denis 'GNUtoo' Carikli wrote on 7 Aug 2024 17:39
[PATCH v1 2/2] guix-install.sh: Support perp.
(name . Denis 'GNUtoo' Carikli)(address . GNUtoo@cyberdimension.org)
d4927ad6160e8acb02b917929b587aae02b26768.1723041383.git.GNUtoo@cyberdimension.org
Without this patch, it is possible to install Guix on Dragora, but then no
init system is detected and so the Guix daemon isn't started.

Thanks a lot for the help from selk on #dragora on Libera Chat for the help.

* etc/guix-install.sh
(chk_init_sys): Detect perp.
(sys_enable_guix_daemon): Install, configure, enable and start the perp
service.
(sys_delete_guix_daemon): Stop and remove the perp service.
* etc/perp/rc.log.in: New file.
* etc/perp/rc.main.in: New file.
* nix/local.mk: Add build rules.
* .gitignore: Ignore generated etc/perp/rc.log and etc/perp/rc.main.

Change-Id: I15a5229fee69ebd41ac538b25a3e68793c563144
Signed-off-by: Denis 'GNUtoo' Carikli <GNUtoo@cyberdimension.org>
---
.gitignore | 2 ++
etc/guix-install.sh | 25 +++++++++++++++++++++++++
etc/perp/rc.log.in | 24 ++++++++++++++++++++++++
etc/perp/rc.main.in | 45 +++++++++++++++++++++++++++++++++++++++++++++
nix/local.mk | 17 ++++++++++++++++-
5 files changed, 112 insertions(+), 1 deletion(-)
create mode 100644 etc/perp/rc.log.in
create mode 100644 etc/perp/rc.main.in

Toggle diff (188 lines)
diff --git a/.gitignore b/.gitignore
index 0f74b5da3d..11f99e32db 100644
--- a/.gitignore
+++ b/.gitignore
@@ -77,6 +77,8 @@
/etc/guix-gc.service
/etc/init.d/guix-daemon
/etc/openrc/guix-daemon
+/etc/perp/rc.log
+/etc/perp/rc.main
/guix-*
/guix/config.scm
/libformat.a
diff --git a/etc/guix-install.sh b/etc/guix-install.sh
index 9d9c294d75..4a0b326ffa 100755
--- a/etc/guix-install.sh
+++ b/etc/guix-install.sh
@@ -232,6 +232,10 @@ chk_init_sys()
_msg "${INF}init system is: systemd"
INIT_SYS="systemd"
return 0
+ elif [[ $(perpboot -V 2>&1) =~ perpboot ]]; then
+ _msg "${INF}init system is: perp"
+ INIT_SYS="perp"
+ return 0
elif [[ -f /etc/init.d/cron && ! -h /etc/init.d/cron ]]; then
_msg "${INF}init system is: sysv-init"
INIT_SYS="sysv-init"
@@ -505,6 +509,20 @@ sys_enable_guix_daemon()
systemctl start guix-daemon; } &&
_msg "${PAS}enabled Guix daemon via systemd"
;;
+ perp)
+ { mkdir -p /etc/perp/guix-daemon/;
+ cp ~root/.config/guix/current/etc/perp/rc.log \
+ /etc/perp/guix-daemon/rc.log;
+ cp ~root/.config/guix/current/etc/perp/rc.main \
+ /etc/perp/guix-daemon/rc.main;
+ chmod 775 /etc/perp/guix-daemon/rc.log;
+ chmod 775 /etc/perp/guix-daemon/rc.main;
+
+ configure_substitute_discovery /etc/perp/guix-daemon/rc.main
+
+ perpctl A guix-daemon; } &&
+ _msg "${PAS}enabled Guix daemon via perp"
+ ;;
sysv-init)
{ mkdir -p /etc/init.d;
cp ~root/.config/guix/current/etc/init.d/guix-daemon \
@@ -587,6 +605,13 @@ sys_delete_guix_daemon()
systemctl daemon-reload
;;
+ perp)
+ _msg "${INF}stopping and disabling guix-daemon"
+ perpctl X guix-daemon
+ _msg "${INF}removing guix-daemon"
+ rm -rf /etc/perp/guix-daemon
+ ;;
+
sysv-init)
update-rc.d guix-daemon disable
service guix-daemon stop
diff --git a/etc/perp/rc.log.in b/etc/perp/rc.log.in
new file mode 100644
index 0000000000..11c3ab490e
--- /dev/null
+++ b/etc/perp/rc.log.in
@@ -0,0 +1,24 @@
+#!/bin/sh
+# GNU Guix --- Functional package management for GNU
+# Copyright © 2024 Denis 'GNUtoo' Carikli <GNUtoo@cyberdimension.org>
+#
+# 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/>.
+
+if [ "${1}" = "start" ] ; then
+ exec tinylog_run "${2}"
+fi
+
+exit 0
diff --git a/etc/perp/rc.main.in b/etc/perp/rc.main.in
new file mode 100644
index 0000000000..cdf92763eb
--- /dev/null
+++ b/etc/perp/rc.main.in
@@ -0,0 +1,45 @@
+#! /bin/sh
+# GNU Guix --- Functional package management for GNU
+# Copyright © 2024 Denis 'GNUtoo' Carikli <GNUtoo@cyberdimension.org>
+#
+# 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/>.
+
+start() {
+ echo "*** ${SVNAME}: starting Guix daemon..."
+
+ export GUIX_LOCPATH=@localstatedir@/guix/profiles/per-user/root/guix-profile/lib/locale
+ export LC_ALL=en_US.utf8
+ exec @localstatedir@/guix/profiles/per-user/root/current-guix/bin/guix-daemon \
+ --build-users-group=guixbuild --discover=no \
+ --substitute-urls='https://bordeaux.guix.gnu.org https://ci.guix.gnu.org' 2>&1
+}
+
+reset() {
+ case $3 in
+ "exit" )
+ echo "*** ${SVNAME}: exited status $4"
+ ;;
+ "signal" )
+ echo "*** ${SVNAME}: killed on signal $5"
+ ;;
+ * )
+ echo "*** ${SVNAME}: stopped ($3)"
+ ;;
+ esac
+ exit 0
+}
+
+eval ${TARGET} "$@"
diff --git a/nix/local.mk b/nix/local.mk
index 8a2b2b88e8..ffc57185cf 100644
--- a/nix/local.mk
+++ b/nix/local.mk
@@ -194,6 +194,18 @@ etc/openrc/guix-daemon: etc/openrc/guix-daemon.in \
"$<" > "$@.tmp"; \
mv "$@.tmp" "$@"
+# The service script for perp.
+perpservicedir = $(sysconfdir)/perp
+nodist_perpservice_DATA = etc/perp/rc.log etc/perp/rc.main
+
+etc/perp/rc.%: etc/perp/rc.%.in \
+ $(top_builddir)/config.status
+ $(AM_V_GEN)$(MKDIR_P) "`dirname $@`"; \
+ $(SED) -e 's|@''localstatedir''@|$(localstatedir)|' \
+ -e 's|@''GUIX_SUBSTITUTE_URLS''@|$(GUIX_SUBSTITUTE_URLS)|' \
+ < "$<" > "$@.tmp"; \
+ mv "$@.tmp" "$@"
+
# The '.conf' jobs for Upstart.
upstartjobdir = $(libdir)/upstart/system
nodist_upstartjob_DATA = etc/guix-daemon.conf etc/guix-publish.conf
@@ -210,6 +222,7 @@ CLEANFILES += \
$(nodist_systemdservice_DATA) \
$(nodist_upstartjob_DATA) \
$(nodist_sysvinitservice_DATA) \
+ $(nodist_perpservice_DATA) \
$(nodist_openrcservice_DATA)
EXTRA_DIST += \
@@ -223,7 +236,9 @@ EXTRA_DIST += \
etc/guix-gc.service.in \
etc/guix-gc.timer \
etc/init.d/guix-daemon.in \
- etc/openrc/guix-daemon.in
+ etc/openrc/guix-daemon.in \
+ etc/perp/rc.log.in \
+ etc/perp/rc.main.in
if CAN_RUN_TESTS
--
2.45.2
V
V
Vincent Legoll wrote on 8 Aug 2024 11:08
[PATCH v1 0/2] Add perp support in guix-install.sh for Dragora.
(address . 72514@debbugs.gnu.org)
CAEwRq=oEJBagHVutbgD0rMtXYdHMbgeO4LPz0FTj-xcMLwm_Og@mail.gmail.com
Hello,

Totally untested, but for what it's worth: LGTM

And also: good luck

--
Vincent Legoll
Attachment: file
?
Your comment

Commenting via the web interface is currently disabled.

To comment on this conversation send an email to 72514@debbugs.gnu.org

To respond to this issue using the mumi CLI, first switch to it
mumi current 72514
Then, you may apply the latest patchset in this issue (with sign off)
mumi am -- -s
Or, compose a reply to this issue
mumi compose
Or, send patches to this issue
mumi send-email *.patch