aboutsummaryrefslogtreecommitdiffstats
path: root/src/repo/s6rc_repo_setuptodate.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/repo/s6rc_repo_setuptodate.c')
-rw-r--r--src/repo/s6rc_repo_setuptodate.c34
1 files changed, 34 insertions, 0 deletions
diff --git a/src/repo/s6rc_repo_setuptodate.c b/src/repo/s6rc_repo_setuptodate.c
index f01143f..cfc6731 100644
--- a/src/repo/s6rc_repo_setuptodate.c
+++ b/src/repo/s6rc_repo_setuptodate.c
@@ -6,6 +6,7 @@
#include <string.h>
#include <stdint.h>
#include <errno.h>
+#include <unistd.h>
#include <skalibs/stat.h>
#include <skalibs/strerr.h>
@@ -34,12 +35,43 @@ int s6rc_repo_setuptodate (char const *repo, char const *set)
strerr_warnfusys("stat ", srcfn) ;
return -1 ;
}
+
+ /* Do we have a compiled db for this set? */
if (stat(dstfn, &stcompiled) == -1)
{
if (errno == ENOENT) return 0 ;
strerr_warnfusys("stat ", dstfn) ;
return -1 ;
}
+
+ /* Do we have a snapshot of the source set for the compiled db? */
+ {
+ struct stat stsnap ;
+ char snap[repolen + 54 + setlen] ;
+ ssize_t r ;
+ memcpy(snap, srcfn, repolen + 9) ;
+ memcpy(snap + repolen + 9, ".snapshot", 9) ;
+ r = readlink(dstfn, snap + repolen + 18, setlen + 35) ;
+ if (r == -1)
+ {
+ strerr_warnfusys("readlink ", dstfn) ;
+ return -1 ;
+ }
+ if (r != setlen + 34)
+ {
+ strerr_warnf("invalid symlink: ", dstfn) ;
+ return -1 ;
+ }
+ snap[repolen + setlen + 53] = 0 ;
+ if (stat(snap, &stsnap) == -1)
+ {
+ if (errno == ENOENT) return 0 ;
+ strerr_warnfusys("stat ", snap) ;
+ return -1 ;
+ }
+ }
+
+ /* Has the compiled db been built with the latest major s6-rc version? */
{
uint32_t version = s6rc_repo_read_major(dstfn) ;
if (!version)
@@ -49,6 +81,8 @@ int s6rc_repo_setuptodate (char const *repo, char const *set)
}
if (version < s6rc_get_major(S6RC_VERSION)) return 0 ;
}
+
+ /* Is the compiled db more recent than the source set? */
return
stsource.st_mtim.tv_sec < stcompiled.st_mtim.tv_sec ? 1 :
stsource.st_mtim.tv_sec > stcompiled.st_mtim.tv_sec ? 0 :