[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[bug#42816] [PATCH 2/2] guix-install.sh: Add openrc support
From: |
Morgan . J . Smith |
Subject: |
[bug#42816] [PATCH 2/2] guix-install.sh: Add openrc support |
Date: |
Tue, 11 Aug 2020 23:38:42 -0400 |
From: Morgan Smith <Morgan.J.Smith@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@elephly.net>
# Copyright © 2018 Efraim Flashner <efraim@flashner.co.il>
# Copyright © 2019, 2020 Tobias Geerinckx-Rice <me@tobias.gr>
+# Copyright © 2020 Morgan Smith <Morgan.J.Smith@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