Skip to content

Commit 18fd310

Browse files
classabbyampthe-maldridge
authored andcommitted
services/nomad/build/build-rsyncd: reorganise sync architecture
now packages get synced to an incoming directory. a script runs after each rsync to move and register the packages into the repo
1 parent 1219028 commit 18fd310

3 files changed

Lines changed: 97 additions & 26 deletions

File tree

services/nomad/build/build-rsyncd.nomad

Lines changed: 49 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,18 @@ job "build-rsyncd" {
1919
read_only = false
2020
}
2121

22+
volume "root_mirror" {
23+
type = "host"
24+
source = "root_mirror"
25+
read_only = false
26+
}
27+
28+
volume "incoming_pkgs" {
29+
type = "host"
30+
source = "incoming_pkgs"
31+
read_only = false
32+
}
33+
2234
service {
2335
provider = "nomad"
2436
name = "build-rsyncd"
@@ -29,8 +41,7 @@ job "build-rsyncd" {
2941
driver = "docker"
3042

3143
config {
32-
image = "ghcr.io/void-linux/infra-rsync:20240709R1"
33-
volumes = [ "local/buildsync.conf:/etc/rsyncd.conf.d/buildsync.conf" ]
44+
image = "ghcr.io/void-linux/infra-rsync:20251102R1"
3445
}
3546

3647
resources {
@@ -43,17 +54,26 @@ job "build-rsyncd" {
4354
destination = "/hostdir"
4455
}
4556

57+
volume_mount {
58+
volume = "root_mirror"
59+
destination = "/mirror"
60+
}
61+
62+
volume_mount {
63+
volume = "incoming_pkgs"
64+
destination = "/incoming"
65+
}
66+
4667
template {
47-
data = file("xbps-clean-sigs")
48-
destination = "local/xbps-clean-sigs"
68+
data = file("rsync-post-xfer")
69+
destination = "local/rsync-post-xfer"
4970
perms = "0755"
5071
}
5172

5273
template {
5374
data = <<EOF
5475
{{- with nomadVar "nomad/jobs/buildsync" }}
55-
buildsync-aarch64:{{ .aarch64_password }}
56-
buildsync-musl:{{ .musl_password }}
76+
buildsync:{{ .password }}
5777
{{- end }}
5878
EOF
5979
destination = "secrets/buildsync.secrets"
@@ -75,21 +95,30 @@ incoming chmod = D0755,F0644
7595
[sources]
7696
path = /hostdir/sources
7797
filter = - by_sha256/ - .* - *.part
78-
auth users = buildsync-*:rw
79-
80-
[aarch64]
81-
path = /hostdir/binpkgs/aarch64
82-
auth users = buildsync-aarch64:rw
83-
filter = + */ + *-repodata + otime + *.xbps - *.sig - *.sig2 - *-repodata.* - *-stagedata.* - *.x86_64* - x86_64*-repodata - .*
84-
post-xfer exec = /local/xbps-clean-sigs
85-
86-
[musl]
87-
path = /hostdir/binpkgs/musl
88-
auth users = buildsync-musl:rw
89-
filter = + */ + *-repodata + otime + *.xbps - *.sig - *.sig2 - *-repodata.* - *-stagedata.* - .*
90-
post-xfer exec = /local/xbps-clean-sigs
98+
auth users = buildsync:rw
99+
100+
&merge /local/rsyncd.conf.d
101+
EOF
102+
destination = "local/rsyncd.conf.d/buildsync.conf"
103+
}
104+
105+
dynamic "template" {
106+
for_each = [
107+
"x86_64", "i686", "armv7l", "armv6l",
108+
"x86_64-musl", "armv7l-musl", "armv6l-musl",
109+
"aarch64", "aarch64-musl",
110+
]
111+
112+
content {
113+
data = <<EOF
114+
[incoming-${template.value}]
115+
path = /incoming/${template.value}
116+
auth users = buildsync:rw
117+
filter = + */ + *.${template.value}.xbps - *.sig - *.sig2 - *-repodata* - .*
118+
post-xfer exec = /local/rsync-post-xfer
91119
EOF
92-
destination = "local/buildsync.conf"
120+
destination = "local/rsyncd.conf.d/${template.value}.conf.inc"
121+
}
93122
}
94123
}
95124
}
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
#!/bin/sh
2+
3+
set -e
4+
5+
TGT_BASE="/mirror/current"
6+
7+
process_repo() {
8+
repo="$1"
9+
if [ ! -d "$RSYNC_MODULE_PATH/$repo" ] || [ ! -d "$TGT_BASE/$TGT/$repo" ]; then
10+
return
11+
fi
12+
# add to repodata
13+
find "$RSYNC_MODULE_PATH"/"$repo" -maxdepth 1 -type f -printf "$TGT_BASE/$TGT/$repo/%f\0" | \
14+
xargs -r0 xbps-rindex -a
15+
# clean old packages from repodata
16+
xbps-rindex -c "$TGT_BASE/$TGT/$repo"
17+
# remove old packages
18+
xbps-rindex -r "$TGT_BASE/$TGT/$repo"
19+
# Remove signatures that don't have a corresponding package
20+
find "$TGT_BASE/$TGT/$repo" -maxdepth 1 \( -name '*.xbps.sig' -o -name '*.xbps.sig2' \) \
21+
-exec sh -c 'for x in "$@"; do [ -e "${x%.sig*}" ] || rm -- $x; done' _ {} +
22+
}
23+
24+
export XBPS_TARGET_ARCH="${RSYNC_MODULE_NAME#*-}"
25+
26+
case "$XBPS_TARGET_ARCH" in
27+
aarch64*) TGT="aarch64" ;;
28+
*-musl) TGT="musl" ;;
29+
*) TGT="" ;;
30+
esac
31+
32+
# copy files to repo
33+
rsync -va "${RSYNC_MODULE_PATH:?}"/ "$TGT_BASE/$TGT/"
34+
35+
for repo in / /bootstrap /debug /nonfree; do
36+
process_repo "$repo"
37+
done
38+
39+
if [ "$XBPS_TARGET_ARCH" = 'i686' ]; then
40+
for repo in /multilib /multilib/bootstrap /multilib/nonfree; do
41+
process_repo "$repo"
42+
done
43+
fi
44+
45+
# clean up incoming
46+
rm -r "${RSYNC_MODULE_PATH:?}"/*
47+
48+
exit 0

services/nomad/build/xbps-clean-sigs

Lines changed: 0 additions & 6 deletions
This file was deleted.

0 commit comments

Comments
 (0)