From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:470:142:3::10]:59164) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jO1e0-00051d-5U for guix-patches@gnu.org; Mon, 13 Apr 2020 12:09:09 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1jO1dw-0005OD-KA for guix-patches@gnu.org; Mon, 13 Apr 2020 12:09:08 -0400 Received: from debbugs.gnu.org ([209.51.188.43]:49025) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1jO1dw-0005Nj-7V for guix-patches@gnu.org; Mon, 13 Apr 2020 12:09:04 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1jO1dw-0006xB-16 for guix-patches@gnu.org; Mon, 13 Apr 2020 12:09:04 -0400 Subject: [bug#40601] [PATCH 5/5] guix-install.sh, guix-binary tarball: Handle runit-based foreign distributions. Resent-Message-ID: From: Vincent Legoll Date: Mon, 13 Apr 2020 18:07:40 +0200 Message-Id: <20200413160740.19584-5-vincent.legoll@gmail.com> In-Reply-To: <20200413160740.19584-1-vincent.legoll@gmail.com> References: <20200413160740.19584-1-vincent.legoll@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-patches-bounces+kyle=kyleam.com@gnu.org Sender: "Guix-patches" To: 40601@debbugs.gnu.org Cc: Vincent Legoll * .gitignore: Add /etc/runit/run. * etc/guix-install.sh (chk_init_sys): Add case to detect runit. (sys_enable_guix_daemon): Add case to setup guix-daemon within runit. * etc/runit/run.in: New file. * nix/local.mk (etc/runit/run): Add target to generate etc/runit/run from etc/runit/run.in. (nodist_runitservice_DATA): New variable... (CLEANFILES): ... add it here. (runitservicedir): New variable. (EXTRA_DIST): Add etc/runit/run.in. --- .gitignore | 1 + etc/guix-install.sh | 11 +++++++++++ etc/runit/run.in | 15 +++++++++++++++ nix/local.mk | 13 +++++++++++++ 4 files changed, 40 insertions(+) create mode 100644 etc/runit/run.in diff --git a/.gitignore b/.gitignore index fd2cf56098..89a2c89e1e 100644 --- a/.gitignore +++ b/.gitignore @@ -72,6 +72,7 @@ /etc/guix-publish.conf /etc/guix-publish.service /etc/init.d/guix-daemon +/etc/runit/run /guix-daemon /guix/config.scm /libformat.a diff --git a/etc/guix-install.sh b/etc/guix-install.sh index 0d15a05cb4..06590ee97f 100755 --- a/etc/guix-install.sh +++ b/etc/guix-install.sh @@ -152,6 +152,10 @@ chk_init_sys() _msg "${INF}init system is: sysv-init" INIT_SYS="sysv-init" return 0 + elif [[ -d /etc/sv ]]; then + _msg "${INF}init system is: runit" + INIT_SYS="runit" + return 0 else INIT_SYS="NA" _err "${ERR}Init system could not be detected." @@ -364,6 +368,13 @@ sys_enable_guix_daemon() systemctl enable guix-daemon; } && _msg "${PAS}enabled Guix daemon via systemd" ;; + runit) + { cp -r "${ROOT_HOME}/.config/guix/current/lib/runit/guix-daemon" \ + /etc/sv; + chmod 755 /etc/sv/guix-daemon/run; + ln -s /etc/sv/guix-daemon /etc/runit/runsvdir/default/; } && + _msg "${PAS}enabled Guix daemon via runit" + ;; sysv-init) { mkdir -p /etc/init.d; cp "${ROOT_HOME}/.config/guix/current/etc/init.d/guix-daemon" \ diff --git a/etc/runit/run.in b/etc/runit/run.in new file mode 100644 index 0000000000..e57ef597bc --- /dev/null +++ b/etc/runit/run.in @@ -0,0 +1,15 @@ +#!/bin/sh + +# This is a "run script" for the runit init system to launch +# 'guix-daemon'. Drop it in /etc/sv/guix-daemon and add a symlink to +# it like the following to have 'guix-daemon' automatically started. +# ln -s /etc/sv/guix-daemon /etc/runit/runsvdir/default/ + +GUIX_LOCPATH=@localstatedir@/guix/profiles/per-user/root/guix-profile/lib/locale +LC_ALL=en_US.utf8 + +export GUIX_LOCPATH LC_ALL + +exec @localstatedir@/guix/profiles/per-user/root/current-guix/bin/guix-daemon \ + --build-users-group=guixbuild + diff --git a/nix/local.mk b/nix/local.mk index 412d89ba3d..877ddcc281 100644 --- a/nix/local.mk +++ b/nix/local.mk @@ -175,6 +175,17 @@ etc/init.d/guix-daemon: etc/init.d/guix-daemon.in \ "$<" > "$@.tmp"; \ mv "$@.tmp" "$@" +# The service run script for runit. +runitservicedir = $(libdir)/runit/guix-daemon +nodist_runitservice_DATA = etc/runit/run + +etc/runit/run: etc/runit/run.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 @@ -189,6 +200,7 @@ etc/guix-%.conf: etc/guix-%.conf.in \ CLEANFILES += \ $(nodist_systemdservice_DATA) \ $(nodist_upstartjob_DATA) \ + $(nodist_runitservice_DATA) \ $(nodist_sysvinitservice_DATA) EXTRA_DIST += \ @@ -198,6 +210,7 @@ EXTRA_DIST += \ etc/guix-daemon.conf.in \ etc/guix-publish.service.in \ etc/guix-publish.conf.in \ + etc/runit/run.in \ etc/init.d/guix-daemon.in if CAN_RUN_TESTS -- 2.26.0