Add bin/setup to prepare a repository host

The sync guard could not read the repository database because bsdtar was not
installed on the host, and the first fix was to parse around its absence. The
better answer is for the host to have what the tooling needs: libarchive ships
the library pacman links against without necessarily installing the binary, so
bsdtar being present was an assumption, not a fact.

bin/setup installs the dependencies, enables Docker, creates the state
directory, and installs and enables the release timers -- the steps the README
previously listed by hand. It is idempotent and takes --check to report without
changing anything. Signing credentials and the rclone remote hold secrets, so
it reports on those rather than creating them.

sync-repo goes back to reading the database with bsdtar alone, and says to run
bin/setup when it is missing.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
David Heinemeier HanssonandClaude Opus 5 committed 2026-08-12 05:04:06 -07:00
1 parent dbe1db4b03
commit f8c1cbb072
4 files changed
+217 -23

No files matched your search

+12 -10
View File
@@ -142,23 +142,25 @@ if grep -qx 'omarchy\.db' <<<"$REMOTE_LISTING"; then
trap 'rm -f "$REMOTE_DB_FILE"' EXIT
rclone cat "$REMOTE/$DESTINATION_DIRECTORY/omarchy.db" --s3-no-head >"$REMOTE_DB_FILE" 2>/dev/null
# Download to a file rather than piping: GNU tar detects the compression from
# a seekable archive but not from a pipe, and the database has been both gzip
# and zstd over its life. bsdtar reads either too, but it is not present on
# every host, so tar leads and bsdtar covers a tar too old for zstd.
REMOTE_ENTRIES=$(tar -tf "$REMOTE_DB_FILE" 2>/dev/null)
if [[ -z "$REMOTE_ENTRIES" ]] && command -v bsdtar >/dev/null 2>&1; then
REMOTE_ENTRIES=$(bsdtar -tf "$REMOTE_DB_FILE" 2>/dev/null)
if ! command -v bsdtar >/dev/null 2>&1; then
print_error "bsdtar is not installed"
echo ""
echo "The repository host needs it to read the repository database."
echo "Run bin/setup to install everything this host requires."
exit 1
fi
REMOTE_NAMES=$(printf '%s\n' "$REMOTE_ENTRIES" | sed 's|/.*||' |
sed -E 's/-[^-]+-[^-]+$//' | sort -u | grep -v '^$')
# bsdtar, not tar: repo-add has used both gzip and zstd for the database, and
# libarchive detects either without being told which.
REMOTE_NAMES=$(bsdtar -tf "$REMOTE_DB_FILE" 2>/dev/null | sed 's|/.*||' |
sed -E 's/-[^-]+-[^-]+$//' | sort -u)
if [[ -z "$REMOTE_NAMES" ]]; then
print_error "The remote database exists but could not be read"
echo ""
echo "Refusing to sync rather than assume the remote is empty. Check that"
echo "omarchy.db is not corrupt: rclone cat $REMOTE/$DESTINATION_DIRECTORY/omarchy.db | tar -t"
echo "omarchy.db is not corrupt:"
echo " rclone cat $REMOTE/$DESTINATION_DIRECTORY/omarchy.db | bsdtar -tf -"
exit 1
fi