aboutsummaryrefslogtreecommitdiffstats
path: root/src/repo
diff options
context:
space:
mode:
authorLaurent Bercot <ska-skaware@skarnet.org>2026-10-15 08:19:48 +0000
committerLaurent Bercot <ska-skaware@skarnet.org>2026-10-15 08:19:48 +0000
commitdb3fb428599c9c8fe105dcf4ba8d1c914c54cc26 (patch)
treef83ab9920c39916777a35e5034a4cb9f43614da8 /src/repo
parent91a0655557e707977f583b2142bda898ee599fd8 (diff)
downloads6-rc-db3fb428599c9c8fe105dcf4ba8d1c914c54cc26.tar.gz
More work on format-upgrade inclusion: real meta-information storageHEADmain
If a db format upgrade is necessary, we need to compile the snapshot with the new s6-rc-compile. There's data we need to pass to it that isn't stored (options passed when committing the original set), so we store it in the db itself (patching s6-rc-compile). We modify the s6-rc-compile wrappers to pass all this metadata. Next, we will compile the snapshot.
Diffstat (limited to 'src/repo')
-rw-r--r--src/repo/deps-lib/s6rcrepo1
-rw-r--r--src/repo/s6rc_repo_compile.c14
-rw-r--r--src/repo/s6rc_repo_read_major.c15
-rw-r--r--src/repo/s6rc_repo_setcompile.c2
4 files changed, 18 insertions, 14 deletions
diff --git a/src/repo/deps-lib/s6rcrepo b/src/repo/deps-lib/s6rcrepo
index aee5f34..eb1ead9 100644
--- a/src/repo/deps-lib/s6rcrepo
+++ b/src/repo/deps-lib/s6rcrepo
@@ -7,6 +7,7 @@ s6rc_repo_fillset.o
s6rc_repo_fixset.o
s6rc_repo_flattenservices.o
s6rc_repo_getserviceflags.o
+s6rc_repo_install_needs_upgrade.o
s6rc_repo_list_sets.o
s6rc_repo_listalldeps.o
s6rc_repo_listcontents.o
diff --git a/src/repo/s6rc_repo_compile.c b/src/repo/s6rc_repo_compile.c
index f89a65a..fc7d8ea 100644
--- a/src/repo/s6rc_repo_compile.c
+++ b/src/repo/s6rc_repo_compile.c
@@ -16,12 +16,13 @@
#include <s6-rc/config.h>
#include <s6-rc/repo.h>
-int s6rc_repo_compile (char const *repo, char const *set, char const *const *rxs, uint8_t nrxs, char *oldc, unsigned int verbosity, char const *fdhuser, char const *catchall)
+int s6rc_repo_compile (char const *repo, char const *set, char const *const *rxs, uint8_t nrxs, char *oldc, unsigned int verbosity, char const *fdhuser, char const *catchall, char const *defbundle)
{
size_t repolen = strlen(repo) ;
size_t setlen = strlen(set) ;
size_t totrxlen = 0 ;
int needprefix = strcmp(set, ".ref") ;
+ int needsnapshot = needprefix && memcmp(set, ".snapshot.", 10) ;
char snap[setlen + 44] ;
char newc[repolen + setlen + 45] ;
memcpy(newc, repo, repolen) ;
@@ -38,7 +39,7 @@ int s6rc_repo_compile (char const *repo, char const *set, char const *const *rxs
pid_t pid ;
size_t m = 0 ;
int wstat ;
- char const *argv[11 + nrxs] ;
+ char const *argv[13 + nrxs] ;
char fmtv[UINT_FMT] ;
char src[nrxs * (repolen + 10 + (needprefix ? setlen + 1 : 0)) + totrxlen] ;
char *w = src ;
@@ -57,6 +58,11 @@ int s6rc_repo_compile (char const *repo, char const *set, char const *const *rxs
argv[m++] = "-L" ;
argv[m++] = catchall ;
}
+ if (defbundle)
+ {
+ argv[m++] = "-D" ;
+ argv[m++] = defbundle ;
+ }
argv[m++] = "--" ;
argv[m++] = newc ;
for (uint8_t i = 0 ; i < nrxs ; i++)
@@ -96,7 +102,7 @@ int s6rc_repo_compile (char const *repo, char const *set, char const *const *rxs
}
}
- if (needprefix)
+ if (needsnapshot)
{
int e ;
memcpy(snap, ".snapshot", 9) ;
@@ -124,7 +130,7 @@ int s6rc_repo_compile (char const *repo, char const *set, char const *const *rxs
{
int e = errno ;
rm_rf(newc) ;
- if (needprefix) s6rc_repo_setdelete(repo, snap) ;
+ if (needsnapshot) s6rc_repo_setdelete(repo, snap) ;
errno = e ;
strerr_warnfu4sys("atomically symlink ", newc + repolen + 10, " to ", fn) ;
return -1 ;
diff --git a/src/repo/s6rc_repo_read_major.c b/src/repo/s6rc_repo_read_major.c
index 08d646b..1501fe2 100644
--- a/src/repo/s6rc_repo_read_major.c
+++ b/src/repo/s6rc_repo_read_major.c
@@ -16,15 +16,12 @@ uint32_t s6rc_repo_read_major (char const *compiled)
size_t clen = strlen(compiled) ;
ssize_t r ;
uint32_t res ;
- char tmp[UINT32_FMT] ;
- char fn[clen + 7] ;
+ char pack[5] ;
+ char fn[clen + 16] ;
memcpy(fn, compiled, clen) ;
- memcpy(fn + clen, "/major", 7) ;
- r = openreadnclose(fn, tmp, UINT32_FMT) ;
- if (r == -1) return errno == ENOENT ? 7 : 0 ; /* up to 0.7.0.0 doesn't have db/major */
- if (!r) return 0 ;
- if (tmp[r] != '\n') return (errno = EPROTO, 0) ;
- tmp[r] = 0 ;
- if (uint320_scan(tmp, &res) != r) return (errno = EPROTO, 0) ;
+ memcpy(fn + clen, "/metainfo/major", 16) ;
+ r = openreadnclose(fn, pack, 5) ;
+ if (r != 4) return r == -1 && errno == ENOENT ? 7 : 0 ; /* up to 0.7.0.0 doesn't have metainfo */
+ uint32_unpack_big(pack, &res) ;
return res ;
}
diff --git a/src/repo/s6rc_repo_setcompile.c b/src/repo/s6rc_repo_setcompile.c
index 1bdbea8..f894f64 100644
--- a/src/repo/s6rc_repo_setcompile.c
+++ b/src/repo/s6rc_repo_setcompile.c
@@ -13,7 +13,7 @@ int s6rc_repo_setcompile (char const *repo, char const *set, char const *defbund
int r ;
if (!s6rc_repo_makesetbundles(repo, set, verbosity)) return -1 ;
if (!s6rc_repo_makedefbundle(repo, set, defbundle)) return -1 ;
- r = s6rc_repo_compile(repo, set, rxs, 4, oldc, verbosity, fdhuser, catchall) ;
+ r = s6rc_repo_compile(repo, set, rxs, 4, oldc, verbosity, fdhuser, catchall, defbundle) ;
{
int e = errno ;