diff options
| author | Laurent Bercot <ska-skaware@skarnet.org> | 2025-09-21 12:36:52 +0000 |
|---|---|---|
| committer | Laurent Bercot <ska-skaware@skarnet.org> | 2025-09-21 12:36:52 +0000 |
| commit | 0efd4cf8041f107a4460cfefa16667ee012e85d3 (patch) | |
| tree | 0d91a24a3965d4739d2a89779506b91c63ebe744 | |
| parent | 8671af033b2f5512e9138cbadcfc068b3ae3e135 (diff) | |
| download | s6-rc-0efd4cf8041f107a4460cfefa16667ee012e85d3.tar.gz | |
Add s6-rc-set-commit, slightly rephrase other binaries
| -rw-r--r-- | .gitignore | 1 | ||||
| -rw-r--r-- | package/deps.mak | 3 | ||||
| -rw-r--r-- | package/modes | 1 | ||||
| -rw-r--r-- | package/targets.mak | 1 | ||||
| -rw-r--r-- | src/repo/deps-exe/s6-rc-set-commit | 3 | ||||
| -rw-r--r-- | src/repo/s6-rc-repo-init.c | 43 | ||||
| -rw-r--r-- | src/repo/s6-rc-set-changestate.c | 33 | ||||
| -rw-r--r-- | src/repo/s6-rc-set-commit.c | 117 | ||||
| -rw-r--r-- | src/repo/s6-rc-set-copy.c | 27 | ||||
| -rw-r--r-- | src/repo/s6-rc-set-delete.c | 16 | ||||
| -rw-r--r-- | src/repo/s6-rc-set-new.c | 16 |
11 files changed, 193 insertions, 68 deletions
@@ -21,3 +21,4 @@ /s6-rc-set-copy /s6-rc-set-delete /s6-rc-set-changestate +/s6-rc-set-commit diff --git a/package/deps.mak b/package/deps.mak index 3ba2e42..367d1e5 100644 --- a/package/deps.mak +++ b/package/deps.mak @@ -53,6 +53,7 @@ src/libs6rc/s6rc_strrefcmp.o src/libs6rc/s6rc_strrefcmp.lo: src/libs6rc/s6rc_str src/libs6rc/s6rc_type_check.o src/libs6rc/s6rc_type_check.lo: src/libs6rc/s6rc_type_check.c src/include/s6-rc/s6rc-utils.h src/repo/s6-rc-repo-init.o src/repo/s6-rc-repo-init.lo: src/repo/s6-rc-repo-init.c src/include/s6-rc/config.h src/include/s6-rc/s6rc.h src/repo/s6-rc-set-changestate.o src/repo/s6-rc-set-changestate.lo: src/repo/s6-rc-set-changestate.c src/include/s6-rc/config.h src/include/s6-rc/s6rc.h +src/repo/s6-rc-set-commit.o src/repo/s6-rc-set-commit.lo: src/repo/s6-rc-set-commit.c src/include/s6-rc/config.h src/include/s6-rc/s6rc.h src/repo/s6-rc-set-copy.o src/repo/s6-rc-set-copy.lo: src/repo/s6-rc-set-copy.c src/include/s6-rc/config.h src/include/s6-rc/s6rc.h src/repo/s6-rc-set-delete.o src/repo/s6-rc-set-delete.lo: src/repo/s6-rc-set-delete.c src/include/s6-rc/config.h src/include/s6-rc/s6rc.h src/repo/s6-rc-set-new.o src/repo/s6-rc-set-new.lo: src/repo/s6-rc-set-new.c src/include/s6-rc/config.h src/include/s6-rc/s6rc.h @@ -81,6 +82,8 @@ s6-rc-repo-init: EXTRA_LIBS := ${SYSCLOCK_LIB} s6-rc-repo-init: src/repo/s6-rc-repo-init.o ${LIBS6RC} -lskarnet s6-rc-set-changestate: EXTRA_LIBS := ${SYSCLOCK_LIB} s6-rc-set-changestate: src/repo/s6-rc-set-changestate.o ${LIBS6RC} -lskarnet +s6-rc-set-commit: EXTRA_LIBS := ${SYSCLOCK_LIB} +s6-rc-set-commit: src/repo/s6-rc-set-commit.o ${LIBS6RC} -lskarnet s6-rc-set-copy: EXTRA_LIBS := ${SYSCLOCK_LIB} s6-rc-set-copy: src/repo/s6-rc-set-copy.o ${LIBS6RC} -lskarnet s6-rc-set-delete: EXTRA_LIBS := ${SYSCLOCK_LIB} diff --git a/package/modes b/package/modes index c4a936f..8f37adb 100644 --- a/package/modes +++ b/package/modes @@ -13,3 +13,4 @@ s6-rc-set-new 0755 s6-rc-set-copy 0755 s6-rc-set-delete 0755 s6-rc-set-changestate 0755 +s6-rc-set-commit 0755 diff --git a/package/targets.mak b/package/targets.mak index 072c69c..da74098 100644 --- a/package/targets.mak +++ b/package/targets.mak @@ -12,6 +12,7 @@ s6-rc-set-new \ s6-rc-set-copy \ s6-rc-set-delete \ s6-rc-set-changestate \ +s6-rc-set-commit \ LIBEXEC_TARGETS := \ s6-rc-fdholder-filler \ diff --git a/src/repo/deps-exe/s6-rc-set-commit b/src/repo/deps-exe/s6-rc-set-commit new file mode 100644 index 0000000..6dd7af7 --- /dev/null +++ b/src/repo/deps-exe/s6-rc-set-commit @@ -0,0 +1,3 @@ +${LIBS6RC} +-lskarnet +${SYSCLOCK_LIB} diff --git a/src/repo/s6-rc-repo-init.c b/src/repo/s6-rc-repo-init.c index 06ba632..971a00e 100644 --- a/src/repo/s6-rc-repo-init.c +++ b/src/repo/s6-rc-repo-init.c @@ -33,13 +33,12 @@ static void cleanup (char const *fn) enum golb_e { - GOLB_FORCE, - GOLB_N + GOLB_FORCE = 0x01 } ; -static gol_bool const rgolb[1] = +static gol_bool const rgolb[] = { - { .so = 'f', .lo = "force", .clear = 0, .set = 1 << GOLB_FORCE } + { .so = 'f', .lo = "force", .clear = 0, .set = GOLB_FORCE } } ; enum gola_e @@ -50,38 +49,38 @@ enum gola_e GOLA_N } ; -static gol_arg const rgola[3] = +static gol_arg const rgola[] = { { .so = 'v', .lo = "verbosity", .i = GOLA_VERBOSITY }, { .so = 'r', .lo = "repodir", .i = GOLA_REPODIR }, - { .so = 'h', .lo = "fdhuser", .i = GOLA_FDHUSER } + { .so = 'h', .lo = "fd-holder-user", .i = GOLA_FDHUSER } } ; int main (int argc, char const *const *argv) { size_t repolen ; - char const *repo = S6RC_REPO_BASE ; unsigned int verbosity = 1 ; mode_t m ; - char const *wgola[3] = { 0 } ; + char const *wgola[GOLA_N] = { 0 } ; uint64_t wgolb = 0 ; unsigned int golc ; PROG = "s6-rc-repo-init" ; - golc = gol_main(argc, argv, rgolb, 1, rgola, 3, &wgolb, wgola) ; + wgola[GOLA_REPODIR] = S6RC_REPO_BASE ; + + golc = GOL_main(argc, argv, rgolb, rgola, &wgolb, wgola) ; argc -= golc ; argv += golc ; if (wgola[GOLA_VERBOSITY] && !uint0_scan(wgola[GOLA_VERBOSITY], &verbosity)) strerr_dief1x(100, "verbosity needs to be an unsigned integer") ; - if (wgola[GOLA_REPODIR]) repo = wgola[GOLA_REPODIR] ; for (unsigned int i = 0 ; i < argc ; i++) if (argv[i][0] != '/') strerr_dief2x(100, argv[i], " is not an absolute path") ; if (!argc) strerr_warnw1x("no source directories given, creating an empty repository") ; tain_now_g() ; - repolen = strlen(repo) ; + repolen = strlen(wgola[GOLA_REPODIR]) ; char repotmp[repolen + 12] ; char tmp[repolen + 21] ; - memcpy(repotmp, repo, repolen) ; + memcpy(repotmp, wgola[GOLA_REPODIR], repolen) ; memcpy(repotmp + repolen, "-tmp.XXXXXX", 12) ; m = umask(0) ; if (!mkdtemp(repotmp)) @@ -132,32 +131,32 @@ int main (int argc, char const *const *argv) if (chmod(repotmp, 02755) == -1) strerr_diefu2sys(111, "chmod ", repotmp) ; - if (rename(repotmp, repo) == -1) + if (rename(repotmp, wgola[GOLA_REPODIR]) == -1) { - if (errno != EEXIST || !(wgolb & 1 << GOLB_FORCE)) + if (errno != EEXIST || !(wgolb & GOLB_FORCE)) { cleanup(repotmp) ; - strerr_diefu4sys(111, "rename ", repotmp, " to ", repo) ; + strerr_diefu4sys(111, "rename ", repotmp, " to ", wgola[GOLA_REPODIR]) ; } else { - memcpy(tmp, repo, repolen) ; + memcpy(tmp, wgola[GOLA_REPODIR], repolen) ; memcpy(tmp + repolen, ":old:", 5) ; random_name(tmp + repolen + 5, 15) ; tmp[repolen + 20] = 0 ; - if (rename(repo, tmp) == -1) + if (rename(wgola[GOLA_REPODIR], tmp) == -1) { cleanup(repotmp) ; - strerr_diefu4sys(111, "rename ", repo, " to ", tmp) ; + strerr_diefu4sys(111, "rename ", wgola[GOLA_REPODIR], " to ", tmp) ; } - if (rename(repotmp, repo) == -1) + if (rename(repotmp, wgola[GOLA_REPODIR]) == -1) { int e = errno ; - if (rename(tmp, repo) == -1) - strerr_diefu7sys(111, "rename directories to ", repo, ": weird race happened. New repository is at ", repotmp, " and old repository is at ", tmp, " - reported error was") ; + if (rename(tmp, wgola[GOLA_REPODIR]) == -1) + strerr_diefu7sys(111, "rename directories to ", wgola[GOLA_REPODIR], ": weird race happened. New repository is at ", repotmp, " and old repository is at ", tmp, " - reported error was") ; errno = e ; cleanup(repotmp) ; - strerr_diefu4sys(111, "rename ", repotmp, " to ", repo) ; + strerr_diefu4sys(111, "rename ", repotmp, " to ", wgola[GOLA_REPODIR]) ; } } } diff --git a/src/repo/s6-rc-set-changestate.c b/src/repo/s6-rc-set-changestate.c index 8ce491d..7a502b6 100644 --- a/src/repo/s6-rc-set-changestate.c +++ b/src/repo/s6-rc-set-changestate.c @@ -18,7 +18,7 @@ #include <s6-rc/config.h> #include <s6-rc/s6rc.h> -#define USAGE "s6-rc-set-changestate [ -v verbosity ] [ -F forcelevel ] [ -r repo ] [ -3 ] set newstate services..." +#define USAGE "s6-rc-set-changestate [ -v verbosity ] [ -r repo ] [ -E ] [ -f | -I fail|pull|warn ] [ -n ] set newstate services..." #define dieusage() strerr_dieusage(100, USAGE) enum golb_e @@ -44,7 +44,7 @@ struct subname_s static gol_bool const rgolb[] = { - { .so = '3', .lo = "force-essential", .clear = 0, .set = GOLB_FORCE_ESSENTIAL }, + { .so = 'E', .lo = "force-essential", .clear = 0, .set = GOLB_FORCE_ESSENTIAL }, { .so = 'f', .lo = "ignore-dependencies", .clear = 0, .set = GOLB_IGNORE_DEPENDENCIES }, { .so = 'n', .lo = "dry-run", .clear = 0, .set = GOLB_DRYRUN } } ; @@ -74,6 +74,7 @@ static struct subname_s const accepted_subs[] = { .name = "enable", .sub = 2 }, { .name = "enabled", .sub = 2 }, { .name = "essential", .sub = 3 }, + { .name = "make-essential", .sub = 3 }, { .name = "mask", .sub = 0 }, { .name = "masked", .sub = 0 }, { .name = "onboot", .sub = 2 }, @@ -91,11 +92,10 @@ int main (int argc, char const *const *argv) stralloc storage = STRALLOC_ZERO ; genalloc svlist = GENALLOC_ZERO ; /* s6rc_repo_sv */ genalloc indices = GENALLOC_ZERO ; /* size_t then uint32_t */ - char const *repo = S6RC_REPO_BASE ; int fdlock ; unsigned int verbosity = 1 ; unsigned int forcelevel = 1 ; - char const *wgola[3] = { 0 } ; + char const *wgola[GOLA_N] = { 0 } ; unsigned int golc ; struct subname_s *newsub ; size_t max = 0, sabase ; @@ -103,7 +103,9 @@ int main (int argc, char const *const *argv) uint32_t listn, n ; PROG = "s6-rc-set-changestate" ; - golc = gol_main(argc, argv, rgolb, 1, rgola, 2, &wgolb, wgola) ; + wgola[GOLA_REPODIR] = S6RC_REPO_BASE ; + + golc = GOL_main(argc, argv, rgolb, rgola, &wgolb, wgola) ; argc -= golc ; argv += golc ; if (wgola[GOLA_VERBOSITY] && !uint0_scan(wgola[GOLA_VERBOSITY], &verbosity)) strerr_dief1x(100, "verbosity needs to be an unsigned integer") ; @@ -113,7 +115,6 @@ int main (int argc, char const *const *argv) if (!p) strerr_dief1x(100, "if-dependencies-found needs to be fail, warn or pull") ; forcelevel = p->sub ; } - if (wgola[GOLA_REPODIR]) repo = wgola[GOLA_REPODIR] ; if (argc < 3) dieusage() ; if (strchr(argv[0], '/') || strchr(argv[0], '\n')) strerr_dief1x(100, "set names cannot contain / or newlines") ; @@ -123,16 +124,16 @@ int main (int argc, char const *const *argv) if (newsub->sub == 3 && !(wgolb & GOLB_FORCE_ESSENTIAL)) strerr_dief1x(100, " artificially mark a service as essential without --force-essential") ; - fdlock = s6rc_repo_lock(repo, 1) ; - if (fdlock == -1) strerr_diefu2sys(111, "lock ", repo) ; + fdlock = s6rc_repo_lock(wgola[GOLA_REPODIR], 1) ; + if (fdlock == -1) strerr_diefu2sys(111, "lock ", wgola[GOLA_REPODIR]) ; tain_now_g() ; - if (!s6rc_repo_makesvlist(repo, argv[0], &storage, &svlist)) _exit(111) ; + if (!s6rc_repo_makesvlist(wgola[GOLA_REPODIR], argv[0], &storage, &svlist)) _exit(111) ; list = genalloc_s(s6rc_repo_sv, &svlist) ; listn = genalloc_len(s6rc_repo_sv, &svlist) ; sabase = storage.len ; { - int r = s6rc_repo_flattenservices(repo, argv + 2, argc - 2, &storage, &indices) ; + int r = s6rc_repo_flattenservices(wgola[GOLA_REPODIR], argv + 2, argc - 2, &storage, &indices) ; if (r) _exit(r) ; } n = genalloc_len(size_t, &indices) ; @@ -145,7 +146,7 @@ int main (int argc, char const *const *argv) { char const *s = storage.s + genalloc_s(size_t, &indices)[i] ; s6rc_repo_sv *p = bsearchr(s, list, listn, sizeof(s6rc_repo_sv), &s6rc_repo_sv_bcmpr, storage.s) ; - if (!p) strerr_dief7x(102, "inconsistent view in set ", argv[0], " of repository ", repo, ": service ", s, " is defined in the reference database but not in the textual representation of the set") ; + if (!p) strerr_dief7x(102, "inconsistent view in set ", argv[0], " of repository ", wgola[GOLA_REPODIR], ": service ", s, " is defined in the reference database but not in the textual representation of the set") ; starting[i] = *p ; ind[i] = p - list ; max += strlen(s) + 1 ; @@ -170,7 +171,7 @@ int main (int argc, char const *const *argv) m += len ; } - if (!s6rc_repo_badsub(repo, argv[0], tmpstart, n, newsub->sub, list, listn, &storage, &indices)) _exit(111) ; + if (!s6rc_repo_badsub(wgola[GOLA_REPODIR], argv[0], tmpstart, n, newsub->sub, list, listn, &storage, &indices)) _exit(111) ; if (genalloc_len(uint32_t, &indices)) { uint32_t const *bads = genalloc_s(uint32_t, &indices) ; @@ -200,9 +201,9 @@ int main (int argc, char const *const *argv) if (forcelevel == 2) { s6rc_repo_sv full[n + badn] ; - for (unsigned int i = 0 ; i < n ; i++) full[i] = starting[i] ; - for (unsigned int i = 0 ; i < badn ; i++) full[n + i] = list[bads[i]] ; - if (!s6rc_repo_moveservices(repo, argv[0], full, n + badn, newsub->sub, storage.s, verbosity)) _exit(111) ; + for (uint32_t i = 0 ; i < n ; i++) full[i] = starting[i] ; + for (uint32_t i = 0 ; i < badn ; i++) full[n + i] = list[bads[i]] ; + if (!s6rc_repo_moveservices(wgola[GOLA_REPODIR], argv[0], full, n + badn, newsub->sub, storage.s, verbosity)) _exit(111) ; _exit(0) ; } } @@ -212,7 +213,7 @@ int main (int argc, char const *const *argv) if (!(wgolb & GOLB_DRYRUN)) { - if (!s6rc_repo_moveservices(repo, argv[0], starting, n, newsub->sub, storage.s, verbosity)) _exit(111) ; + if (!s6rc_repo_moveservices(wgola[GOLA_REPODIR], argv[0], starting, n, newsub->sub, storage.s, verbosity)) _exit(111) ; } _exit(0) ; } diff --git a/src/repo/s6-rc-set-commit.c b/src/repo/s6-rc-set-commit.c new file mode 100644 index 0000000..07ddbfb --- /dev/null +++ b/src/repo/s6-rc-set-commit.c @@ -0,0 +1,117 @@ +/* ISC license. */ + +#include <string.h> +#include <unistd.h> +#include <stdlib.h> +#include <errno.h> + +#include <skalibs/uint64.h> +#include <skalibs/posixplz.h> +#include <skalibs/stat.h> +#include <skalibs/prog.h> +#include <skalibs/allreadwrite.h> +#include <skalibs/strerr.h> +#include <skalibs/gol.h> +#include <skalibs/tai.h> +#include <skalibs/stralloc.h> +#include <skalibs/genalloc.h> +#include <skalibs/djbunix.h> + +#include <s6-rc/config.h> +#include <s6-rc/s6rc.h> + +#define USAGE "s6-rc-set-commit [ -v verbosity ] [ -r repo ] [ -D defaultbundle ] [ -h fdhuser ] [ -K ] set" +#define dieusage() strerr_dieusage(100, USAGE) + +enum golb_e +{ + GOLB_KEEPOLD = 0x01 +} ; + +enum gola_e +{ + GOLA_VERBOSITY, + GOLA_REPODIR, + GOLA_DEFBUNDLE, + GOLA_FDHUSER, + GOLA_N +} ; + +static gol_bool const rgolb[] = +{ + { .so = 'K', .lo = "keep-old", .clear = 0, .set = GOLB_KEEPOLD } +} ; + +static gol_arg const rgola[] = +{ + { .so = 'v', .lo = "verbosity", .i = GOLA_VERBOSITY }, + { .so = 'r', .lo = "repodir", .i = GOLA_REPODIR }, + { .so = 'D', .lo = "default-bundle", .i = GOLA_DEFBUNDLE }, + { .so = 'h', .lo = "fd-holder-user", .i = GOLA_FDHUSER } +} ; + +static uint64_t wgolb = 0 ; + +static void check_set (char const *repo, char const *set) +{ + struct stat st ; + size_t repolen = strlen(repo) ; + size_t setlen = strlen(set) ; + char fn[repolen + 10 + setlen] ; + memcpy(fn, repo, repolen) ; + memcpy(fn + repolen, "/sources/", 9) ; + memcpy(fn + repolen + 9, set, setlen + 1) ; + if (stat(fn, &st) == -1) + { + if (errno == ENOENT) + strerr_dief4x(3, "set ", set, " does not exist in repository ", repo) ; + else strerr_diefu2sys(111, "stat ", fn) ; + } + if (!S_ISDIR(st.st_mode)) + strerr_dief3x(102, "file ", fn, " is not a directory") ; +} + +int main (int argc, char const *const *argv) +{ + int fdlock ; + unsigned int verbosity = 1 ; + char const *wgola[GOLA_N] = { 0 } ; + unsigned int golc ; + int r ; + + PROG = "s6-rc-set-commit" ; + wgola[GOLA_REPODIR] = S6RC_REPO_BASE ; + wgola[GOLA_DEFBUNDLE] = "default" ; + + golc = GOL_main(argc, argv, rgolb, rgola, &wgolb, wgola) ; + argc -= golc ; argv += golc ; + if (wgola[GOLA_VERBOSITY] && !uint0_scan(wgola[GOLA_VERBOSITY], &verbosity)) + strerr_dief1x(100, "verbosity needs to be an unsigned integer") ; + if (!argc) dieusage() ; + if (strchr(argv[0], '/') || strchr(argv[0], '\n')) + strerr_dief1x(100, "set names cannot contain / or newlines") ; + + fdlock = s6rc_repo_lock(wgola[GOLA_REPODIR], 1) ; + if (fdlock == -1) strerr_diefu2sys(111, "lock ", wgola[GOLA_REPODIR]) ; + check_set(wgola[GOLA_REPODIR], argv[0]) ; + tain_now_g() ; + + size_t oldclen = S6RC_REPO_COMPILE_BUFLEN(strlen(wgola[GOLA_REPODIR]), strlen(argv[0])) ; + char oldc[oldclen] ; + + r = s6rc_repo_setcompile(wgola[GOLA_REPODIR], argv[0], wgola[GOLA_DEFBUNDLE], oldc, verbosity, wgola[GOLA_FDHUSER]) ; + if (r == -1) _exit(111) ; + if (!r) _exit(1) ; + if (r == 2) + { + if (wgolb & GOLB_KEEPOLD) + { + oldc[oldclen - 1] = '\n' ; + if (allwrite(1, oldc, oldclen) < oldclen) + strerr_diefu1sys(111, "write to stdout") ; + oldc[oldclen - 1] = 0 ; + } + else rm_rf(oldc) ; + } + _exit(0) ; +} diff --git a/src/repo/s6-rc-set-copy.c b/src/repo/s6-rc-set-copy.c index 202ac9e..7961ca0 100644 --- a/src/repo/s6-rc-set-copy.c +++ b/src/repo/s6-rc-set-copy.c @@ -21,8 +21,7 @@ enum golb_e { - GOLB_FORCE, - GOLB_N + GOLB_FORCE = 0x01 } ; enum gola_e @@ -32,12 +31,12 @@ enum gola_e GOLA_N } ; -static gol_bool const rgolb[1] = +static gol_bool const rgolb[] = { - { .so = 'f', .lo = "force", .clear = 0, .set = 1 << GOLB_FORCE } + { .so = 'f', .lo = "force", .clear = 0, .set = GOLB_FORCE } } ; -static gol_arg const rgola[2] = +static gol_arg const rgola[] = { { .so = 'v', .lo = "verbosity", .i = GOLA_VERBOSITY }, { .so = 'r', .lo = "repodir", .i = GOLA_REPODIR } @@ -74,7 +73,7 @@ static inline void docopy (char const *repo, char const *srcname, char const *ds { if (errno != ENOENT) strerr_diefu2sys(111, "access ", dst) ; } - else if (wgolb & (1 << GOLB_FORCE)) + else if (wgolb & GOLB_FORCE) { memcpy(olddst, dst, repolen + 9) ; r = readlink(dst, olddst + repolen + 9, dstlen + 9) ; @@ -107,26 +106,26 @@ static inline void docopy (char const *repo, char const *srcname, char const *ds int main (int argc, char const *const *argv) { - char const *repo = S6RC_REPO_BASE ; int fdlock ; unsigned int verbosity = 1 ; - char const *wgola[2] = { 0 } ; + char const *wgola[GOLA_N] = { 0 } ; unsigned int golc ; PROG = "s6-rc-set-copy" ; - golc = gol_main(argc, argv, rgolb, 1, rgola, 2, &wgolb, wgola) ; + wgola[GOLA_REPODIR] = S6RC_REPO_BASE ; + + golc = GOL_main(argc, argv, rgolb, rgola, &wgolb, wgola) ; argc -= golc ; argv += golc ; if (wgola[GOLA_VERBOSITY] && !uint0_scan(wgola[GOLA_VERBOSITY], &verbosity)) strerr_dief1x(100, "verbosity needs to be an unsigned integer") ; - if (wgola[GOLA_REPODIR]) repo = wgola[GOLA_REPODIR] ; if (argc < 2) dieusage() ; for (unsigned int i = 0 ; i < 2 ; i++) if (strchr(argv[i], '/') || strchr(argv[i], '\n')) strerr_dief1x(100, "set names cannot contain / or newlines") ; - fdlock = s6rc_repo_lock(repo, 1) ; - if (fdlock == -1) strerr_diefu2sys(111, "lock ", repo) ; + fdlock = s6rc_repo_lock(wgola[GOLA_REPODIR], 1) ; + if (fdlock == -1) strerr_diefu2sys(111, "lock ", wgola[GOLA_REPODIR]) ; tain_now_g() ; - docopy(repo, argv[0], argv[1]) ; - return 0 ; + docopy(wgola[GOLA_REPODIR], argv[0], argv[1]) ; + _exit(0) ; } diff --git a/src/repo/s6-rc-set-delete.c b/src/repo/s6-rc-set-delete.c index 2750abb..48a81f0 100644 --- a/src/repo/s6-rc-set-delete.c +++ b/src/repo/s6-rc-set-delete.c @@ -77,7 +77,7 @@ enum gola_e GOLA_N } ; -static gol_arg const rgola[2] = +static gol_arg const rgola[] = { { .so = 'v', .lo = "verbosity", .i = GOLA_VERBOSITY }, { .so = 'r', .lo = "repodir", .i = GOLA_REPODIR } @@ -85,18 +85,18 @@ static gol_arg const rgola[2] = int main (int argc, char const *const *argv) { - char const *repo = S6RC_REPO_BASE ; int fdlock ; unsigned int verbosity = 1 ; - char const *wgola[2] = { 0 } ; + char const *wgola[GOLA_N] = { 0 } ; unsigned int golc ; PROG = "s6-rc-set-delete" ; + wgola[GOLA_REPODIR] = S6RC_REPO_BASE ; + golc = gol_main(argc, argv, 0, 0, rgola, 2, 0, wgola) ; argc -= golc ; argv += golc ; if (wgola[GOLA_VERBOSITY] && !uint0_scan(wgola[GOLA_VERBOSITY], &verbosity)) strerr_dief1x(100, "verbosity needs to be an unsigned integer") ; - if (wgola[GOLA_REPODIR]) repo = wgola[GOLA_REPODIR] ; if (!argc) dieusage() ; for (unsigned int i = 0 ; i < argc ; i++) { @@ -108,11 +108,11 @@ int main (int argc, char const *const *argv) strerr_dief2x(100, "set names cannot ", "contain / or newlines") ; } - fdlock = s6rc_repo_lock(repo, 1) ; - if (fdlock == -1) strerr_diefu2sys(111, "lock ", repo) ; + fdlock = s6rc_repo_lock(wgola[GOLA_REPODIR], 1) ; + if (fdlock == -1) strerr_diefu2sys(111, "lock ", wgola[GOLA_REPODIR]) ; tain_now_g() ; for (unsigned int i = 0 ; i < argc ; i++) - dodelete(repo, argv[i]) ; - return 0 ; + dodelete(wgola[GOLA_REPODIR], argv[i]) ; + _exit(0) ; } diff --git a/src/repo/s6-rc-set-new.c b/src/repo/s6-rc-set-new.c index cd137fb..bc72f92 100644 --- a/src/repo/s6-rc-set-new.c +++ b/src/repo/s6-rc-set-new.c @@ -89,7 +89,7 @@ enum gola_e GOLA_N } ; -static gol_arg const rgola[2] = +static gol_arg const rgola[] = { { .so = 'v', .lo = "verbosity", .i = GOLA_VERBOSITY }, { .so = 'r', .lo = "repodir", .i = GOLA_REPODIR } @@ -97,18 +97,18 @@ static gol_arg const rgola[2] = int main (int argc, char const *const *argv) { - char const *repo = S6RC_REPO_BASE ; int fdlock ; unsigned int verbosity = 1 ; - char const *wgola[2] = { 0 } ; + char const *wgola[GOLA_N] = { 0 } ; unsigned int golc ; PROG = "s6-rc-set-new" ; + wgola[GOLA_REPODIR] = S6RC_REPO_BASE ; + golc = gol_main(argc, argv, 0, 0, rgola, 2, 0, wgola) ; argc -= golc ; argv += golc ; if (wgola[GOLA_VERBOSITY] && !uint0_scan(wgola[GOLA_VERBOSITY], &verbosity)) strerr_dief1x(100, "verbosity needs to be an unsigned integer") ; - if (wgola[GOLA_REPODIR]) repo = wgola[GOLA_REPODIR] ; if (!argc) dieusage() ; for (unsigned int i = 0 ; i < argc ; i++) { @@ -119,12 +119,12 @@ int main (int argc, char const *const *argv) if (strchr(argv[i], '/') || strchr(argv[i], '\n')) strerr_dief2x(100, "set names cannot ", "contain / or newlines") ; } - fdlock = s6rc_repo_lock(repo, 1) ; - if (fdlock == -1) strerr_diefu2sys(111, "lock ", repo) ; + fdlock = s6rc_repo_lock(wgola[GOLA_REPODIR], 1) ; + if (fdlock == -1) strerr_diefu2sys(111, "lock ", wgola[GOLA_REPODIR]) ; tain_now_g() ; for (unsigned int i = 0 ; i < argc ; i++) - newset(repo, argv[i]) ; + newset(wgola[GOLA_REPODIR], argv[i]) ; - return 0 ; + _exit(0) ; } |
