aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLaurent Bercot <ska-skaware@skarnet.org>2025-11-26 11:02:51 +0000
committerLaurent Bercot <ska-skaware@skarnet.org>2025-11-26 11:02:51 +0000
commit047b747ec72f42f2f1549ae497b9adf72e54feb5 (patch)
tree335a3def8ef7b2920d747279d3cdb191c61aef83
parentc00521078b8277964be155e44da84e9db72b0929 (diff)
downloads6-frontend-047b747ec72f42f2f1549ae497b9adf72e54feb5.tar.gz
Complete base functionality
-rw-r--r--package/deps.mak8
-rw-r--r--src/s6-frontend/deps-exe/s6-frontend6
-rw-r--r--src/s6-frontend/live_status.c65
-rw-r--r--src/s6-frontend/repository.c2
-rw-r--r--src/s6-frontend/repository_init.c44
-rw-r--r--src/s6-frontend/s6-frontend-internal.h15
-rw-r--r--src/s6-frontend/set.c35
-rw-r--r--src/s6-frontend/set_change.c26
-rw-r--r--src/s6-frontend/set_init.c83
9 files changed, 129 insertions, 155 deletions
diff --git a/package/deps.mak b/package/deps.mak
index 9d75108..1948c21 100644
--- a/package/deps.mak
+++ b/package/deps.mak
@@ -26,12 +26,16 @@ src/s6-frontend/process_status.o src/s6-frontend/process_status.lo: src/s6-front
src/s6-frontend/repository.o src/s6-frontend/repository.lo: src/s6-frontend/repository.c src/s6-frontend/s6-frontend-internal.h
src/s6-frontend/repository_help.o src/s6-frontend/repository_help.lo: src/s6-frontend/repository_help.c src/s6-frontend/s6-frontend-internal.h
src/s6-frontend/repository_init.o src/s6-frontend/repository_init.lo: src/s6-frontend/repository_init.c src/s6-frontend/s6-frontend-internal.h src/include/s6-frontend/config.h
+src/s6-frontend/repository_list.o src/s6-frontend/repository_list.lo: src/s6-frontend/repository_list.c src/s6-frontend/s6-frontend-internal.h
+src/s6-frontend/repository_sync.o src/s6-frontend/repository_sync.lo: src/s6-frontend/repository_sync.c src/s6-frontend/s6-frontend-internal.h
src/s6-frontend/s6-frontend.o src/s6-frontend/s6-frontend.lo: src/s6-frontend/s6-frontend.c src/s6-frontend/s6-frontend-internal.h
src/s6-frontend/s6.o src/s6-frontend/s6.lo: src/s6-frontend/s6.c src/include/s6-frontend/config.h
src/s6-frontend/set.o src/s6-frontend/set.lo: src/s6-frontend/set.c src/s6-frontend/s6-frontend-internal.h
src/s6-frontend/set_change.o src/s6-frontend/set_change.lo: src/s6-frontend/set_change.c src/s6-frontend/s6-frontend-internal.h
+src/s6-frontend/set_copy.o src/s6-frontend/set_copy.lo: src/s6-frontend/set_copy.c src/s6-frontend/s6-frontend-internal.h
src/s6-frontend/set_help.o src/s6-frontend/set_help.lo: src/s6-frontend/set_help.c src/s6-frontend/s6-frontend-internal.h
-src/s6-frontend/set_init.o src/s6-frontend/set_init.lo: src/s6-frontend/set_init.c src/s6-frontend/s6-frontend-internal.h src/include/s6-frontend/config.h
+src/s6-frontend/set_list.o src/s6-frontend/set_list.lo: src/s6-frontend/set_list.c src/s6-frontend/s6-frontend-internal.h
+src/s6-frontend/set_status.o src/s6-frontend/set_status.lo: src/s6-frontend/set_status.c src/s6-frontend/s6-frontend-internal.h src/include/s6-frontend/config.h
s6-frontend-helper-kill: EXTRA_LIBS :=
s6-frontend-helper-kill: src/helpers/s6-frontend-helper-kill.o -lskarnet
@@ -43,5 +47,5 @@ endif
s6: EXTRA_LIBS :=
s6: src/s6-frontend/s6.o -lskarnet
s6-frontend: EXTRA_LIBS := ${MAYBEPTHREAD_LIB}
-s6-frontend: src/s6-frontend/s6-frontend.o src/s6-frontend/help.o src/s6-frontend/live.o src/s6-frontend/live_boot.o src/s6-frontend/live_help.o src/s6-frontend/live_hpr.o src/s6-frontend/live_startstop.o src/s6-frontend/live_status.o src/s6-frontend/live_stop_everything.o src/s6-frontend/process.o src/s6-frontend/process_help.o src/s6-frontend/process_kill.o src/s6-frontend/process_restart.o src/s6-frontend/process_startstop.o src/s6-frontend/process_status.o src/s6-frontend/repository.o src/s6-frontend/repository_help.o src/s6-frontend/repository_init.o src/s6-frontend/set.o src/s6-frontend/set_change.o src/s6-frontend/set_help.o src/s6-frontend/set_init.o libs6f.a.xyzzy ${LIBNSSS} -ls6rc -ls6 -lskarnet
+s6-frontend: src/s6-frontend/s6-frontend.o src/s6-frontend/help.o src/s6-frontend/live.o src/s6-frontend/live_boot.o src/s6-frontend/live_help.o src/s6-frontend/live_hpr.o src/s6-frontend/live_startstop.o src/s6-frontend/live_status.o src/s6-frontend/live_stop_everything.o src/s6-frontend/process.o src/s6-frontend/process_help.o src/s6-frontend/process_kill.o src/s6-frontend/process_restart.o src/s6-frontend/process_startstop.o src/s6-frontend/process_status.o src/s6-frontend/repository.o src/s6-frontend/repository_help.o src/s6-frontend/repository_init.o src/s6-frontend/repository_list.o src/s6-frontend/repository_sync.o src/s6-frontend/set.o src/s6-frontend/set_change.o src/s6-frontend/set_copy.o src/s6-frontend/set_help.o src/s6-frontend/set_list.o src/s6-frontend/set_status.o libs6f.a.xyzzy ${LIBNSSS} -ls6rc -ls6 -lskarnet
INTERNAL_LIBS := libs6f.a.xyzzy
diff --git a/src/s6-frontend/deps-exe/s6-frontend b/src/s6-frontend/deps-exe/s6-frontend
index 3c28943..ff93238 100644
--- a/src/s6-frontend/deps-exe/s6-frontend
+++ b/src/s6-frontend/deps-exe/s6-frontend
@@ -15,10 +15,14 @@ process_status.o
repository.o
repository_help.o
repository_init.o
+repository_list.o
+repository_sync.o
set.o
set_change.o
+set_copy.o
set_help.o
-set_init.o
+set_list.o
+set_status.o
libs6f.a.xyzzy
${LIBNSSS}
-ls6rc
diff --git a/src/s6-frontend/live_status.c b/src/s6-frontend/live_status.c
index df42aed..f103363 100644
--- a/src/s6-frontend/live_status.c
+++ b/src/s6-frontend/live_status.c
@@ -24,30 +24,36 @@
static void live_status_all (void) gccattr_noreturn ;
static void live_status_all (void)
{
- static char const *const argv[] =
- {
+ char const *argv[23] ;
+ unsigned int m = 0 ;
#ifdef S6_FRONTEND_USE_UTIL_LINUX
- EXECLINE_EXTBINPREFIX "pipeline", "-w", "--",
- " column", " -ts/",
- "",
+ if (g->color)
+ {
+ argv[m++] = EXECLINE_EXTBINPREFIX "pipeline" ;
+ argv[m++] = "-w" ;
+ argv[m++] = "--" ;
+ argv[m++] = " column" ;
+ argv[m++] = " -ts/" ;
+ argv[m++] = "" ;
+ }
#endif
- EXECLINE_EXTBINPREFIX "if",
- " " EXECLINE_EXTBINPREFIX "pipeline",
- " " S6RC_EXTBINPREFIX "s6-rc",
- " -ua",
- " list",
- " ",
- " sed",
- " s|$|/up",
- "",
- " " S6RC_EXTBINPREFIX "s6-rc",
- " -da",
- " list",
- "",
- "sed",
- "s|$|/down",
- 0
- } ;
+ argv[m++] = EXECLINE_EXTBINPREFIX "if" ;
+ argv[m++] = " " EXECLINE_EXTBINPREFIX "pipeline" ;
+ argv[m++] = " " S6RC_EXTBINPREFIX "s6-rc" ;
+ argv[m++] = " -ua" ;
+ argv[m++] = " list" ;
+ argv[m++] = " " ;
+ argv[m++] = " sed" ;
+ argv[m++] = " s|$|/up" ;
+ argv[m++] = "" ;
+ argv[m++] = EXECLINE_EXTBINPREFIX "pipeline" ;
+ argv[m++] = " " S6RC_EXTBINPREFIX "s6-rc" ;
+ argv[m++] = " -da" ;
+ argv[m++] = " list" ;
+ argv[m++] = "" ;
+ argv[m++] = "sed" ;
+ argv[m++] = "s|$|/down" ;
+ argv[m++] = 0 ;
xmexec_n(argv, cleanup_modif.s, cleanup_modif.len, cleanup_modif.n) ;
}
@@ -141,12 +147,15 @@ static void live_status_some (char const *const *services)
if (!stralloc_0(&sa)) dienomem() ;
#ifdef S6_FRONTEND_USE_UTIL_LINUX
- argv[m++] = EXECLINE_EXTBINPREFIX "pipeline" ;
- argv[m++] = "-w" ;
- argv[m++] = "--" ;
- argv[m++] = " column" ;
- argv[m++] = " -ts/" ;
- argv[m++] = "",
+ if (g->color)
+ {
+ argv[m++] = EXECLINE_EXTBINPREFIX "pipeline" ;
+ argv[m++] = "-w" ;
+ argv[m++] = "--" ;
+ argv[m++] = " column" ;
+ argv[m++] = " -ts/" ;
+ argv[m++] = "",
+ }
#endif
argv[m++] = EXECLINE_EXTBINPREFIX "if" ;
argv[m++] = " " EXECLINE_EXTBINPREFIX "piperw" ;
diff --git a/src/s6-frontend/repository.c b/src/s6-frontend/repository.c
index 1f78811..923bf68 100644
--- a/src/s6-frontend/repository.c
+++ b/src/s6-frontend/repository.c
@@ -15,6 +15,8 @@ void repository (char const *const *argv)
{
{ .s = "help", .f = &repository_help },
{ .s = "init", .f = &repository_init },
+ { .s = "list", .f = &repository_list },
+ { .s = "sync", .f = &repository_sync },
} ;
struct command_s *cmd ;
argv += gol_argv(argv, 0, 0, 0, 0, 0, 0) ;
diff --git a/src/s6-frontend/repository_init.c b/src/s6-frontend/repository_init.c
index ad2e639..e26c816 100644
--- a/src/s6-frontend/repository_init.c
+++ b/src/s6-frontend/repository_init.c
@@ -1,10 +1,14 @@
/* ISC license. */
#include <string.h>
+#include <sys/wait.h>
+#include <unistd.h>
#include <skalibs/uint64.h>
#include <skalibs/types.h>
#include <skalibs/envexec.h>
+#include <skalibs/cspawn.h>
+#include <skalibs/djbunix.h>
#include <s6-rc/config.h>
@@ -14,6 +18,7 @@
enum golb_e
{
GOLB_FORCE = 0x01,
+ GOLB_UPDATE = 0x02,
} ;
enum gola_e
@@ -28,6 +33,7 @@ void repository_init (char const *const *argv)
static gol_bool const rgolb[] =
{
{ .so = 'f', .lo = "force", .clear = 0, .set = GOLB_FORCE },
+ { .so = 'U', .lo = "update-stores", .clear = 0, .set = GOLB_UPDATE },
} ;
static gol_arg const rgola[] =
{
@@ -53,18 +59,15 @@ void repository_init (char const *const *argv)
}
if (storage[len-1]) { n++ ; storage[len] = 0 ; }
- char const *newargv[10 + n] ;
+ char const *newargv[11 + n] ;
+ fmtv[uint_fmt(fmtv, g->verbosity)] = 0 ;
newargv[m++] = S6RC_EXTBINPREFIX "s6-rc-repo-init" ;
- if (g->verbosity != 1)
- {
- fmtv[uint_fmt(fmtv, g->verbosity)] = 0 ;
- newargv[m++] = "-v" ;
- newargv[m++] = fmtv ;
- }
+ newargv[m++] = "-v" ;
+ newargv[m++] = fmtv ;
newargv[m++] = "-r" ;
newargv[m++] = g->dirs.repo ;
- if (wgolb & GOLB_FORCE)
- newargv[m++] = "-f" ;
+ if (wgolb & GOLB_FORCE) newargv[m++] = "-f" ;
+ if (wgolb & GOLB_UPDATE) newargv[m++] = "-U" ;
if (wgola[GOLA_FDHUSER])
{
newargv[m++] = "-h" ;
@@ -78,5 +81,26 @@ void repository_init (char const *const *argv)
len += strlen(storage + len) + 1 ;
}
newargv[m++] = 0 ;
- xmexec_n(newargv, cleanup_modif.s, cleanup_modif.len, cleanup_modif.n) ;
+ if (wgolb & GOLB_UPDATE)
+ xmexec_n(newargv, cleanup_modif.s, cleanup_modif.len, cleanup_modif.n) ;
+ else
+ {
+ int wstat ;
+ pid_t pid = xmspawn_n(newargv, cleanup_modif.s, cleanup_modif.len, cleanup_modif.n, 0, 0, 0) ;
+ if (wait_pid(pid, &wstat) == -1) strerr_diefu1sys(111, "wait_pid") ;
+ if (wait_estatus(wstat)) _exit(wait_estatus(wstat)) ;
+ m = 0 ;
+ newargv[m++] = S6RC_EXTBINPREFIX "s6-rc-set-new" ;
+ if (g->verbosity != 1)
+ {
+ newargv[m++] = "-v" ;
+ newargv[m++] = fmtv ;
+ }
+ newargv[m++] = "-r" ;
+ newargv[m++] = g->dirs.repo ;
+ newargv[m++] = "--" ;
+ newargv[m++] = "current" ;
+ newargv[m++] = 0 ;
+ xmexec_n(newargv, cleanup_modif.s, cleanup_modif.len, cleanup_modif.n) ;
+ }
}
diff --git a/src/s6-frontend/s6-frontend-internal.h b/src/s6-frontend/s6-frontend-internal.h
index 93e8b19..91e76b5 100644
--- a/src/s6-frontend/s6-frontend-internal.h
+++ b/src/s6-frontend/s6-frontend-internal.h
@@ -66,15 +66,28 @@ extern void repository (char const *const *) gccattr_noreturn ;
extern void repository_help (char const *const *) gccattr_noreturn ;
extern void repository_init (char const *const *) gccattr_noreturn ;
+extern void repository_sync (char const *const *) gccattr_noreturn ;
+extern void repository_list (char const *const *) gccattr_noreturn ;
/* set */
-extern void set_change (char const *const *argv, char const *, char const *) gccattr_noreturn ;
+extern int set_check_service_names (char const *const *, unsigned int) ;
extern void set (char const *const *) gccattr_noreturn ;
extern void set_help (char const *const *) gccattr_noreturn ;
+extern void set_list (char const *const *) gccattr_noreturn ;
+extern void set_status (char const *const *) gccattr_noreturn ;
+
+extern void set_load (char const *const *) gccattr_noreturn ;
+extern void set_save (char const *const *) gccattr_noreturn ;
+
+extern void set_mask (char const *const *) gccattr_noreturn ;
+extern void set_unmask (char const *const *) gccattr_noreturn ;
+extern void set_enable (char const *const *) gccattr_noreturn ;
+extern void set_disable (char const *const *) gccattr_noreturn ;
+
/* main */
diff --git a/src/s6-frontend/set.c b/src/s6-frontend/set.c
index d31c50c..637b127 100644
--- a/src/s6-frontend/set.c
+++ b/src/s6-frontend/set.c
@@ -11,28 +11,12 @@
#define USAGE "s6 set subcommand [ subcommand options ] [ services... ] Type \"s6 set help\" for details."
#define dieusage() strerr_dieusage(100, USAGE)
-static void set_disable (char const *const *argv) gccattr_noreturn ;
-static void set_disable (char const *const *argv)
+int set_check_service_names (char const *const *names, unsigned int n)
{
- set_change(argv, "latent", "disable") ;
-}
-
-static void set_enable (char const *const *argv) gccattr_noreturn ;
-static void set_enable (char const *const *argv)
-{
- set_change(argv, "active", "enable") ;
-}
-
-static void set_mask (char const *const *argv) gccattr_noreturn ;
-static void set_mask (char const *const *argv)
-{
- set_change(argv, "masked", "mask") ;
-}
-
-static void set_unmask (char const *const *argv) gccattr_noreturn ;
-static void set_unmask (char const *const *argv)
-{
- set_change(argv, "latent", "unmask") ;
+ for (unsigned int i = 0 ; i < n ; i++)
+ if (names[i][0] == '.' || strchr(names[i], '/') || strchr(names[i], '\n'))
+ return 0 ;
+ return 1 ;
}
void set (char const *const *argv)
@@ -42,12 +26,11 @@ void set (char const *const *argv)
{ .s = "disable", .f = &set_disable },
{ .s = "enable", .f = &set_enable },
{ .s = "help", .f = &set_help },
-// { .s = "list", .f = &set_list },
-// { .s = "load", .f = &set_load },
+ { .s = "list", .f = &set_list },
+ { .s = "load", .f = &set_load },
{ .s = "mask", .f = &set_mask },
-// { .s = "save", .f = &set_save },
-// { .s = "status", .f = &set_status },
-// { .s = "sync", .f = &set_sync },
+ { .s = "save", .f = &set_save },
+ { .s = "status", .f = &set_status },
{ .s = "unmask", .f = &set_unmask },
} ;
struct command_s *cmd ;
diff --git a/src/s6-frontend/set_change.c b/src/s6-frontend/set_change.c
index b5fa2d2..bc222d9 100644
--- a/src/s6-frontend/set_change.c
+++ b/src/s6-frontend/set_change.c
@@ -1,8 +1,5 @@
/* ISC license. */
-#include <string.h>
-#include <unistd.h>
-
#include <skalibs/gccattributes.h>
#include <skalibs/uint64.h>
#include <skalibs/types.h>
@@ -24,7 +21,8 @@ enum gola_e
GOLA_N
} ;
-void set_change (char const *const *argv, char const *newsub, char const *cmd)
+static void set_change (char const *const *argv, char const *newsub, char const *cmd) gccattr_noreturn ;
+static void set_change (char const *const *argv, char const *newsub, char const *cmd)
{
static gol_bool const rgolb[] =
{
@@ -78,3 +76,23 @@ void set_change (char const *const *argv, char const *newsub, char const *cmd)
newargv[m++] = 0 ;
xmexec_n(newargv, cleanup_modif.s, cleanup_modif.len, cleanup_modif.n) ;
}
+
+void set_disable (char const *const *argv)
+{
+ set_change(argv, "latent", "disable") ;
+}
+
+void set_enable (char const *const *argv)
+{
+ set_change(argv, "active", "enable") ;
+}
+
+void set_mask (char const *const *argv)
+{
+ set_change(argv, "masked", "mask") ;
+}
+
+void set_unmask (char const *const *argv)
+{
+ set_change(argv, "latent", "unmask") ;
+}
diff --git a/src/s6-frontend/set_init.c b/src/s6-frontend/set_init.c
deleted file mode 100644
index 3a5225b..0000000
--- a/src/s6-frontend/set_init.c
+++ /dev/null
@@ -1,83 +0,0 @@
-/* ISC license. */
-
-#include <string.h>
-
-#include <skalibs/gccattributes.h>
-#include <skalibs/uint64.h>
-#include <skalibs/types.h>
-#include <skalibs/envexec.h>
-
-#include <s6-rc/config.h>
-
-#include <s6-frontend/config.h>
-#include "s6-frontend-internal.h"
-
-enum golb_e
-{
- GOLB_FORCE = 0x01,
-} ;
-
-enum gola_e
-{
- GOLA_FDHUSER,
- GOLA_STOREPATH,
- GOLA_N
-} ;
-
-void set_init (char const *const *argv)
-{
- static gol_bool const rgolb[] =
- {
- { .so = 'f', .lo = "force", .clear = 0, .set = GOLB_FORCE },
- } ;
- static gol_arg const rgola[] =
- {
- { .so = 'h', .lo = "fdholder-user", .i = GOLA_FDHUSER },
- { .so = 'p', .lo = "store-path", .i = GOLA_STOREPATH },
- } ;
- uint64_t wgolb = 0 ;
- unsigned int m = 0 ;
- unsigned int n = 0 ;
- char const *wgola[GOLA_N] = { 0 } ;
- size_t len ;
- char fmtv[UINT_FMT] ;
-
- wgola[GOLA_STOREPATH] = S6_FRONTEND_STOREPATH ;
- argv += GOL_argv(argv, rgolb, rgola, &wgolb, wgola) ;
-
- len = strlen(wgola[GOLA_STOREPATH]) ;
- char storage[len+1] ;
- for (size_t i = 0 ; i < len ; i++)
- {
- if (wgola[GOLA_STOREPATH][i] == ':') { n++ ; storage[i] = 0 ; }
- else storage[i] = wgola[GOLA_STOREPATH][i] ;
- }
- if (storage[len-1]) { n++ ; storage[len] = 0 ; }
-
- char const *newargv[10 + n] ;
- newargv[m++] = S6RC_EXTBINPREFIX "s6-rc-repo-init" ;
- 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 ;
- if (wgolb & GOLB_FORCE)
- newargv[m++] = "-f" ;
- if (wgola[GOLA_FDHUSER])
- {
- newargv[m++] = "-h" ;
- newargv[m++] = wgola[GOLA_FDHUSER] ;
- }
- newargv[m++] = "--" ;
- len = 0 ;
- for (unsigned int i = 0 ; i < n ; i++)
- {
- newargv[m++] = storage + len ;
- len += strlen(storage + len) + 1 ;
- }
- newargv[m++] = 0 ;
- xmexec_n(newargv, cleanup_modif.s, cleanup_modif.len, cleanup_modif.n) ;
-}