diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/s6-frontend/live_install.c | 5 | ||||
| -rw-r--r-- | src/s6-frontend/repository_list.c | 4 | ||||
| -rw-r--r-- | src/s6-frontend/s6-frontend-internal.h | 3 | ||||
| -rw-r--r-- | src/s6-frontend/set.c | 3 | ||||
| -rw-r--r-- | src/s6-frontend/set.help.txt | 22 | ||||
| -rw-r--r-- | src/s6-frontend/set_change.c | 50 | ||||
| -rw-r--r-- | src/s6-frontend/set_check.c | 15 | ||||
| -rw-r--r-- | src/s6-frontend/set_commit.c | 7 | ||||
| -rw-r--r-- | src/s6-frontend/set_copy.c | 65 | ||||
| -rw-r--r-- | src/s6-frontend/set_delete.c | 6 | ||||
| -rw-r--r-- | src/s6-frontend/set_list.c | 15 | ||||
| -rw-r--r-- | src/s6-frontend/set_status.c | 15 |
12 files changed, 117 insertions, 93 deletions
diff --git a/src/s6-frontend/live_install.c b/src/s6-frontend/live_install.c index 6ab0780..10861f3 100644 --- a/src/s6-frontend/live_install.c +++ b/src/s6-frontend/live_install.c @@ -19,6 +19,7 @@ enum golb_e enum gola_e { GOLA_CONVFILE, + GOLA_SET, GOLA_N } ; @@ -35,12 +36,14 @@ void live_install (char const *const *argv) static gol_arg const rgola[] = { { .so = 'f', .lo = "conversion-file", .i = GOLA_CONVFILE }, + { .so = 's', .lo = "set", .i = GOLA_SET }, } ; uint64_t wgolb = 0 ; unsigned int m = 0 ; char const *wgola[GOLA_N] = { 0 } ; char const *newargv[18] ; char fmtv[UINT_FMT] ; + wgola[GOLA_SET] = "current" ; argv += GOL_argv(argv, rgolb, rgola, &wgolb, wgola) ; @@ -68,7 +71,7 @@ void live_install (char const *const *argv) } if (wgolb & GOLB_INIT) newargv[m++] = "--no-update" ; newargv[m++] = "--" ; - newargv[m++] = "current" ; + newargv[m++] = wgola[GOLA_SET] ; newargv[m++] = 0 ; main_exec(newargv) ; } diff --git a/src/s6-frontend/repository_list.c b/src/s6-frontend/repository_list.c index b34ac71..063b9d6 100644 --- a/src/s6-frontend/repository_list.c +++ b/src/s6-frontend/repository_list.c @@ -8,7 +8,7 @@ void repository_list (char const *const *argv) { - char const *newargv[9] ; + char const *newargv[7] ; unsigned int m = 0 ; char fmtv[UINT_FMT] ; newargv[m++] = S6RC_EXTBINPREFIX "s6-rc-repo-list" ; @@ -20,8 +20,6 @@ void repository_list (char const *const *argv) } newargv[m++] = "-r" ; newargv[m++] = g->dirs.repo ; - newargv[m++] = "-x" ; - newargv[m++] = "current" ; newargv[m++] = "--" ; newargv[m++] = 0 ; diff --git a/src/s6-frontend/s6-frontend-internal.h b/src/s6-frontend/s6-frontend-internal.h index 843ad41..7bd1409 100644 --- a/src/s6-frontend/s6-frontend-internal.h +++ b/src/s6-frontend/s6-frontend-internal.h @@ -74,8 +74,7 @@ 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_copy (char const *const *) gccattr_noreturn ; extern void set_delete (char const *const *) gccattr_noreturn ; extern void set_mask (char const *const *) gccattr_noreturn ; diff --git a/src/s6-frontend/set.c b/src/s6-frontend/set.c index 8123371..fe5f165 100644 --- a/src/s6-frontend/set.c +++ b/src/s6-frontend/set.c @@ -25,15 +25,14 @@ void set (char const *const *argv) { { .s = "check", .f = &set_check }, { .s = "commit", .f = &set_commit }, + { .s = "copy", .f = &set_copy }, { .s = "delete", .f = &set_delete }, { .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 = "make-essential", .f = &set_make_essential }, { .s = "mask", .f = &set_mask }, - { .s = "save", .f = &set_save }, { .s = "status", .f = &set_status }, { .s = "unmask", .f = &set_unmask }, } ; diff --git a/src/s6-frontend/set.help.txt b/src/s6-frontend/set.help.txt index 362ee9f..62b59ea 100644 --- a/src/s6-frontend/set.help.txt +++ b/src/s6-frontend/set.help.txt @@ -2,8 +2,8 @@ Usage: s6 set subcommand [ options ] [ arguments... ] Subcommands: help this message - save save the current set under a user-provided name - load load a previously saved set + copy copy a set to another name (default name is "current") + delete delete one or more sets list list services in the working set status list services in the working set with their rx enable enable services @@ -14,21 +14,27 @@ Subcommands: commit commit working set (can then be installed) -s6 set save options: +s6 set copy options: -f --force overwrite named set if existing -s6 set load options: none +s6 set delete options: none -s6 set list options: none +s6 set list options: + -s SET --set=SET show services in set SET (default: current) s6 set status options: -E --with-essentials show all services, even essential ones (default) -e --without-essentials don't show essential services + -s SET --set=SET show services in set SET (default: current) s6 set enable|disable|mask|unmask options: -f --ignore-dependencies only change listed services -n --dry-run show what would happen, don't do - -I WHAT --if-dependencies-found=WHAT WHAT=warn (default) | fail | pull (dependencies will be brought to the same rx) + -I --no-fail-on-dependencies warn or pull unlisted dependencies if found (default) + -i --fail-on-dependencies fail if unlisted dependencies are found + -P --no-pull-dependencies warn on unlisted dependencies (default) + -p --pull-dependencies apply the rx change to unlisted dependencies as well + -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) @@ -36,10 +42,12 @@ s6 set check options: -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 + -s SET --set=SET check set SET (default: current) s6 set commit options: -f --force compile db even if up-to-date -K --keep-old keep old db if any, print its path to stdout -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) + -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) diff --git a/src/s6-frontend/set_change.c b/src/s6-frontend/set_change.c index 64b6fbf..a0db9b7 100644 --- a/src/s6-frontend/set_change.c +++ b/src/s6-frontend/set_change.c @@ -11,13 +11,14 @@ enum golb_e { - GOLB_IGNORE_DEPENDENCIES = 0x02, - GOLB_DRYRUN = 0x04, + GOLB_DRYRUN = 0x02, + GOLB_FAIL_ON_DEPS = 0x04, + GOLB_PULL_DEPS = 0x08, } ; enum gola_e { - GOLA_FORCELEVEL, + GOLA_SET, GOLA_N } ; @@ -26,30 +27,28 @@ static void set_change (char const *const *argv, char const *newrx, char const * { static gol_bool const rgolb[] = { - { .so = 'f', .lo = "ignore-dependencies", .clear = 0, .set = GOLB_IGNORE_DEPENDENCIES }, - { .so = 'n', .lo = "dry-run", .clear = 0, .set = GOLB_DRYRUN } + { .so = 0, .lo = "no-dry-run", .clear = GOLB_DRYRUN, .set = 0 }, + { .so = 'n', .lo = "dry-run", .clear = 0, .set = GOLB_DRYRUN }, + { .so = 'I', .lo = "no-fail-on-dependencies", .clear = GOLB_FAIL_ON_DEPS, .set = 0 }, + { .so = 'i', .lo = "fail-on-dependencies", .clear = 0, .set = GOLB_FAIL_ON_DEPS }, + { .so = 'P', .lo = "no-pull-dependencies", .clear = GOLB_PULL_DEPS, .set = 0 }, + { .so = 'p', .lo = "pull-dependencies", .clear = 0, .set = GOLB_PULL_DEPS }, } ; static gol_arg const rgola[] = { - { .so = 'I', .lo = "if-dependencies-found", .i = GOLA_FORCELEVEL } + { .so = 's', .lo = "set", .i = GOLA_SET }, } ; uint64_t wgolb = 0 ; + char const *wgola[GOLA_N] = { [GOLA_SET] = "current" } ; unsigned int m = 0 ; + unsigned int argc ; - char const *wgola[GOLA_N] = { 0 } ; argv += GOL_argv(argv, rgolb, rgola, &wgolb, wgola) ; - if (!*argv) strerr_die(100, "usage: ", "s6 set ", cmd, " [ --ignore-dependencies ] [ --dry-run ] [ --if-dependencies-found=fail|warn|pull ] services...") ; - argc = env_len(argv) ; - if (wgola[GOLA_FORCELEVEL]) - { - if (strcmp(wgola[GOLA_FORCELEVEL], "fail") - && strcmp(wgola[GOLA_FORCELEVEL], "pull") - && strcmp(wgola[GOLA_FORCELEVEL], "warn")) - strerr_dief1x(100, "--if-dependencies-found= argument must be fail, warn or pull") ; - } + if (!*argv) strerr_die(100, "usage: ", "s6 set ", cmd, " [ --dry-run ] [ --fail-on-dependencies | --pull-dependencies ] [ --set=setname ] services...") ; + argc = env_len(argv) ; char fmtv[UINT_FMT] ; - char const *newargv[14 + argc] ; + char const *newargv[13 + argc] ; newargv[m++] = S6RC_EXTBINPREFIX "s6-rc-set-change" ; if (g->verbosity != 1) { @@ -59,21 +58,14 @@ static void set_change (char const *const *argv, char const *newrx, char const * } newargv[m++] = "-r" ; newargv[m++] = g->dirs.repo ; - if (wgolb & GOLB_IGNORE_DEPENDENCIES) - newargv[m++] = "-f" ; - if (wgolb & GOLB_DRYRUN) - newargv[m++] = "-n" ; - if (wgola[GOLA_FORCELEVEL]) - { - newargv[m++] = "-I" ; - newargv[m++] = wgola[GOLA_FORCELEVEL] ; - } + if (wgolb & GOLB_DRYRUN) newargv[m++] = "-n" ; if (!strcmp(newrx, "always")) newargv[m++] = "-e" ; + if (wgolb & GOLB_FAIL_ON_DEPS) newargv[m++] = "-i" ; + if (wgolb & GOLB_PULL_DEPS) newargv[m++] = "-p" ; newargv[m++] = "--" ; - newargv[m++] = "current" ; + newargv[m++] = wgola[GOLA_SET] ; newargv[m++] = newrx ; - for (unsigned int i = 0 ; i < argc ; i++) - newargv[m++] = argv[i] ; + for (unsigned int i = 0 ; i < argc ; i++) newargv[m++] = argv[i] ; newargv[m++] = 0 ; main_exec(newargv) ; } diff --git a/src/s6-frontend/set_check.c b/src/s6-frontend/set_check.c index a76d538..f0cd536 100644 --- a/src/s6-frontend/set_check.c +++ b/src/s6-frontend/set_check.c @@ -18,6 +18,12 @@ enum golb_e GOLB_FIX = 0x04, } ; +enum gola_e +{ + GOLA_SET, + GOLA_N +} ; + void set_check (char const *const *argv) { static gol_bool const rgolb[] = @@ -28,12 +34,17 @@ void set_check (char const *const *argv) { .so = 'u', .lo = "up", .clear = 0, .set = GOLB_FIXUP }, { .so = 'F', .lo = "fix", .clear = 0, .set = GOLB_FIX }, } ; + static gol_arg const rgola[] = + { + { .so = 's', .lo = "set", .i = GOLA_SET }, + } ; uint64_t wgolb = 0 ; + char const *wgola[GOLA_N] = { [GOLA_SET] = "current" } ; unsigned int m = 0 ; char const *newargv[11] ; char fmtv[UINT_FMT] = " " ; - argv += gol_argv(argv, rgolb, 5, 0, 0, &wgolb, 0) ; + argv += GOL_argv(argv, rgolb, rgola, &wgolb, wgola) ; newargv[m++] = S6RC_EXTBINPREFIX "s6-rc-set-fix" ; if (g->verbosity != 1) @@ -48,7 +59,7 @@ void set_check (char const *const *argv) newargv[m++] = wgolb & GOLB_FIXUP ? "--fix-up" : "--fix-down" ; if (!(wgolb & GOLB_FIX)) newargv[m++] = "--dry-run" ; newargv[m++] = "--" ; - newargv[m++] = "current" ; + newargv[m++] = wgola[GOLA_SET] ; newargv[m++] = 0 ; main_exec(newargv) ; diff --git a/src/s6-frontend/set_commit.c b/src/s6-frontend/set_commit.c index 887d5d9..3e0fae2 100644 --- a/src/s6-frontend/set_commit.c +++ b/src/s6-frontend/set_commit.c @@ -18,6 +18,7 @@ enum gola_e { GOLA_DEFBUNDLE, GOLA_FDHUSER, + GOLA_SET, GOLA_N } ; @@ -31,7 +32,8 @@ void set_commit (char const *const *argv) static gol_arg const rgola[] = { { .so = 'D', .lo = "default-bundle", .i = GOLA_DEFBUNDLE }, - { .so = 'h', .lo = "fdholder-user", .i = GOLA_FDHUSER } + { .so = 'h', .lo = "fdholder-user", .i = GOLA_FDHUSER }, + { .so = 's', .lo = "set", .i = GOLA_SET }, } ; uint64_t wgolb = 0 ; @@ -41,6 +43,7 @@ void set_commit (char const *const *argv) char fmtv[UINT_FMT] ; wgola[GOLA_DEFBUNDLE] = S6_FRONTEND_DEFBUNDLE ; + wgola[GOLA_SET] = "current" ; argv += GOL_argv(argv, rgolb, rgola, &wgolb, wgola) ; newargv[m++] = S6RC_EXTBINPREFIX "s6-rc-set-commit" ; @@ -62,7 +65,7 @@ void set_commit (char const *const *argv) newargv[m++] = wgola[GOLA_FDHUSER] ; } newargv[m++] = "--" ; - newargv[m++] = "current" ; + newargv[m++] = wgola[GOLA_SET] ; newargv[m++] = 0 ; main_exec(newargv) ; } diff --git a/src/s6-frontend/set_copy.c b/src/s6-frontend/set_copy.c index 07b9e24..b9f9713 100644 --- a/src/s6-frontend/set_copy.c +++ b/src/s6-frontend/set_copy.c @@ -17,50 +17,37 @@ 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) +void set_copy (char const *const *argv) { - 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 ; - main_exec(argv) ; -} - -void set_save (char const *const *argv) -{ - static gol_bool const rgolb[] = + static gol_bool const rgolb[] = { { .so = 'f', .lo = "force", .clear = 0, .set = GOLB_FORCE }, } ; uint64_t wgolb = 0 ; + unsigned int m = 0 ; + char const *newargv[10] ; + char fmtv[UINT_FMT] ; + 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)) ; -} + if (!argv[0] || !argv[1]) strerr_die(100, "usage: ", "s6 set ", "copy [ --force ] source destination") ; + if (argv[0][0] == '.' || strchr(argv[0], '/') || strchr(argv[0], '\n')) + strerr_dief(100, "invalid ", "source", " set name") ; + if (argv[1][0] == '.' || strchr(argv[1], '/') || strchr(argv[1], '\n')) + strerr_dief(100, "invalid ", "destination", " set name") ; -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) ; + newargv[m++] = S6RC_EXTBINPREFIX "s6-rc-set-copy" ; + 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" ; + newargv[m++] = "--" ; + newargv[m++] = argv[0] ; + newargv[m++] = argv[1] ; + newargv[m++] = 0 ; + main_exec(newargv) ; } diff --git a/src/s6-frontend/set_delete.c b/src/s6-frontend/set_delete.c index f5e5e37..9346d3b 100644 --- a/src/s6-frontend/set_delete.c +++ b/src/s6-frontend/set_delete.c @@ -17,9 +17,11 @@ void set_delete (char const *const *argv) argc = env_len(argv) ; for (unsigned int i = 0 ; i < argc ; i++) - if (argv[i][0] == '.' || strchr(argv[i], '/') || strchr(argv[i], '\n') - || !strcmp(argv[i], "current")) + { + if (argv[i][0] == '.' || strchr(argv[i], '/') || strchr(argv[i], '\n')) strerr_dief(100, "invalid set name: ", argv[i]) ; + if (!strcmp(argv[i], "current")) strerr_diefu(100, "delete current set") ; + } unsigned int m = 0 ; char const *newargv[7 + argc] ; diff --git a/src/s6-frontend/set_list.c b/src/s6-frontend/set_list.c index f5eeeb1..d1a127f 100644 --- a/src/s6-frontend/set_list.c +++ b/src/s6-frontend/set_list.c @@ -14,6 +14,12 @@ enum golb_e GOLB_IGNORE_ESSENTIALS = 0x01, } ; +enum gola_e +{ + GOLA_SET, + GOLA_N +} ; + void set_list (char const *const *argv) { static gol_bool const rgolb[] = @@ -21,11 +27,16 @@ void set_list (char const *const *argv) { .so = 'E', .lo = "with-essentials", .clear = GOLB_IGNORE_ESSENTIALS, .set = 0 }, { .so = 'e', .lo = "without-essentials", .clear = 0, .set = GOLB_IGNORE_ESSENTIALS }, } ; + static gol_arg const rgola[] = + { + { .so = 's', .lo = "set", .i = GOLA_SET }, + } ; uint64_t wgolb = 0 ; + char const *wgola[GOLA_N] = { [GOLA_SET] = "current" } ; unsigned int m = 0 ; char const *newargv[10] ; char fmtv[UINT_FMT] ; - argv += gol_argv(argv, rgolb, 2, 0, 0, &wgolb, 0) ; + argv += GOL_argv(argv, rgolb, rgola, &wgolb, wgola) ; newargv[m++] = S6RC_EXTBINPREFIX "s6-rc-set-status" ; fmtv[uint_fmt(fmtv, g->verbosity)] = 0 ; @@ -36,7 +47,7 @@ void set_list (char const *const *argv) newargv[m++] = "-L" ; newargv[m++] = wgolb & GOLB_IGNORE_ESSENTIALS ? "--without-essentials" : "--with-essentials" ; newargv[m++] = "--" ; - newargv[m++] = "current" ; + newargv[m++] = wgola[GOLA_SET] ; newargv[m++] = 0 ; main_exec(newargv) ; } diff --git a/src/s6-frontend/set_status.c b/src/s6-frontend/set_status.c index a5dd094..8f397b8 100644 --- a/src/s6-frontend/set_status.c +++ b/src/s6-frontend/set_status.c @@ -16,6 +16,12 @@ enum golb_e GOLB_IGNORE_ESSENTIALS = 0x01, } ; +enum gola_e +{ + GOLA_SET, + GOLA_N +} ; + void set_status (char const *const *argv) { static gol_bool const rgolb[] = @@ -23,12 +29,17 @@ void set_status (char const *const *argv) { .so = 'E', .lo = "with-essentials", .clear = GOLB_IGNORE_ESSENTIALS, .set = 0 }, { .so = 'e', .lo = "without-essentials", .clear = 0, .set = GOLB_IGNORE_ESSENTIALS }, } ; + static gol_arg const rgola[] = + { + { .so = 's', .lo = "set", .i = GOLA_SET }, + } ; uint64_t wgolb = 0 ; + char const *wgola[GOLA_N] = { [GOLA_SET] = "current" } ; unsigned int m = 0 ; unsigned int argc ; char fmtv[UINT_FMT] = " " ; - argv += gol_argv(argv, rgolb, 2, 0, 0, &wgolb, 0) ; + argv += GOL_argv(argv, rgolb, rgola, &wgolb, wgola) ; argc = env_len(argv) ; if (!set_check_service_names(argv, argc)) strerr_dief1x(100, "invalid service name") ; @@ -42,7 +53,7 @@ void set_status (char const *const *argv) newargv[m++] = g->dirs.repo ; newargv[m++] = wgolb & GOLB_IGNORE_ESSENTIALS ? "--without-essentials" : "--with-essentials" ; newargv[m++] = "--" ; - newargv[m++] = "current" ; + newargv[m++] = wgola[GOLA_SET] ; for (unsigned int i = 0 ; i < argc ; i++) newargv[m++] = argv[i] ; newargv[m++] = 0 ; |
