aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLaurent Bercot <ska-skaware@skarnet.org>2026-06-15 20:23:02 +0000
committerLaurent Bercot <ska-skaware@skarnet.org>2026-06-15 20:23:02 +0000
commit968a4dfecc4340dcfedf9d231e7465710219f762 (patch)
treef146ea146a8e795412727b0bd8c42ec7f42ab353
parent87b8fcabeecf2a9cff2ca596da54d6c1cf17d89f (diff)
downloads6-rc-968a4dfecc4340dcfedf9d231e7465710219f762.tar.gz
s6-rc-set-change: move if-dependencies tristate to two bools
-rw-r--r--NEWS5
-rw-r--r--doc/s6-rc-set-change.html56
-rw-r--r--doc/upgrade.html3
-rw-r--r--src/repo/s6-rc-set-change.c56
4 files changed, 56 insertions, 64 deletions
diff --git a/NEWS b/NEWS
index 2862d00..6279cf2 100644
--- a/NEWS
+++ b/NEWS
@@ -4,8 +4,11 @@ In 0.7.0.0
----------
- Bugfixes.
+ - s6-rc-bundle deleted.
- s6-rc-init is now idempotent and behaves better in pathological situations.
- - New "s6-rc reload" command.
+ - New "s6-rc reload" command. And new "reload" file for oneshots.
+ - s6-rc-set-change has -I|-i and -P|-p options, replacing -I fail|warn|pull.
+The redundant -f option is gone entirely.
In 0.6.1.1
diff --git a/doc/s6-rc-set-change.html b/doc/s6-rc-set-change.html
index 403079b..e731379 100644
--- a/doc/s6-rc-set-change.html
+++ b/doc/s6-rc-set-change.html
@@ -27,7 +27,7 @@ the <a href="repodefs.html#rx">rx</a> of some services.
<h2> Interface </h2>
<pre>
- s6-rc-set-change [ -v <em>verbosity</em> ] [ -r <em>repo</em> ] [ -E | -e ] [ -f | -I fail|pull|warn ] [ -n ] <em>set</em> <em>newrx</em> <em>services...</em>
+ s6-rc-set-change [ -v <em>verbosity</em> ] [ -r <em>repo</em> ] [ -E | -e ] [ -n ] [ -f ] [ -I | -i ] [ -P | -p ] <em>set</em> <em>newrx</em> <em>services...</em>
</pre>
<ul>
@@ -39,60 +39,58 @@ the <a href="repodefs.html#rx">rx</a> of some services.
<h2> Options </h2>
<dl>
- <dt> -v <em>verbosity</em>, --verbosity=<em>verbosity</em> </dt>
+ <dt> <tt>-v <em>verbosity</em></tt>, <tt>--verbosity=<em>verbosity</em></tt> </dt>
<dd> Be more or less verbose. The default is <strong>1</strong>, which means
that error messages and warnings will be written to stderr. 0 means that only
error messages will be written, and 2 or more adds informational messages. </dd>
- <dt> -r <em>repo</em>, --repository=<em>repo</em> </dt>
+ <dt> <tt>-r <em>repo</em></tt>, <tt>--repository=<em>repo</em></tt> </dt>
<dd> Use the repository in <em>repo</em>, which must exist. Default is
<strong>/var/lib/s6-rc/repository</strong>.
</dd>
- <dt> -E, --no-force-essential </dt>
+ <dt> <tt>-E</tt>, <tt>--no-force-essential</tt> </dt>
<dd> If a service needs to be moved to/from the <tt>always</tt> rx, fail and report
an error. This is the default. Services marked as <em>always</em> are normally defined
in the stores with <tt>flag-essential</tt>, and inconsistencies between essential
services should be resolved in the stores. </dd>
- <dt> -e, --force-essential </dt>
+ <dt> <tt>-e</tt>, <tt>--force-essential</tt> </dt>
<dd> Move services to/from the <tt>always</tt> rx if they need to be. This option
should only be used temporarily until the store inconsistency is fixed. Be aware that
moving a service from <em>always</em> to <em>usable</em> or <em>masked</em> may
result in an unbootable set. </dd>
- <dt> -f, --ignore-dependencies </dt>
- <dd> Change <em>services...</em> to <em>newrx</em>, but do not change any other
-services, even if the dependency graph would normally mandate it. This may result
-in an inconsistent set that you cannot commit. </dd>
-</dl>
-
- <dt> -I <em>action</em>, --if-dependencies-found=<em>action</em> </dt>
- <dd> Determine what to do if a dependency would make the set inconsistent.
-For instance, if service <tt>A</tt> depends on service <tt>B</tt>, they are both
-in the <tt>latent</tt> rx, and you are trying to change <tt>A</tt> to <tt>active</tt>
-without mentioning <tt>B</tt>, this would not work: in order to be brought up at
-boot time, <tt>A</tt> would first need <tt>B</tt> to also be brought up at boot time,
-so <tt>A</tt> can only be <tt>active</tt> if <tt>B</tt> also is. In that situation,
-what s6-rc-set-change does depends on the value of <em>action</em>:
- <ul>
- <li> <tt>fail</tt>: print an error message and exit 1. </li>
- <li> <tt>warn</tt>: print a warning message and proceed. This is the default. </li>
- <li> <tt>pull</tt>: print a warning message and pull the dependencies of
-<em>services...</em> into <em>newrx</em>. (Or the reverse dependencies, if
-you're trying to disable or mask services. </li>
- </ul>
- The warning messages are not printed if <em>verbosity</em> is 0. </dd>
-
<dt> -n, --dry-run </dt>
<dd> Check whether the command would succeed, print warning or error messages if
appropriate, but do not perform the actual modifications. </dd>
+ <dt> <tt>-I</tt>, <tt>--no-fail-on-dependencies</tt> </dt>
+ <dd> Do not fail if a dependency is found. Depending on the <tt>-P</tt> or <tt>-p</tt>
+flag, either print a warning message and proceed to make an inconsistent set, or pull the
+dependency into the change. This is the default. </dd>
+
+ <dt> <tt>-i</tt>, <tt>--fail-on-dependencies</tt> </dt>
+ <dd> If a dependency is found that would create an inconsistent set if the change was
+applied, print an error message and exit 1. </dd>
+
+ <dt> <tt>-P</tt>, <tt>--no-pull-dependencies</tt> </dt>
+ <dd> If a dependency is found that would create an inconsistent set if the change was
+applied, print a warning message (if verbosity is not 0) listing the services that
+also need to change prescriptions; then apply the change anyway. This is the default. </dd>
+
+ <dt> <tt>-p</tt>, <tt>--pull-dependencies</tt> </dt>
+ <dd> If a dependency is found that would create an inconsistent set, automatically
+extend the change to the dependencies as well so the set remain consistent. Print an
+informational message (if verbosity is 2 or more) listing the services that are being
+pulled into the change, then apply the change. </dd>
+</dl>
+
<h2> Exit codes </h2>
<dl>
<dt> 0 </dt> <dd> Success. </dd>
- <dt> 1 </dt> <dd> <tt>-I fail</tt> was given and dependencies prevented <em>services...</em>
+ <dt> 1 </dt> <dd> The <tt>-I</tt> option was given and dependencies prevented <em>services...</em>
from being changed to <em>newrx</em>. </dd>
<dt> 3 </dt> <dd> A service in <em>services...</em> was not found in the reference database. </dt>
<dt> 4 </dt> <dd> Invalid or corrupted reference database. </dd>
diff --git a/doc/upgrade.html b/doc/upgrade.html
index f61933c..f814e85 100644
--- a/doc/upgrade.html
+++ b/doc/upgrade.html
@@ -48,8 +48,9 @@ using the latest <a href="s6-rc-compile.html">s6-rc-compile</a> </li>
<li> Run the latest <a href="s6-rc-format-upgrade.html">s6-rc-format-upgrade</a> with the
newly obtained database </li>
<li> Run the latest <a href="s6-rc-update.html">s6-rc-update</a> with the same database </li>
- <li> Your system is now running the latest version of s6-rc; you can delete your old database </li>
+ <li> Your system is now running the latest version of s6-rc; you can delete your old database. </li>
</ul>
+ <li> <a href="s6-rc-set-change.html">s6-rc-set-change</a> has a different option syntax. </li>
</ul>
<h2> in 0.6.1.1 </h2>
diff --git a/src/repo/s6-rc-set-change.c b/src/repo/s6-rc-set-change.c
index 3dbb62a..6e5f9ea 100644
--- a/src/repo/s6-rc-set-change.c
+++ b/src/repo/s6-rc-set-change.c
@@ -18,14 +18,15 @@
#include <s6-rc/config.h>
#include <s6-rc/s6rc.h>
-#define USAGE "s6-rc-set-change [ -v verbosity ] [ -r repo ] [ -E | -e ] [ -f | -I fail|pull|warn ] [ -n ] set newrx services..."
+#define USAGE "s6-rc-set-change [ -v verbosity ] [ -r repo ] [ -E | -e ] [ -n ] [ -I | -i ] [ -P | -p ] set newrx services..."
#define dieusage() strerr_dieusage(100, USAGE)
enum golb_e
{
GOLB_FORCE_ESSENTIAL = 0x01,
- GOLB_IGNORE_DEPENDENCIES = 0x02,
- GOLB_DRYRUN = 0x04
+ GOLB_DRYRUN = 0x02,
+ GOLB_FAIL_ON_DEPS = 0x04,
+ GOLB_PULL_DEPS = 0x08,
} ;
enum gola_e
@@ -53,20 +54,17 @@ int main (int argc, char const *const *argv)
{
{ .so = 'E', .lo = "no-force-essential", .clear = GOLB_FORCE_ESSENTIAL, .set = 0 },
{ .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 }
+ { .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 = 'v', .lo = "verbosity", .i = GOLA_VERBOSITY },
{ .so = 'r', .lo = "repodir", .i = GOLA_REPODIR },
- { .so = 'I', .lo = "if-dependencies-found", .i = GOLA_FORCELEVEL }
- } ;
- static struct rxname_s const accepted_forcelevels[] =
- {
- { .name = "fail", .rx = 0 },
- { .name = "pull", .rx = 2 },
- { .name = "warn", .rx = 1 }
} ;
static struct rxname_s const accepted_rxs[] =
{
@@ -96,10 +94,8 @@ int main (int argc, char const *const *argv)
genalloc gatmp = GENALLOC_ZERO ; /* size_t whatever */
int fdlock ;
unsigned int verbosity = 1 ;
- unsigned int forcelevel = 1 ;
char const *wgola[GOLA_N] = { 0 } ;
uint64_t wgolb = 0 ;
- unsigned int golc ;
struct rxname_s *newrx ;
size_t max = 0, sabase ;
s6rc_repo_sv *list ;
@@ -108,27 +104,22 @@ int main (int argc, char const *const *argv)
PROG = "s6-rc-set-change" ;
wgola[GOLA_REPODIR] = S6RC_REPODIR ;
- golc = GOL_main(argc, argv, rgolb, rgola, &wgolb, wgola) ;
+ unsigned int 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_FORCELEVEL])
- {
- struct rxname_s *p = bsearch(wgola[GOLA_FORCELEVEL], accepted_forcelevels, sizeof(accepted_forcelevels)/sizeof(struct rxname_s), sizeof(struct rxname_s), &rxname_cmp) ;
- if (!p) strerr_dief1x(100, "if-dependencies-found needs to be fail, warn or pull") ;
- forcelevel = p->rx ;
- }
+ strerr_dief(100, "verbosity needs to be an unsigned integer") ;
if (argc < 3) dieusage() ;
s6rc_repo_sanitize_setname(argv[0]) ;
newrx = bsearch(argv[1], accepted_rxs, sizeof(accepted_rxs)/sizeof(struct rxname_s), sizeof(struct rxname_s), &rxname_cmp) ;
- if (!newrx) strerr_dief2x(100, "unrecognized state change directive: ", argv[1]) ;
+ if (!newrx) strerr_dief(100, "unrecognized state change directive: ", argv[1]) ;
if (newrx->rx == 3 && !(wgolb & GOLB_FORCE_ESSENTIAL))
- strerr_diefu1x(100, "artificially mark a service as essential without --force-essential") ;
+ strerr_diefu(100, "artificially mark a service as essential without --force-essential") ;
for (unsigned int i = 2 ; i < argc ; i++) s6rc_repo_sanitize_svname(argv[i]) ;
tain_now_g() ;
fdlock = s6rc_repo_lock(wgola[GOLA_REPODIR], 1) ;
- if (fdlock == -1) strerr_diefu2sys(111, "lock ", wgola[GOLA_REPODIR]) ;
+ if (fdlock == -1) strerr_diefusys(111, "lock ", wgola[GOLA_REPODIR]) ;
if (!s6rc_repo_makesvlist_byname(wgola[GOLA_REPODIR], argv[0], &storage, &svlist)) _exit(111) ;
list = genalloc_s(s6rc_repo_sv, &svlist) ;
listn = genalloc_len(s6rc_repo_sv, &svlist) ;
@@ -138,7 +129,7 @@ int main (int argc, char const *const *argv)
if (e) _exit(e) ;
}
n = genalloc_len(size_t, &indices) ;
- if (!n) strerr_dief1x(101, "can't happen: 0 services in flattened list!") ;
+ if (!n) strerr_dief(101, "can't happen: 0 services in flattened list!") ;
s6rc_repo_sv starting[n] ;
uint32_t ind[n] ;
@@ -147,7 +138,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 ", wgola[GOLA_REPODIR], ": service ", s, " is defined in the reference database but not in the textual representation of the set") ;
+ if (!p) strerr_dief(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 ;
@@ -156,7 +147,6 @@ int main (int argc, char const *const *argv)
storage.len = sabase ;
genalloc_setlen(size_t, &indices, 0) ;
- if (!(wgolb & GOLB_IGNORE_DEPENDENCIES))
{
size_t m = 0 ;
char const *tmpstart[n] ;
@@ -177,16 +167,16 @@ int main (int argc, char const *const *argv)
{
uint32_t const *bads = genalloc_s(uint32_t, &indices) ;
uint32_t badn = genalloc_len(uint32_t, &indices) ;
- if (verbosity || !forcelevel)
+ if (wgolb & GOLB_FAIL_ON_DEPS || verbosity > !!(wgolb & GOLB_PULL_DEPS))
{
char const *arg[10 + (badn << 1)] ;
arg[0] = PROG ;
arg[1] = ": " ;
- arg[2] = !forcelevel ? "fatal" : "warning" ;
+ arg[2] = wgolb & GOLB_FAIL_ON_DEPS ? "fatal" : wgolb & GOLB_PULL_DEPS ? "info" : "warning" ;
arg[3] = ": the following services (" ;
arg[4] = newrx->rx >= 2 ? "dependencies of" : "depending on" ;
arg[5] = " the ones given as arguments, or part of the same pipeline) " ;
- arg[6] = forcelevel == 2 ? "are also being" : "also need to be" ;
+ arg[6] = wgolb & GOLB_PULL_DEPS ? "are also being" : "also need to be" ;
arg[7] = " changed to \"" ;
arg[8] = s6rc_repo_rxnames[newrx->rx] ;
arg[9] = "\": " ;
@@ -197,9 +187,9 @@ int main (int argc, char const *const *argv)
}
strerr_warnv(arg, 10 + (badn << 1)) ;
}
- if (!forcelevel) _exit(1) ;
+ if (wgolb & GOLB_FAIL_ON_DEPS) _exit(1) ;
if (wgolb & GOLB_DRYRUN) _exit(0) ;
- if (forcelevel == 2)
+ if (wgolb & GOLB_PULL_DEPS)
{
s6rc_repo_sv full[n + badn] ;
for (uint32_t i = 0 ; i < n ; i++) full[i] = starting[i] ;