aboutsummaryrefslogtreecommitdiffstats
path: root/roles/host/templates/usr_local_bin_update_ports.sh.j2
diff options
context:
space:
mode:
authorJan Tuomi <jan@jantuomi.fi>2026-07-25 12:14:27 +0300
committerJan Tuomi <jan@jantuomi.fi>2026-07-25 12:14:27 +0300
commit6bf890f5bcafd9747509efe1122a6132a064a53e (patch)
treecb654270c56a0f882744b4cc6217e9addf41fd54 /roles/host/templates/usr_local_bin_update_ports.sh.j2
parentda9a729eaf6fac9b0cc532dcf0056ba76c7f677d (diff)
Set up poudriere custom repo
Diffstat (limited to 'roles/host/templates/usr_local_bin_update_ports.sh.j2')
-rw-r--r--roles/host/templates/usr_local_bin_update_ports.sh.j261
1 files changed, 61 insertions, 0 deletions
diff --git a/roles/host/templates/usr_local_bin_update_ports.sh.j2 b/roles/host/templates/usr_local_bin_update_ports.sh.j2
new file mode 100644
index 0000000..ad4102d
--- /dev/null
+++ b/roles/host/templates/usr_local_bin_update_ports.sh.j2
@@ -0,0 +1,61 @@
+#!/bin/sh
+set -e
+
+usage() {
+ echo "Usage: update-ports [quarterly|custom]"
+ exit 1
+}
+
+[ $# -eq 1 ] || usage
+
+BASEDIR=/usr/ports
+REMOTE_QUARTERLY="https://github.com/freebsd/freebsd-ports.git"
+REMOTE_CUSTOM="https://github.com/jantuomi/freebsd-ports-custom.git"
+
+case "$1" in
+quarterly)
+ # Find the newest quarterly branch
+ BRANCH=$(git ls-remote --heads "$REMOTE_QUARTERLY" | grep -oE 'refs/heads/[0-9]{4}Q[0-9]' | sort -t/ -k3 -V | tail -1 | sed 's|refs/heads/||')
+ if [ -z "$BRANCH" ]; then
+ echo "Error: Could not determine quarterly branch"
+ exit 1
+ fi
+
+ # Check if already at this version
+ VERSION_FILE="${BASEDIR}/quarterly/.version"
+ if [ -f "$VERSION_FILE" ] && [ "$(cat "$VERSION_FILE")" = "$BRANCH" ]; then
+ echo "Quarterly ports tree already at $BRANCH."
+ exit 0
+ fi
+
+ echo "Downloading quarterly ports tree (branch: $BRANCH)..."
+ TMPDIR="${BASEDIR}/.quarterly.new"
+ rm -rf "$TMPDIR"
+ mkdir -p "$TMPDIR"
+ fetch -qo- "https://github.com/freebsd/freebsd-ports/archive/refs/heads/${BRANCH}.tar.gz" | tar -xf - -C "$TMPDIR" --strip-components=1
+ echo "$BRANCH" > "$TMPDIR/.version"
+
+ if [ -d "${BASEDIR}/quarterly" ]; then
+ mv "${BASEDIR}/quarterly" "${BASEDIR}/.quarterly.old"
+ fi
+ mv "$TMPDIR" "${BASEDIR}/quarterly"
+ rm -rf "${BASEDIR}/.quarterly.old" &
+ echo "Done. Quarterly ports tree updated to $BRANCH."
+ ;;
+custom)
+ # Clone or update
+ if [ -d "${BASEDIR}/custom/.git" ]; then
+ echo "Updating custom ports overlay..."
+ git -C "${BASEDIR}/custom" fetch origin
+ git -C "${BASEDIR}/custom" reset --hard origin/main
+ else
+ echo "Cloning custom ports overlay..."
+ rm -rf "${BASEDIR}/custom"
+ git clone "$REMOTE_CUSTOM" "${BASEDIR}/custom"
+ fi
+ echo "Done. Custom ports overlay updated."
+ ;;
+*)
+ usage
+ ;;
+esac