aboutsummaryrefslogtreecommitdiffstats
path: root/src/libs6rc/s6rc_repo_fix.c
diff options
context:
space:
mode:
authorLaurent Bercot <ska-skaware@skarnet.org>2025-09-24 06:59:18 +0000
committerLaurent Bercot <ska-skaware@skarnet.org>2025-09-24 06:59:18 +0000
commit04186b51dfcada174b5372aab0c7e423a4ed3244 (patch)
treed99d0b35c8c9c1af6b4e7826cd1d87e509895b9d /src/libs6rc/s6rc_repo_fix.c
parenta4756f00b3823952580d1fee704675c6f813a248 (diff)
downloads6-rc-04186b51dfcada174b5372aab0c7e423a4ed3244.tar.gz
More progress: updated sync, nominal fix
Diffstat (limited to 'src/libs6rc/s6rc_repo_fix.c')
-rw-r--r--src/libs6rc/s6rc_repo_fix.c51
1 files changed, 51 insertions, 0 deletions
diff --git a/src/libs6rc/s6rc_repo_fix.c b/src/libs6rc/s6rc_repo_fix.c
new file mode 100644
index 0000000..b379d30
--- /dev/null
+++ b/src/libs6rc/s6rc_repo_fix.c
@@ -0,0 +1,51 @@
+/* ISC license. */
+
+#include <string.h>
+#include <stdlib.h>
+#include <errno.h>
+
+#include <skalibs/posixplz.h>
+#include <skalibs/direntry.h>
+#include <skalibs/strerr.h>
+#include <skalibs/stralloc.h>
+#include <skalibs/genalloc.h>
+
+#include <s6-rc/repo.h>
+
+int s6rc_repo_fix (char const *repo, uint32_t options, unsigned int verbosity)
+{
+ stralloc sa = STRALLOC_ZERO ;
+ genalloc svlist = GENALLOC_ZERO ; /* s6rc_repo_sv */
+ genalloc badga = GENALLOC_ZERO ; /* uint32_t */
+ genalloc setind = GENALLOC_ZERO ; /* size_t */
+ int n ;
+
+ if (verbosity >= 3)
+ strerr_warni2x("checking set consistency in repository ", repo) ;
+
+ n = s6rc_repo_list_sets(repo, &sa, &setind) ;
+ if (n < 0)
+ {
+ strerr_warnfu1sys("list sets") ;
+ return 0 ;
+ }
+ for (uint32_t i = 0 ; i < nsets ; i++)
+ {
+ if (verbosity >= 3)
+ strerr_warni2x("checking set ", sa.s + genalloc_s(size_t, &setind)[i]) ;
+ if (!s6rc_repo_fixset(repo, sa.s + genalloc_s(size_t, &setind)[i], options, verbosity, &sa, &svlist, &badga)) goto err ;
+ }
+
+ genalloc_free(s6rc_repo_sv, &svlist) ;
+ genalloc_free(uint32_t, &badga) ;
+ genalloc_free(size_t, &setind) ;
+ stralloc_free(&sa) ;
+ return 1 ;
+
+ err:
+ genalloc_free(s6rc_repo_sv, &svlist) ;
+ genalloc_free(uint32_t, &badga) ;
+ genalloc_free(size_t, &setind) ;
+ stralloc_free(&sa) ;
+ return 0 ;
+}