diff options
| author | Laurent Bercot <ska-skaware@skarnet.org> | 2025-12-21 20:13:58 +0000 |
|---|---|---|
| committer | Laurent Bercot <ska-skaware@skarnet.org> | 2025-12-21 20:13:58 +0000 |
| commit | 6a5e2bb5b7b605048d1829725424ab85f70affc7 (patch) | |
| tree | e2c1832e36d59cf8c55f680adae80a3302a7872d | |
| parent | 047b747ec72f42f2f1549ae497b9adf72e54feb5 (diff) | |
| download | s6-frontend-6a5e2bb5b7b605048d1829725424ab85f70affc7.tar.gz | |
Complete set of commands for s6-frontend
| -rw-r--r-- | package/deps.mak | 5 | ||||
| -rw-r--r-- | src/s6-frontend/deps-exe/s6-frontend | 3 | ||||
| -rw-r--r-- | src/s6-frontend/live.c | 1 | ||||
| -rw-r--r-- | src/s6-frontend/live_install.c | 67 | ||||
| -rw-r--r-- | src/s6-frontend/live_status.c | 2 | ||||
| -rw-r--r-- | src/s6-frontend/repository_list.c | 30 | ||||
| -rw-r--r-- | src/s6-frontend/repository_sync.c | 46 | ||||
| -rw-r--r-- | src/s6-frontend/s6-frontend-internal.h | 5 | ||||
| -rw-r--r-- | src/s6-frontend/set.c | 2 | ||||
| -rw-r--r-- | src/s6-frontend/set_change.c | 4 | ||||
| -rw-r--r-- | src/s6-frontend/set_check.c | 55 | ||||
| -rw-r--r-- | src/s6-frontend/set_commit.c | 68 | ||||
| -rw-r--r-- | src/s6-frontend/set_copy.c | 65 | ||||
| -rw-r--r-- | src/s6-frontend/set_list.c | 33 | ||||
| -rw-r--r-- | src/s6-frontend/set_status.c | 65 |
15 files changed, 447 insertions, 4 deletions
diff --git a/package/deps.mak b/package/deps.mak index 1948c21..2b5bbdb 100644 --- a/package/deps.mak +++ b/package/deps.mak @@ -14,6 +14,7 @@ src/s6-frontend/live.o src/s6-frontend/live.lo: src/s6-frontend/live.c src/s6-fr src/s6-frontend/live_boot.o src/s6-frontend/live_boot.lo: src/s6-frontend/live_boot.c src/s6-frontend/s6-frontend-internal.h src/include/s6-frontend/config.h src/s6-frontend/live_help.o src/s6-frontend/live_help.lo: src/s6-frontend/live_help.c src/s6-frontend/s6-frontend-internal.h src/s6-frontend/live_hpr.o src/s6-frontend/live_hpr.lo: src/s6-frontend/live_hpr.c src/s6-frontend/s6-frontend-internal.h src/include/s6-frontend/config.h +src/s6-frontend/live_install.o src/s6-frontend/live_install.lo: src/s6-frontend/live_install.c src/s6-frontend/s6-frontend-internal.h src/s6-frontend/live_startstop.o src/s6-frontend/live_startstop.lo: src/s6-frontend/live_startstop.c src/s6-frontend/s6-frontend-internal.h src/s6-frontend/live_status.o src/s6-frontend/live_status.lo: src/s6-frontend/live_status.c src/s6-frontend/s6-frontend-internal.h src/include/s6-frontend/config.h src/s6-frontend/live_stop_everything.o src/s6-frontend/live_stop_everything.lo: src/s6-frontend/live_stop_everything.c src/s6-frontend/s6-frontend-internal.h @@ -32,6 +33,8 @@ src/s6-frontend/s6-frontend.o src/s6-frontend/s6-frontend.lo: src/s6-frontend/s6 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_check.o src/s6-frontend/set_check.lo: src/s6-frontend/set_check.c src/s6-frontend/s6-frontend-internal.h src/include/s6-frontend/config.h +src/s6-frontend/set_commit.o src/s6-frontend/set_commit.lo: src/s6-frontend/set_commit.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_list.o src/s6-frontend/set_list.lo: src/s6-frontend/set_list.c src/s6-frontend/s6-frontend-internal.h @@ -47,5 +50,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/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 +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_install.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_check.o src/s6-frontend/set_commit.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 ff93238..d322eb7 100644 --- a/src/s6-frontend/deps-exe/s6-frontend +++ b/src/s6-frontend/deps-exe/s6-frontend @@ -3,6 +3,7 @@ live.o live_boot.o live_help.o live_hpr.o +live_install.o live_startstop.o live_status.o live_stop_everything.o @@ -19,6 +20,8 @@ repository_list.o repository_sync.o set.o set_change.o +set_check.o +set_commit.o set_copy.o set_help.o set_list.o diff --git a/src/s6-frontend/live.c b/src/s6-frontend/live.c index e401552..cd1f70a 100644 --- a/src/s6-frontend/live.c +++ b/src/s6-frontend/live.c @@ -18,6 +18,7 @@ void live (char const *const *argv) { .s = "boot", .f = &live_boot }, { .s = "halt", .f = &live_halt }, { .s = "help", .f = &live_help }, + { .s = "install", .f = &live_install }, { .s = "poweroff", .f = &live_poweroff }, { .s = "reboot", .f = &live_reboot }, { .s = "restart", .f = &live_restart }, diff --git a/src/s6-frontend/live_install.c b/src/s6-frontend/live_install.c new file mode 100644 index 0000000..6c85b96 --- /dev/null +++ b/src/s6-frontend/live_install.c @@ -0,0 +1,67 @@ +/* ISC license. */ + +#include <skalibs/uint64.h> +#include <skalibs/types.h> +#include <skalibs/envexec.h> + +#include <s6-rc/config.h> + +#include "s6-frontend-internal.h" + +enum golb_e +{ + GOLB_BLOCK = 0x01, + GOLB_KEEPOLD = 0x02, +} ; + +enum gola_e +{ + GOLA_CONVFILE, + GOLA_N +} ; + +void live_install (char const *const *argv) +{ + static gol_bool const rgolb[] = + { + { .so = 'b', .lo = "block", .clear = 0, .set = GOLB_BLOCK }, + { .so = 'K', .lo = "keep-old", .clear = 0, .set = GOLB_KEEPOLD }, + } ; + static gol_arg const rgola[] = + { + { .so = 'f', .lo = "conversion-file", .i = GOLA_CONVFILE }, + } ; + uint64_t wgolb = 0 ; + unsigned int m = 0 ; + char const *wgola[GOLA_N] = { 0 } ; + char const *newargv[16] ; + char fmtv[UINT_FMT] ; + + argv += GOL_argv(argv, rgolb, rgola, &wgolb, wgola) ; + + newargv[m++] = S6RC_EXTBINPREFIX "s6-rc-set-install" ; + 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++] = "-c" ; + newargv[m++] = g->dirs.boot ; + newargv[m++] = "-l" ; + newargv[m++] = g->dirs.live ; + + if (wgolb & GOLB_BLOCK) newargv[m++] = "-b" ; + if (wgolb & GOLB_KEEPOLD) newargv[m++] = "-K" ; + if (wgola[GOLA_CONVFILE]) + { + newargv[m++] = "-f" ; + newargv[m++] = wgola[GOLA_CONVFILE] ; + } + 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/live_status.c b/src/s6-frontend/live_status.c index f103363..a68d99f 100644 --- a/src/s6-frontend/live_status.c +++ b/src/s6-frontend/live_status.c @@ -218,5 +218,5 @@ void live_status (char const *const *argv) argv += gol_argv(argv, 0, 0, 0, 0, 0, 0) ; if (!argv) live_status_all() ; else live_status_some(argv) ; - // _exit(0) ; + _exit(0) ; } diff --git a/src/s6-frontend/repository_list.c b/src/s6-frontend/repository_list.c new file mode 100644 index 0000000..fc734d2 --- /dev/null +++ b/src/s6-frontend/repository_list.c @@ -0,0 +1,30 @@ +/* ISC license. */ + +#include <skalibs/envexec.h> +#include <skalibs/types.h> + +#include <s6-rc/config.h> + +#include "s6-frontend-internal.h" + +void repository_list (char const *const *argv) +{ + char const *newargv[9] ; + unsigned int m = 0 ; + char fmtv[UINT_FMT] ; + newargv[m++] = S6RC_EXTBINPREFIX "s6-rc-repo-list" ; + 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++] = "-x" ; + newargv[m++] = "current" ; + newargv[m++] = "--" ; + newargv[m++] = 0 ; + + xmexec_n(newargv, cleanup_modif.s, cleanup_modif.len, cleanup_modif.n) ; +} diff --git a/src/s6-frontend/repository_sync.c b/src/s6-frontend/repository_sync.c new file mode 100644 index 0000000..1799c7c --- /dev/null +++ b/src/s6-frontend/repository_sync.c @@ -0,0 +1,46 @@ +/* ISC license. */ + +#include <skalibs/types.h> +#include <skalibs/envexec.h> + +#include <s6-rc/config.h> + +#include "s6-frontend-internal.h" + +enum gola_e +{ + GOLA_FDHUSER, + GOLA_N +} ; + +void repository_sync (char const *const *argv) +{ + static gol_arg const rgola[] = + { + { .so = 'h', .lo = "fdholder-user", .i = GOLA_FDHUSER }, + } ; + unsigned int m = 0 ; + char const *wgola[GOLA_N] = { 0 } ; + char fmtv[UINT_FMT] ; + + argv += gol_argv(argv, 0, 0, rgola, GOLA_N, 0, wgola) ; + + char const *newargv[9] ; + newargv[m++] = S6RC_EXTBINPREFIX "s6-rc-repo-sync" ; + 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 (wgola[GOLA_FDHUSER]) + { + newargv[m++] = "-h" ; + newargv[m++] = wgola[GOLA_FDHUSER] ; + } + newargv[m++] = "--" ; + 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 91e76b5..a535e9e 100644 --- a/src/s6-frontend/s6-frontend-internal.h +++ b/src/s6-frontend/s6-frontend-internal.h @@ -44,6 +44,8 @@ extern void live_status (char const *const *) gccattr_noreturn ; extern void live_stop (char const *const *) gccattr_noreturn ; extern void live_stop_everything (char const *const *) gccattr_noreturn ; +extern void live_install (char const *const *) gccattr_noreturn ; + /* process */ @@ -88,6 +90,9 @@ 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 ; +extern void set_check (char const *const *) gccattr_noreturn ; +extern void set_commit (char const *const *) gccattr_noreturn ; + /* main */ diff --git a/src/s6-frontend/set.c b/src/s6-frontend/set.c index 637b127..8774aa5 100644 --- a/src/s6-frontend/set.c +++ b/src/s6-frontend/set.c @@ -23,6 +23,8 @@ void set (char const *const *argv) { static struct command_s const commands[] = { + { .s = "check", .f = &set_check }, + { .s = "commit", .f = &set_commit }, { .s = "disable", .f = &set_disable }, { .s = "enable", .f = &set_enable }, { .s = "help", .f = &set_help }, diff --git a/src/s6-frontend/set_change.c b/src/s6-frontend/set_change.c index bc222d9..5353422 100644 --- a/src/s6-frontend/set_change.c +++ b/src/s6-frontend/set_change.c @@ -79,7 +79,7 @@ static void set_change (char const *const *argv, char const *newsub, char const void set_disable (char const *const *argv) { - set_change(argv, "latent", "disable") ; + set_change(argv, "usable", "disable") ; } void set_enable (char const *const *argv) @@ -94,5 +94,5 @@ void set_mask (char const *const *argv) void set_unmask (char const *const *argv) { - set_change(argv, "latent", "unmask") ; + set_change(argv, "usable", "unmask") ; } diff --git a/src/s6-frontend/set_check.c b/src/s6-frontend/set_check.c new file mode 100644 index 0000000..4abda87 --- /dev/null +++ b/src/s6-frontend/set_check.c @@ -0,0 +1,55 @@ +/* ISC license. */ + +#include <skalibs/uint64.h> +#include <skalibs/types.h> +#include <skalibs/envexec.h> + +#include <execline/config.h> + +#include <s6-rc/config.h> + +#include <s6-frontend/config.h> +#include "s6-frontend-internal.h" + +enum golb_e +{ + GOLB_FIXUP = 0x01, + GOLB_FORCE_ESSENTIAL = 0x02, + GOLB_FIX = 0x04, +} ; + +void set_check (char const *const *argv) +{ + static gol_bool const rgolb[] = + { + { .so = 'E', .lo = "no-force-essential", .clear = GOLB_FORCE_ESSENTIAL, .set = 0 }, + { .so = 'e', .lo = "force-essential", .clear = 0, .set = GOLB_FORCE_ESSENTIAL }, + { .so = 'd', .lo = "down", .clear = GOLB_FIXUP, .set = 0 }, + { .so = 'u', .lo = "up", .clear = 0, .set = GOLB_FIXUP }, + { .so = 'f', .lo = "fix", .clear = 0, .set = GOLB_FIX }, + } ; + uint64_t wgolb = 0 ; + unsigned int m = 0 ; + char const *newargv[11] ; + char fmtv[UINT_FMT] = " " ; + + argv += gol_argv(argv, rgolb, 4, 0, 0, &wgolb, 0) ; + + newargv[m++] = S6RC_EXTBINPREFIX "s6-rc-set-fix" ; + 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++] = wgolb & GOLB_FORCE_ESSENTIAL ? "--force-essential" : "--no-force-essential" ; + newargv[m++] = wgolb & GOLB_FIXUP ? "--fix-up" : "--fix-down" ; + if (!(wgolb & GOLB_FIX)) newargv[m++] = "--dry-run" ; + 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/set_commit.c b/src/s6-frontend/set_commit.c new file mode 100644 index 0000000..b9a6d7a --- /dev/null +++ b/src/s6-frontend/set_commit.c @@ -0,0 +1,68 @@ +/* ISC license. */ + +#include <skalibs/uint64.h> +#include <skalibs/types.h> +#include <skalibs/envexec.h> + +#include <s6-rc/config.h> + +#include "s6-frontend-internal.h" + +enum golb_e +{ + GOLB_FORCE = 0x01, + GOLB_KEEPOLD = 0x02, +} ; + +enum gola_e +{ + GOLA_DEFBUNDLE, + GOLA_FDHUSER, + GOLA_N +} ; + +void set_commit (char const *const *argv) +{ + static gol_bool const rgolb[] = + { + { .so = 'f', .lo = "force", .clear = 0, .set = GOLB_FORCE }, + { .so = 'K', .lo = "keep-old", .clear = 0, .set = GOLB_KEEPOLD }, + } ; + static gol_arg const rgola[] = + { + { .so = 'D', .lo = "default-bundle", .i = GOLA_DEFBUNDLE }, + { .so = 'h', .lo = "fdholder-user", .i = GOLA_FDHUSER } + } ; + + uint64_t wgolb = 0 ; + unsigned int m = 0 ; + char const *wgola[GOLA_N] = { 0 } ; + char const *newargv[14] ; + char fmtv[UINT_FMT] ; + + wgola[GOLA_DEFBUNDLE] = S6_FRONTEND_DEFBUNDLE ; + argv += GOL_argv(argv, rgolb, rgola, &wgolb, wgola) ; + + 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 (wgolb & GOLB_FORCE) newargv[m++] = "-f" ; + if (wgolb & GOLB_KEEPOLD) newargv[m++] = "-K" ; + if (wgola[GOLA_FDHUSER]) + { + newargv[m++] = "-h" ; + newargv[m++] = wgola[GOLA_FDHUSER] ; + } + 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/set_copy.c b/src/s6-frontend/set_copy.c new file mode 100644 index 0000000..1cbfbaf --- /dev/null +++ b/src/s6-frontend/set_copy.c @@ -0,0 +1,65 @@ +/* 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-internal.h" + +enum golb_e +{ + GOLB_FORCE = 0x01, +} ; + +static void set_copy (char const *from, char const *to, int force) gccattr_noreturn ; +static void set_copy (char const *from, char const *to, int force) +{ + unsigned int m = 0 ; + char const *argv[10] ; + char fmtv[UINT_FMT] ; + argv[m++] = S6RC_EXTBINPREFIX "s6-rc-set-copy" ; + if (g->verbosity != 1) + { + fmtv[uint_fmt(fmtv, g->verbosity)] = 0 ; + argv[m++] = "-v" ; + argv[m++] = fmtv ; + } + argv[m++] = "-r" ; + argv[m++] = g->dirs.repo ; + if (force) argv[m++] = "-f" ; + argv[m++] = "--" ; + argv[m++] = from ; + argv[m++] = to ; + argv[m++] = 0 ; + xmexec_n(argv, cleanup_modif.s, cleanup_modif.len, cleanup_modif.n) ; +} + +void set_save (char const *const *argv) +{ + static gol_bool const rgolb[] = + { + { .so = 'f', .lo = "force", .clear = 0, .set = GOLB_FORCE }, + } ; + uint64_t wgolb = 0 ; + argv += gol_argv(argv, rgolb, 1, 0, 0, &wgolb, 0) ; + if (!*argv) strerr_die(100, "usage: ", "s6 set ", "save [ --force ] name") ; + if (argv[0][0] == '.' || strchr(argv[0], '/') || strchr(argv[0], '\n') + || !strcmp(argv[0], "current")) + strerr_dief1x(100, "invalid set name") ; + set_copy("current", argv[0], !!(wgolb & GOLB_FORCE)) ; +} + +void set_load (char const *const *argv) +{ + argv += gol_argv(argv, 0, 0, 0, 0, 0, 0) ; + if (!*argv) strerr_die(100, "usage: ", "s6 set ", "load name") ; + if (argv[0][0] == '.' || strchr(argv[0], '/') || strchr(argv[0], '\n') + || !strcmp(argv[0], "current")) + strerr_dief1x(100, "invalid set name") ; + set_copy(argv[0], "current", 1) ; +} diff --git a/src/s6-frontend/set_list.c b/src/s6-frontend/set_list.c new file mode 100644 index 0000000..6c98137 --- /dev/null +++ b/src/s6-frontend/set_list.c @@ -0,0 +1,33 @@ +/* ISC license. */ + +#include <skalibs/types.h> +#include <skalibs/envexec.h> + +#include <execline/config.h> + +#include <s6-rc/config.h> + +#include "s6-frontend-internal.h" + +void set_list (char const *const *argv) +{ + unsigned int m = 0 ; + char const *newargv[9] ; + char fmtv[UINT_FMT] ; + argv += gol_argv(argv, 0, 0, 0, 0, 0, 0) ; + + newargv[m++] = S6RC_EXTBINPREFIX "s6-rc-set-status" ; + 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++] = "-L" ; + 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/set_status.c b/src/s6-frontend/set_status.c new file mode 100644 index 0000000..4cb04d3 --- /dev/null +++ b/src/s6-frontend/set_status.c @@ -0,0 +1,65 @@ +/* ISC license. */ + +#include <skalibs/uint64.h> +#include <skalibs/types.h> +#include <skalibs/envexec.h> + +#include <execline/config.h> + +#include <s6-rc/config.h> + +#include <s6-frontend/config.h> +#include "s6-frontend-internal.h" + +enum golb_e +{ + GOLB_IGNORE_ESSENTIALS = 0x01, +} ; + +void set_status (char const *const *argv) +{ + static gol_bool const rgolb[] = + { + { .so = 'E', .lo = "with-essentials", .clear = GOLB_IGNORE_ESSENTIALS, .set = 0 }, + { .so = 'e', .lo = "without-essentials", .clear = 0, .set = GOLB_IGNORE_ESSENTIALS }, + } ; + uint64_t wgolb = 0 ; + unsigned int m = 0 ; + unsigned int argc ; + char fmtv[UINT_FMT] = " " ; + + argv += gol_argv(argv, rgolb, 2, 0, 0, &wgolb, 0) ; + argc = env_len(argv) ; + if (!set_check_service_names(argv, argc)) + strerr_dief1x(100, "invalid service name") ; + + char const *newargv[15 + argc] ; + +#ifdef S6_FRONTEND_USE_UTIL_LINUX + if (g->color) + { + newargv[m++] = EXECLINE_EXTBINPREFIX "pipeline" ; + newargv[m++] = "-w" ; + newargv[m++] = "--" ; + newargv[m++] = " column" ; + newargv[m++] = " -ts/" ; + newargv[m++] = "" ; + } +#endif + newargv[m++] = S6RC_EXTBINPREFIX "s6-rc-set-status" ; + 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++] = wgolb & GOLB_IGNORE_ESSENTIALS ? "--without-essentials" : "--with-essentials" ; + newargv[m++] = "--" ; + newargv[m++] = "current" ; + for (unsigned int i = 0 ; i < argc ; i++) newargv[m++] = argv[i] ; + newargv[m++] = 0 ; + + xmexec_n(newargv, cleanup_modif.s, cleanup_modif.len, cleanup_modif.n) ; +} |
