aboutsummaryrefslogtreecommitdiffstats
path: root/sb-publish
diff options
context:
space:
mode:
Diffstat (limited to 'sb-publish')
-rwxr-xr-xsb-publish35
1 files changed, 35 insertions, 0 deletions
diff --git a/sb-publish b/sb-publish
new file mode 100755
index 0000000..9f53c5f
--- /dev/null
+++ b/sb-publish
@@ -0,0 +1,35 @@
+#!/bin/bash
+# Copyright (C) 2026 Danilo M. <danix@danix.xyz>
+#
+# This program is free software; you can redistribute it and/or modify it
+# under the terms of the GNU General Public License version 2 as published
+# by the Free Software Foundation. See the LICENSE file for details.
+
+# sb-publish: push the local package repository to the public mirror.
+#
+# Usage: sb-publish [PKGREPO] (default /repo)
+#
+# Called by rsync_push_hook in slackrepo_SBo-danix.conf after a build, unless
+# the build ran with SBB_PUBLISH=n; run it by hand (or from sb-builder's
+# Publish action) to push such builds later. Settings come from the root-only
+# SB_LOCAL file (default /etc/slackrepo/SBo-danix.local):
+# SB_RSYNC_TARGET rsync destination (required)
+# SB_RSYNC_PASSWORD_FILE --password-file, if the file exists
+# SB_RSYNC_EXCLUDES --exclude-from, if the file exists
+
+set -euo pipefail
+
+SB_LOCAL=${SB_LOCAL:-/etc/slackrepo/SBo-danix.local}
+[ -r "$SB_LOCAL" ] && . "$SB_LOCAL"
+: "${SB_RSYNC_TARGET:?SB_RSYNC_TARGET is not set in $SB_LOCAL}"
+
+pkgrepo=${1:-/repo}
+args=( -havz --delete-after --stats )
+[ -n "${SB_RSYNC_EXCLUDES:-}" ] && [ -f "$SB_RSYNC_EXCLUDES" ] && \
+ args+=( --exclude-from="$SB_RSYNC_EXCLUDES" )
+[ -n "${SB_RSYNC_PASSWORD_FILE:-}" ] && [ -f "$SB_RSYNC_PASSWORD_FILE" ] && \
+ args+=( --password-file="$SB_RSYNC_PASSWORD_FILE" )
+
+echo "sb-publish: pushing $pkgrepo to $SB_RSYNC_TARGET ..."
+rsync "${args[@]}" "$pkgrepo"/ "$SB_RSYNC_TARGET"
+echo "sb-publish: rsync push complete."