aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/repo/deps-exe/s6-rc-repo-list3
-rw-r--r--src/repo/s6-rc-repo-init.c2
-rw-r--r--src/repo/s6-rc-repo-list.c74
-rw-r--r--src/repo/s6-rc-repo-sync.c2
-rw-r--r--src/repo/s6-rc-set-fix.c4
-rw-r--r--src/repo/s6rc_repo_fix.c51
6 files changed, 81 insertions, 55 deletions
diff --git a/src/repo/deps-exe/s6-rc-repo-list b/src/repo/deps-exe/s6-rc-repo-list
new file mode 100644
index 0000000..9fe69bb
--- /dev/null
+++ b/src/repo/deps-exe/s6-rc-repo-list
@@ -0,0 +1,3 @@
+${LIBS6RCREPO}
+-lskarnet
+${SPAWN_LIB}
diff --git a/src/repo/s6-rc-repo-init.c b/src/repo/s6-rc-repo-init.c
index 6c8a7fa..933ea67 100644
--- a/src/repo/s6-rc-repo-init.c
+++ b/src/repo/s6-rc-repo-init.c
@@ -22,7 +22,7 @@
#include <skalibs/unix-transactional.h>
#include <s6-rc/config.h>
-#include <s6-rc/s6rc.h>
+#include <s6-rc/repo.h>
#define USAGE "s6-rc-repo-init [ -v verbosity ] [ -r repo ] [ -h fdhuser ] [ -f ] [ -U ] [ -B ] stores..."
#define dieusage() strerr_dieusage(100, USAGE)
diff --git a/src/repo/s6-rc-repo-list.c b/src/repo/s6-rc-repo-list.c
new file mode 100644
index 0000000..15112d1
--- /dev/null
+++ b/src/repo/s6-rc-repo-list.c
@@ -0,0 +1,74 @@
+/* ISC license. */
+
+#include <unistd.h>
+#include <string.h>
+#include <errno.h>
+
+#include <skalibs/buffer.h>
+#include <skalibs/direntry.h>
+#include <skalibs/envexec.h>
+#include <skalibs/tai.h>
+
+#include <s6-rc/config.h>
+#include <s6-rc/repo.h>
+
+#define USAGE "s6-rc-repo-list [ -v verbosity ] [ -r repo ] [ -x exclude ]"
+#define dieusage() strerr_dieusage(100, USAGE)
+#define dieout() strerr_diefu1sys(111, "write to stdout")
+
+enum gola_e
+{
+ GOLA_VERBOSITY,
+ GOLA_REPODIR,
+ GOLA_EXCLUDE,
+ GOLA_N
+} ;
+
+static gol_arg const rgola[] =
+{
+ { .so = 'v', .lo = "verbosity", .i = GOLA_VERBOSITY },
+ { .so = 'r', .lo = "repodir", .i = GOLA_REPODIR },
+ { .so = 'x', .lo = "exclude", .i = GOLA_EXCLUDE }
+} ;
+
+int main (int argc, char const *const *argv)
+{
+ char const *wgola[GOLA_N] = { 0 } ;
+ unsigned int verbosity = 1 ;
+ unsigned int golc ;
+ int fdlock ;
+
+ PROG = "s6-rc-repo-list" ;
+ wgola[GOLA_REPODIR] = S6RC_REPODIR ;
+
+ golc = gol_main(argc, argv, 0, 0, rgola, 3, 0, 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") ;
+
+ tain_now_g() ;
+ fdlock = s6rc_repo_lock(wgola[GOLA_REPODIR], 1) ;
+ if (fdlock == -1) strerr_diefu2sys(111, "lock ", wgola[GOLA_REPODIR]) ;
+
+ size_t repolen = strlen(wgola[GOLA_REPODIR]) ;
+ char fn[repolen + 9] ;
+ memcpy(fn, wgola[GOLA_REPODIR], repolen) ;
+ memcpy(fn + repolen, "/sources", 9) ;
+ DIR *dir = opendir(fn) ;
+ if (!dir) strerr_diefu2sys(111, "opendir ", fn) ;
+ for (;;)
+ {
+ direntry *d ;
+ errno = 0 ;
+ d = readdir(dir) ;
+ if (!d) break ;
+ if (d->d_name[0] == '.') continue ;
+ if (wgola[GOLA_EXCLUDE] && !strcmp(d->d_name, wgola[GOLA_EXCLUDE])) continue ;
+ if (buffer_puts(buffer_1, d->d_name) < 0
+ || buffer_put(buffer_1, "\n", 1) < 0) dieout() ;
+ }
+ if (errno) strerr_diefu2sys(111, "readdir ", fn) ;
+ // dir_close(dir) ;
+ if (!buffer_flush(buffer_1)) dieout() ;
+ _exit(0) ;
+}
diff --git a/src/repo/s6-rc-repo-sync.c b/src/repo/s6-rc-repo-sync.c
index ba57d49..def9eb4 100644
--- a/src/repo/s6-rc-repo-sync.c
+++ b/src/repo/s6-rc-repo-sync.c
@@ -6,7 +6,7 @@
#include <skalibs/tai.h>
#include <s6-rc/config.h>
-#include <s6-rc/s6rc.h>
+#include <s6-rc/repo.h>
#define USAGE "s6-rc-repo-sync [ -v verbosity ] [ -r repo ] [ -h fdhuser ]"
#define dieusage() strerr_dieusage(100, USAGE)
diff --git a/src/repo/s6-rc-set-fix.c b/src/repo/s6-rc-set-fix.c
index 6205024..54e8c3c 100644
--- a/src/repo/s6-rc-set-fix.c
+++ b/src/repo/s6-rc-set-fix.c
@@ -58,8 +58,8 @@ int main (int argc, char const **argv)
{ .so = 'r', .lo = "repodir", .i = GOLA_REPODIR }
} ;
stralloc sa = STRALLOC_ZERO ;
- genalloc svlist = GENALLOC_ZERO ;
- genalloc badga = GENALLOC_ZERO ;
+ genalloc svlist = GENALLOC_ZERO ; /* s6rc_repo_sv */
+ genalloc badga = GENALLOC_ZERO ; /* uint32_t */
unsigned int verbosity = 1 ;
int fdlock ;
uint64_t wgolb = 0 ;
diff --git a/src/repo/s6rc_repo_fix.c b/src/repo/s6rc_repo_fix.c
deleted file mode 100644
index b379d30..0000000
--- a/src/repo/s6rc_repo_fix.c
+++ /dev/null
@@ -1,51 +0,0 @@
-/* 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 ;
-}