diff options
| author | Laurent Bercot <ska-skaware@skarnet.org> | 2026-10-02 02:22:28 +0000 |
|---|---|---|
| committer | Laurent Bercot <ska-skaware@skarnet.org> | 2026-10-02 02:22:28 +0000 |
| commit | 7c93a058c8d7e21aea2aad8f3114c8422bf6faf7 (patch) | |
| tree | ae569edcc313796b679ec8374e50668c973ffd5f /src/repo/s6rc_repo_compile.c | |
| parent | 3a151bcd1835e1f7871a93c5b0d90f856562a98a (diff) | |
| download | s6-rc-7c93a058c8d7e21aea2aad8f3114c8422bf6faf7.tar.gz | |
First part of the format-upgrade support in repo
In order to work across major bumps, we need to add a call to
s6-rc-format-upgrade before s6-rc-update in the s6-rc-set-install
sequence of commands.
s6-rc-format-upgrade only works when the db is exactly the same
across s6-rc versions. That means we need to have the source version
of the current live set at all times, in order to compile it with
the new s6-rc version before upgrading and then updating.
So:
1. we take a snapshot of the source version of a set every time
we commit.
2. we refuse to install if we don't have the snapshot.
3. we add s6-rc-format-upgrade to the processing chain
4. for cleanup: after installing, we delete all the snapshots of
the set except the one that corresponds to the newly
installed live set.
This commit implements 1: taking the snapshot. It's a regular
s6-rc-set-copy, using an internal name. We refactor
s6-rc-set-copy and s6-rc-set-delete to have primitives we can
use internally.
Wait for later commits before using repo, else you'll fill
your repository with snapshots that won't get cleaned up.
TBD: how to store the s6-rc version in the compiled db. We
probably need to add a small file in there.
Diffstat (limited to 'src/repo/s6rc_repo_compile.c')
| -rw-r--r-- | src/repo/s6rc_repo_compile.c | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/src/repo/s6rc_repo_compile.c b/src/repo/s6rc_repo_compile.c index 64f8879..83fa744 100644 --- a/src/repo/s6rc_repo_compile.c +++ b/src/repo/s6rc_repo_compile.c @@ -22,6 +22,7 @@ int s6rc_repo_compile (char const *repo, char const *set, char const *const *rxs size_t setlen = strlen(set) ; size_t totrxlen = 0 ; int needprefix = strcmp(set, ".ref") ; + char snap[repolen + setlen + 37] ; char newc[repolen + setlen + 45] ; memcpy(newc, repo, repolen) ; memcpy(newc + repolen, "/compiled/.", 11) ; @@ -89,6 +90,26 @@ int s6rc_repo_compile (char const *repo, char const *set, char const *const *rxs return (WEXITSTATUS(wstat) == 1) - 1 ; } } + + if (needprefix) + { + int e ; + memcpy(snap, ".snapshot:", 10) ; + memcpy(snap + 10, newc + repolen + 11, setlen + 26) ; + snap[repolen + setlen + 36] = 0 ; + e = s6rc_repo_setcopy(repo, set, snap, 1) ; + switch (e) + { + case -2 : + strerr_warnf("internal layout error while taking a snapshot of set ", set) ; + return (errno = EILSEQ, -1) ; + case 0 : break ; + default : + strerr_warnfusys("take a snapshot of set ", set) ; + return (errno = e, -1) ; + } + } + { char fn[repolen + setlen + 11] ; memcpy(fn, newc, repolen + 10) ; @@ -97,10 +118,12 @@ int s6rc_repo_compile (char const *repo, char const *set, char const *const *rxs { int e = errno ; rm_rf(newc) ; + s6rc_repo_setdelete(repo, snap) ; errno = e ; strerr_warnfu4sys("atomically symlink ", newc + repolen + 10, " to ", fn) ; return -1 ; } } + return 1 + !!oldc[repolen + 10] ; } |
