aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/include/s6-rc/s6rc-constants.h2
-rw-r--r--src/repo/s6-rc-repo-init.c2
-rw-r--r--src/repo/s6-rc-repo-sync.c2
-rw-r--r--src/repo/s6-rc-set-change.c2
-rw-r--r--src/repo/s6-rc-set-commit.c2
-rw-r--r--src/repo/s6-rc-set-copy.c2
-rw-r--r--src/repo/s6-rc-set-delete.c2
-rw-r--r--src/repo/s6-rc-set-install.c42
-rw-r--r--src/repo/s6-rc-set-new.c2
-rw-r--r--src/s6-rc/s6-rc-bundle.c2
-rw-r--r--src/s6-rc/s6-rc-db.c2
-rw-r--r--src/s6-rc/s6-rc-format-upgrade.c2
-rw-r--r--src/s6-rc/s6-rc-init.c4
-rw-r--r--src/s6-rc/s6-rc-oneshot-run.c2
-rw-r--r--src/s6-rc/s6-rc-update.c4
-rw-r--r--src/s6-rc/s6-rc.c2
16 files changed, 41 insertions, 35 deletions
diff --git a/src/include/s6-rc/s6rc-constants.h b/src/include/s6-rc/s6rc-constants.h
index 168dac8..833e0a7 100644
--- a/src/include/s6-rc/s6rc-constants.h
+++ b/src/include/s6-rc/s6rc-constants.h
@@ -3,8 +3,6 @@
#ifndef S6RC_CONSTANTS_H
#define S6RC_CONSTANTS_H
-#define S6RC_COMPILED_BASE "/etc/s6-rc/compiled"
-
#define S6RC_ONESHOT_RUNNER "s6rc-oneshot-runner"
#define S6RC_ONESHOT_RUNNER_LEN (sizeof S6RC_ONESHOT_RUNNER - 1)
diff --git a/src/repo/s6-rc-repo-init.c b/src/repo/s6-rc-repo-init.c
index 3c353fe..c18b7a3 100644
--- a/src/repo/s6-rc-repo-init.c
+++ b/src/repo/s6-rc-repo-init.c
@@ -72,7 +72,7 @@ int main (int argc, char const *const *argv)
int lockfd ;
PROG = "s6-rc-repo-init" ;
- wgola[GOLA_REPODIR] = S6RC_REPO_BASE ;
+ wgola[GOLA_REPODIR] = S6RC_REPODIR ;
golc = GOL_main(argc, argv, rgolb, rgola, &wgolb, wgola) ;
argc -= golc ; argv += golc ;
diff --git a/src/repo/s6-rc-repo-sync.c b/src/repo/s6-rc-repo-sync.c
index ce04d7b..282f181 100644
--- a/src/repo/s6-rc-repo-sync.c
+++ b/src/repo/s6-rc-repo-sync.c
@@ -35,7 +35,7 @@ int main (int argc, char const *const *argv)
int fdlock, r ;
PROG = "s6-rc-repo-sync" ;
- wgola[GOLA_REPODIR] = S6RC_REPO_BASE ;
+ wgola[GOLA_REPODIR] = S6RC_REPODIR ;
golc = gol_main(argc, argv, 0, 0, rgola, 3, 0, wgola) ;
argc -= golc ; argv += golc ;
diff --git a/src/repo/s6-rc-set-change.c b/src/repo/s6-rc-set-change.c
index d5ca4ed..1ab92f6 100644
--- a/src/repo/s6-rc-set-change.c
+++ b/src/repo/s6-rc-set-change.c
@@ -108,7 +108,7 @@ int main (int argc, char const *const *argv)
uint32_t listn, n ;
PROG = "s6-rc-set-change" ;
- wgola[GOLA_REPODIR] = S6RC_REPO_BASE ;
+ wgola[GOLA_REPODIR] = S6RC_REPODIR ;
golc = GOL_main(argc, argv, rgolb, rgola, &wgolb, wgola) ;
argc -= golc ; argv += golc ;
diff --git a/src/repo/s6-rc-set-commit.c b/src/repo/s6-rc-set-commit.c
index efdb2a9..45d5708 100644
--- a/src/repo/s6-rc-set-commit.c
+++ b/src/repo/s6-rc-set-commit.c
@@ -61,7 +61,7 @@ int main (int argc, char const *const *argv)
int r ;
PROG = "s6-rc-set-commit" ;
- wgola[GOLA_REPODIR] = S6RC_REPO_BASE ;
+ wgola[GOLA_REPODIR] = S6RC_REPODIR ;
wgola[GOLA_DEFBUNDLE] = "default" ;
golc = GOL_main(argc, argv, rgolb, rgola, &wgolb, wgola) ;
diff --git a/src/repo/s6-rc-set-copy.c b/src/repo/s6-rc-set-copy.c
index 3093aaf..21b9cda 100644
--- a/src/repo/s6-rc-set-copy.c
+++ b/src/repo/s6-rc-set-copy.c
@@ -111,7 +111,7 @@ int main (int argc, char const *const *argv)
unsigned int golc ;
PROG = "s6-rc-set-copy" ;
- wgola[GOLA_REPODIR] = S6RC_REPO_BASE ;
+ wgola[GOLA_REPODIR] = S6RC_REPODIR ;
golc = GOL_main(argc, argv, rgolb, rgola, &wgolb, wgola) ;
argc -= golc ; argv += golc ;
diff --git a/src/repo/s6-rc-set-delete.c b/src/repo/s6-rc-set-delete.c
index d0d0f96..24459f5 100644
--- a/src/repo/s6-rc-set-delete.c
+++ b/src/repo/s6-rc-set-delete.c
@@ -90,7 +90,7 @@ int main (int argc, char const *const *argv)
unsigned int golc ;
PROG = "s6-rc-set-delete" ;
- wgola[GOLA_REPODIR] = S6RC_REPO_BASE ;
+ wgola[GOLA_REPODIR] = S6RC_REPODIR ;
golc = gol_main(argc, argv, 0, 0, rgola, 2, 0, wgola) ;
argc -= golc ; argv += golc ;
diff --git a/src/repo/s6-rc-set-install.c b/src/repo/s6-rc-set-install.c
index e8893b2..22f46b4 100644
--- a/src/repo/s6-rc-set-install.c
+++ b/src/repo/s6-rc-set-install.c
@@ -16,13 +16,15 @@
#include <skalibs/buffer.h>
#include <skalibs/strerr.h>
#include <skalibs/gol.h>
+#include <skalibs/stralloc.h>
#include <skalibs/djbunix.h>
#include <skalibs/cspawn.h>
+#include <skalibs/unix-transactional.h>
#include <s6-rc/config.h>
#include <s6-rc/s6rc.h>
-#define USAGE "s6-rc-set-install [ -v verbosity ] [ -l livedir ] [ -r repo ] [ -f convfile ] [ -b ] [ -K ] set bootdbdir"
+#define USAGE "s6-rc-set-install [ -v verbosity ] [ -c bootdb ] [ -l livedir ] [ -r repo ] [ -f convfile ] [ -b ] [ -K ] set"
#define dieusage() strerr_dieusage(100, USAGE)
enum golb_e
@@ -34,6 +36,7 @@ enum golb_e
enum gola_e
{
GOLA_VERBOSITY,
+ GOLA_BOOTDB,
GOLA_LIVEDIR,
GOLA_REPODIR,
GOLA_CONVFILE,
@@ -49,6 +52,7 @@ static gol_bool const rgolb[] =
static gol_arg const rgola[] =
{
{ .so = 'v', .lo = "verbosity", .i = GOLA_VERBOSITY },
+ { .so = 'c', .lo = "bootdb", .i = GOLA_BOOTDB },
{ .so = 'l', .lo = "livedir", .i = GOLA_LIVEDIR },
{ .so = 'r', .lo = "repodir", .i = GOLA_REPODIR },
{ .so = 'f', .lo = "conversion-file", .i = GOLA_CONVFILE }
@@ -62,16 +66,18 @@ int main (int argc, char const *const *argv)
uint64_t wgolb = 0 ;
unsigned int golc ;
int r ;
+ stralloc sa = STRALLOC_ZERO ;
PROG = "s6-rc-set-install" ;
- wgola[GOLA_LIVEDIR] = S6RC_LIVE_BASE ;
- wgola[GOLA_REPODIR] = S6RC_REPO_BASE ;
+ wgola[GOLA_BOOTDB] = S6RC_BOOTDB ;
+ wgola[GOLA_LIVEDIR] = S6RC_LIVEDIR ;
+ wgola[GOLA_REPODIR] = S6RC_REPODIR ;
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 < 2) dieusage() ;
+ if (!argc) dieusage() ;
if (strchr(argv[0], '/') || strchr(argv[0], '\n'))
strerr_dief1x(100, "set names cannot contain / or newlines") ;
@@ -84,11 +90,14 @@ int main (int argc, char const *const *argv)
if (r == -1) _exit(111) ;
if (!r) strerr_dief3x(7, "set ", argv[0], " is not up-to-date; commit it first") ;
+ if (!sadirname(&sa, wgola[GOLA_BOOTDB], strlen(wgola[GOLA_BOOTDB]))
+ || !stralloc_0(&sa)) strerr_diefu1sys(111, "sadirname") ;
+ sa.len-- ;
+
{
size_t repolen = strlen(wgola[GOLA_REPODIR]) ;
size_t setlen = strlen(argv[0]) ;
size_t clen = S6RC_REPO_COMPILE_BUFLEN(repolen, setlen) ;
- size_t dstlen = strlen(argv[1]) ;
ssize_t l ;
pid_t pid ;
int wstat ;
@@ -97,32 +106,28 @@ int main (int argc, char const *const *argv)
char fmtv[UINT_FMT] ;
char clink[repolen + setlen + 11] ;
char cfull[clen] ;
- char dstfn[dstlen + setlen + 36] ;
+ char dstfn[sa.len + setlen + 36] ;
fmtv[uint_fmt(fmtv, verbosity)] = 0 ;
memcpy(clink, wgola[GOLA_REPODIR], repolen) ;
memcpy(clink + repolen, "/compiled/", 10) ;
memcpy(clink + repolen + 10, argv[0], setlen + 1) ;
memcpy(cfull, clink, repolen + 10) ;
- memcpy(dstfn, argv[1], dstlen) ;
- dstfn[dstlen] = '/' ;
+ memcpy(dstfn, sa.s, sa.len) ;
+ dstfn[sa.len] = '/' ;
l = readlink(clink, cfull + repolen + 10, setlen + 35) ;
if (l == -1) strerr_diefu2sys(111, "readlink ", clink) ;
if (l >= setlen + 35) strerr_diefu2x(102, "incorrect/unexpected link contents for ", clink) ;
cfull[repolen + 10 + l] = 0 ;
- memcpy(dstfn + dstlen + 1, cfull + repolen + 10, l+1) ;
+ memcpy(dstfn + sa.len + 1, cfull + repolen + 10, l+1) ;
l = 0 ;
{
struct stat st ;
- if (stat(argv[1], &st) == -1)
- strerr_diefu2sys(111, "stat ", argv[1]) ;
- if (!S_ISDIR(st.st_mode))
- strerr_dief2x(100, argv[1], " is not a directory") ;
if (stat(dstfn, &st) == -1)
{
if (errno != ENOENT)
strerr_diefu2sys(111, "stat ", dstfn) ;
}
- else strerr_dief2x(102, dstfn, " already exists!?") ;
+ else strerr_dief2x(102, dstfn, " already exists") ;
}
{
size_t llen = strlen(wgola[GOLA_LIVEDIR]) ;
@@ -182,7 +187,7 @@ int main (int argc, char const *const *argv)
fmt[int_fmt(fmt, r)] = 0 ;
rm_rf(dstfn) ;
errno = e ;
- strerr_dief4x(r, uargv[0], " exited with code ", fmt, ": live database switch NOT performed") ;
+ strerr_dief4x(r, uargv[0], " exited with code ", fmt, " (live database switch was NOT performed)") ;
}
if (olddb)
{
@@ -190,7 +195,7 @@ int main (int argc, char const *const *argv)
{
if (buffer_puts(buffer_1small, olddb) == -1
|| !buffer_putflush(buffer_1small, "\n", 1))
- strerr_diefu1sys(111, "write to stdout (live database switch performed)") ;
+ strerr_diefu2sys(111, "write to stdout", " (live database switch was performed)") ;
}
else rm_rf(olddb) ;
}
@@ -198,8 +203,11 @@ int main (int argc, char const *const *argv)
{
char fmt[INT_FMT] ;
fmt[int_fmt(fmt, r)] = 0 ;
- strerr_dief4x(r, uargv[0], " exited with code ", fmt, ", but the live database switch was performed") ;
+ strerr_dief4x(r, uargv[0], " exited with code ", fmt, " (live database switch was performed") ;
}
+ if (!atomic_symlink4(dstfn + sa.len + 1, argv[1], 0, 0))
+ strerr_diefu6sys(111, "symlink ", dstfn + sa.len + 1, " to ", argv[1], " (live database switch was performed)", " (update that link manually or next boot might fail)") ;
}
+ // stralloc_free(&sa) ;
_exit(0) ;
}
diff --git a/src/repo/s6-rc-set-new.c b/src/repo/s6-rc-set-new.c
index 010c2b1..e81bee3 100644
--- a/src/repo/s6-rc-set-new.c
+++ b/src/repo/s6-rc-set-new.c
@@ -106,7 +106,7 @@ int main (int argc, char const *const *argv)
unsigned int golc ;
PROG = "s6-rc-set-new" ;
- wgola[GOLA_REPODIR] = S6RC_REPO_BASE ;
+ wgola[GOLA_REPODIR] = S6RC_REPODIR ;
golc = gol_main(argc, argv, 0, 0, rgola, 2, 0, wgola) ;
argc -= golc ; argv += golc ;
diff --git a/src/s6-rc/s6-rc-bundle.c b/src/s6-rc/s6-rc-bundle.c
index 5c486d5..d2b447a 100644
--- a/src/s6-rc/s6-rc-bundle.c
+++ b/src/s6-rc/s6-rc-bundle.c
@@ -225,7 +225,7 @@ static inline unsigned int parse_command (char const *command)
int main (int argc, char const **argv)
{
- char const *live = S6RC_LIVE_BASE ;
+ char const *live = S6RC_LIVEDIR ;
char const *compiled = 0 ;
unsigned int what ;
int force = 0 ;
diff --git a/src/s6-rc/s6-rc-db.c b/src/s6-rc/s6-rc-db.c
index 56ee3d7..4b4c081 100644
--- a/src/s6-rc/s6-rc-db.c
+++ b/src/s6-rc/s6-rc-db.c
@@ -320,7 +320,7 @@ static inline unsigned int parse_list (char const *command)
int main (int argc, char const *const *argv)
{
- char const *live = S6RC_LIVE_BASE ;
+ char const *live = S6RC_LIVEDIR ;
unsigned int what, subwhat = 0 ;
int up = 1 ;
int blocking = 0 ;
diff --git a/src/s6-rc/s6-rc-format-upgrade.c b/src/s6-rc/s6-rc-format-upgrade.c
index e2db73f..e7e29b5 100644
--- a/src/s6-rc/s6-rc-format-upgrade.c
+++ b/src/s6-rc/s6-rc-format-upgrade.c
@@ -33,7 +33,7 @@ static inline void update_livedir (char const *live, char const *newcompiled, ta
int main (int argc, char const *const *argv, char const *const *envp)
{
tain deadline ;
- char const *live = S6RC_LIVE_BASE ;
+ char const *live = S6RC_LIVEDIR ;
int blocking = 0 ;
int livelock ;
PROG = "s6-rc-format-upgrade" ;
diff --git a/src/s6-rc/s6-rc-init.c b/src/s6-rc/s6-rc-init.c
index 19b4770..05c5b37 100644
--- a/src/s6-rc/s6-rc-init.c
+++ b/src/s6-rc/s6-rc-init.c
@@ -32,8 +32,8 @@ int main (int argc, char const *const *argv)
tain deadline ;
stralloc sa = STRALLOC_ZERO ;
size_t dirlen ;
- char const *live = S6RC_LIVE_BASE ;
- char const *compiled = S6RC_COMPILED_BASE ;
+ char const *live = S6RC_LIVEDIR ;
+ char const *compiled = S6RC_BOOTDB ;
char const *prefix = "" ;
int deref = 0 ;
PROG = "s6-rc-init" ;
diff --git a/src/s6-rc/s6-rc-oneshot-run.c b/src/s6-rc/s6-rc-oneshot-run.c
index 136a318..87a0399 100644
--- a/src/s6-rc/s6-rc-oneshot-run.c
+++ b/src/s6-rc/s6-rc-oneshot-run.c
@@ -19,7 +19,7 @@
int main (int argc, char const *const *argv)
{
- char const *live = S6RC_LIVE_BASE ;
+ char const *live = S6RC_LIVEDIR ;
unsigned int number ;
int up ;
int blocking = 0 ;
diff --git a/src/s6-rc/s6-rc-update.c b/src/s6-rc/s6-rc-update.c
index 1ceeba9..bec6bc5 100644
--- a/src/s6-rc/s6-rc-update.c
+++ b/src/s6-rc/s6-rc-update.c
@@ -41,8 +41,8 @@
#define dieusage() strerr_dieusage(100, USAGE)
#define dienomem() strerr_diefu1sys(111, "build string") ;
-static char const *live = S6RC_LIVE_BASE ;
-static size_t livelen = sizeof(S6RC_LIVE_BASE) - 1 ;
+static char const *live = S6RC_LIVEDIR ;
+static size_t livelen = sizeof(S6RC_LIVEDIR) - 1 ;
static unsigned int verbosity = 1 ;
diff --git a/src/s6-rc/s6-rc.c b/src/s6-rc/s6-rc.c
index 1dee5f9..8a3302e 100644
--- a/src/s6-rc/s6-rc.c
+++ b/src/s6-rc/s6-rc.c
@@ -38,7 +38,7 @@ struct pidindex_s
} ;
static unsigned int verbosity = 1 ;
-static char const *live = S6RC_LIVE_BASE ;
+static char const *live = S6RC_LIVEDIR ;
static size_t livelen ;
static pidindex_t *pidindex ;
static unsigned int npids = 0 ;