aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorLaurent Bercot <ska-skaware@skarnet.org>2026-06-19 02:29:06 +0000
committerLaurent Bercot <ska-skaware@skarnet.org>2026-06-19 02:29:06 +0000
commit8eb000d3d22fcf7850b43f75ed52068693430d3b (patch)
tree9ce6403d9206a0707a44312a5ae7069e50a7e3d6 /src
parent135468b32b12e2f2974b72c61e9d8390e562741e (diff)
downloads6-frontend-8eb000d3d22fcf7850b43f75ed52068693430d3b.tar.gz
Add s6 set apply and s6 apply
Diffstat (limited to 'src')
-rw-r--r--src/s6-frontend/deps-exe/s6-frontend1
-rw-r--r--src/s6-frontend/main.help.txt8
-rw-r--r--src/s6-frontend/s6-frontend-internal.h2
-rw-r--r--src/s6-frontend/s6-frontend.c1
-rw-r--r--src/s6-frontend/set.c1
-rw-r--r--src/s6-frontend/set.help.txt13
-rw-r--r--src/s6-frontend/set_apply.c143
-rw-r--r--src/s6-frontend/set_change.c6
8 files changed, 170 insertions, 5 deletions
diff --git a/src/s6-frontend/deps-exe/s6-frontend b/src/s6-frontend/deps-exe/s6-frontend
index b6d45c0..1a47be4 100644
--- a/src/s6-frontend/deps-exe/s6-frontend
+++ b/src/s6-frontend/deps-exe/s6-frontend
@@ -20,6 +20,7 @@ repository_init.o
repository_list.o
repository_sync.o
set.o
+set_apply.o
set_change.o
set_check.o
set_commit.o
diff --git a/src/s6-frontend/main.help.txt b/src/s6-frontend/main.help.txt
index f7c03eb..7837152 100644
--- a/src/s6-frontend/main.help.txt
+++ b/src/s6-frontend/main.help.txt
@@ -11,6 +11,14 @@ Commands:
set manipulate sets of services (offline, to later install them live)
repository manipulate the service repository itself
+Shortcuts:
+ enable s6 set enable
+ disable s6 set disable
+ start s6 live start
+ stop s6 live stop
+ kill s6 process kill
+ apply s6 set apply
+
Global options:
-h --help equivalent to "s6 help"
-u --user override config values with XDG environment
diff --git a/src/s6-frontend/s6-frontend-internal.h b/src/s6-frontend/s6-frontend-internal.h
index dad191b..587b4e2 100644
--- a/src/s6-frontend/s6-frontend-internal.h
+++ b/src/s6-frontend/s6-frontend-internal.h
@@ -88,6 +88,8 @@ extern void set_make_essential (char const *const *) gccattr_noreturn ;
extern void set_check (char const *const *) gccattr_noreturn ;
extern void set_commit (char const *const *) gccattr_noreturn ;
+extern void set_apply (char const *const *) gccattr_noreturn ;
+
/* system */
diff --git a/src/s6-frontend/s6-frontend.c b/src/s6-frontend/s6-frontend.c
index c79464e..9e649a7 100644
--- a/src/s6-frontend/s6-frontend.c
+++ b/src/s6-frontend/s6-frontend.c
@@ -118,6 +118,7 @@ int main (int argc, char const *const *argv)
} ;
static struct command_s const commands[] =
{
+ { .s = "apply", .f = &set_apply },
{ .s = "disable", .f = &set_disable },
{ .s = "enable", .f = &set_enable },
{ .s = "help", .f = &main_help },
diff --git a/src/s6-frontend/set.c b/src/s6-frontend/set.c
index fe5f165..8ece627 100644
--- a/src/s6-frontend/set.c
+++ b/src/s6-frontend/set.c
@@ -23,6 +23,7 @@ void set (char const *const *argv)
{
static struct command_s const commands[] =
{
+ { .s = "apply", .f = &set_apply },
{ .s = "check", .f = &set_check },
{ .s = "commit", .f = &set_commit },
{ .s = "copy", .f = &set_copy },
diff --git a/src/s6-frontend/set.help.txt b/src/s6-frontend/set.help.txt
index 62b59ea..9113f34 100644
--- a/src/s6-frontend/set.help.txt
+++ b/src/s6-frontend/set.help.txt
@@ -12,6 +12,7 @@ Subcommands:
unmask unmask services (equivalent to "disable")
check check working set and fix inconsistencies
commit commit working set (can then be installed)
+ apply make working set live: commit + live install + live reset
s6 set copy options:
@@ -37,8 +38,8 @@ s6 set enable|disable|mask|unmask options:
-s SET --set=SET change services in set SET (default: current)
s6 set check options:
- -E --no-force-essential do not allow manual changes to essential services (default)
- -e --force-essential allow manual changes to essential services
+ -E --no-force-essentials do not allow manual changes to essential services (default)
+ -e --force-essentials allow manual changes to essential services
-F --fix try to fix inconsistencies automatically
-d --down fix by disabling or masking services if necessary (default)
-u --up fix by enabling services if necessary
@@ -51,3 +52,11 @@ s6 set commit options:
-h USER --fdholder-user=USER user for the s6-fdholderd process (default: root - it's fine)
-s SET --set=SET commit set SET (default: current)
+s6 set apply options:
+ -b --block block if another s6-rc is running (default: fail)
+ -D BUN --default-bundle=BUN name of the bundle containing enabled+essential services
+ -h USER --fdholder-user=USER user for the s6-fdholderd process (default: root - it's fine)
+ -f CONVFILE --conversion-file=CONVFILE use CONVFILE when updating the service db (default: none)
+ -s SET --set=SET apply set SET (default: current)
+ -t TIMEOUT --timeout=TIMEOUT fail after TIMEOUT milliseconds (default: 0 (=infinite))
+
diff --git a/src/s6-frontend/set_apply.c b/src/s6-frontend/set_apply.c
new file mode 100644
index 0000000..b017212
--- /dev/null
+++ b/src/s6-frontend/set_apply.c
@@ -0,0 +1,143 @@
+/* ISC license. */
+
+#include <skalibs/uint64.h>
+#include <skalibs/types.h>
+#include <skalibs/envexec.h>
+#include <skalibs/djbunix.h>
+
+#include <s6-rc/config.h>
+
+#include "s6-frontend-internal.h"
+
+enum golb_e
+{
+ GOLB_BLOCK = 0x01,
+} ;
+
+enum gola_e
+{
+ GOLA_DEFBUNDLE,
+ GOLA_FDHUSER,
+ GOLA_CONVFILE,
+ GOLA_SET,
+ GOLA_TIMEOUT,
+ GOLA_N
+} ;
+
+void set_apply (char const *const *argv)
+{
+ static gol_bool const rgolb[] =
+ {
+ { .so = 'b', .lo = "block", .clear = 0, .set = GOLB_BLOCK },
+ } ;
+ static gol_arg const rgola[] =
+ {
+ { .so = 'D', .lo = "default-bundle", .i = GOLA_DEFBUNDLE },
+ { .so = 'h', .lo = "fdholder-user", .i = GOLA_FDHUSER },
+ { .so = 'f', .lo = "conversion-file", .i = GOLA_CONVFILE },
+ { .so = 's', .lo = "set", .i = GOLA_SET },
+ { .so = 't', .lo = "timeout", .i = GOLA_TIMEOUT },
+ } ;
+ uint64_t wgolb = 0 ;
+ unsigned int timeout = 0 ;
+ unsigned int m = 0 ;
+ int wstat ;
+ pid_t pid ;
+ char const *wgola[GOLA_N] = { 0 } ;
+ char const *newargv[15] ;
+ char fmtv[UINT_FMT] ;
+ char fmtt[UINT_FMT] ;
+
+ wgola[GOLA_DEFBUNDLE] = S6_FRONTEND_DEFBUNDLE ;
+ wgola[GOLA_SET] = "current" ;
+
+ argv += GOL_argv(argv, rgolb, rgola, &wgolb, wgola) ;
+
+ if (wgola[GOLA_TIMEOUT])
+ {
+ if (!uint0_scan(wgola[GOLA_TIMEOUT], &timeout))
+ strerr_dief1x(100, "timeout must be an integer (milliseconds)") ;
+ }
+
+ /* set commit */
+ newargv[m++] = S6RC_EXTBINPREFIX "s6-rc-set-commit" ;
+ if (g->verbosity != 1)
+ {
+ fmtv[uint_fmt(fmtv, g->verbosity)] = 0 ;
+ newargv[m++] = "-v" ;
+ newargv[m++] = fmtv ;
+ }
+ newargv[m++] = "-r" ;
+ newargv[m++] = g->dirs.repo ;
+ newargv[m++] = "-D" ;
+ newargv[m++] = wgola[GOLA_DEFBUNDLE] ;
+ if (wgola[GOLA_FDHUSER])
+ {
+ newargv[m++] = "-h" ;
+ newargv[m++] = wgola[GOLA_FDHUSER] ;
+ }
+ newargv[m++] = "--" ;
+ newargv[m++] = wgola[GOLA_SET] ;
+ newargv[m++] = 0 ;
+
+ pid = main_spawn(newargv) ;
+ if (wait_pid(pid, &wstat) == -1)
+ strerr_diefusys(111, "wait for ", newargv[0]) ;
+ if (wait_estatus(wstat))
+ strerr_dief(wait_estatus(wstat), newargv[0], " failed") ;
+
+ /* live install */
+ m = 0 ;
+ newargv[m++] = S6RC_EXTBINPREFIX "s6-rc-set-install" ;
+ if (g->verbosity != 1)
+ {
+ newargv[m++] = "-v" ;
+ newargv[m++] = fmtv ;
+ }
+ newargv[m++] = "-r" ;
+ newargv[m++] = g->dirs.repo ;
+ newargv[m++] = "-c" ;
+ newargv[m++] = g->dirs.boot ;
+ newargv[m++] = "-l" ;
+ newargv[m++] = g->dirs.live ;
+
+ if (wgolb & GOLB_BLOCK) newargv[m++] = "-b" ;
+ if (wgola[GOLA_CONVFILE])
+ {
+ newargv[m++] = "-f" ;
+ newargv[m++] = wgola[GOLA_CONVFILE] ;
+ }
+ newargv[m++] = "--" ;
+ newargv[m++] = wgola[GOLA_SET] ;
+ newargv[m++] = 0 ;
+
+ pid = main_spawn(newargv) ;
+ if (wait_pid(pid, &wstat) == -1)
+ strerr_diefusys(111, "wait for ", newargv[0]) ;
+ if (wait_estatus(wstat))
+ strerr_dief(wait_estatus(wstat), newargv[0], " failed") ;
+
+ /* live reset */
+ m = 0 ;
+ newargv[m++] = S6RC_EXTBINPREFIX "s6-rc" ;
+ if (g->verbosity != 1)
+ {
+ newargv[m++] = "-v" ;
+ newargv[m++] = fmtv ;
+ }
+ if (timeout)
+ {
+ fmtt[uint_fmt(fmtt, timeout)] = 0 ;
+ newargv[m++] = "-t" ;
+ newargv[m++] = fmtt ;
+ }
+ newargv[m++] = "-pe" ;
+ newargv[m++] = "-l" ;
+ newargv[m++] = g->dirs.live ;
+ if (wgolb & GOLB_BLOCK) newargv[m++] = "-b" ;
+ newargv[m++] = "--" ;
+ newargv[m++] = "change" ;
+ newargv[m++] = wgola[GOLA_DEFBUNDLE] ;
+ newargv[m++] = 0 ;
+ main_exec(argv) ;
+}
diff --git a/src/s6-frontend/set_change.c b/src/s6-frontend/set_change.c
index a0db9b7..deefe5e 100644
--- a/src/s6-frontend/set_change.c
+++ b/src/s6-frontend/set_change.c
@@ -11,9 +11,9 @@
enum golb_e
{
- GOLB_DRYRUN = 0x02,
- GOLB_FAIL_ON_DEPS = 0x04,
- GOLB_PULL_DEPS = 0x08,
+ GOLB_DRYRUN = 0x01,
+ GOLB_FAIL_ON_DEPS = 0x02,
+ GOLB_PULL_DEPS = 0x04,
} ;
enum gola_e