opn
This commit is contained in:
1 parent
e2398a4379
commit
92aa0b676d
9 files changed
+425
-310
No files matched your search
+51
-26
@@ -2,24 +2,37 @@
|
||||
set -Eeuo pipefail
|
||||
source /opt/rust-package-builder/scripts/lib.sh
|
||||
|
||||
STATE_FILE="$DATA_DIR/state/last_commit"
|
||||
REPOSITORY="$DATA_DIR/repository"
|
||||
CURRENT="$REPOSITORY/current"
|
||||
|
||||
published_release_complete_for_commit() {
|
||||
linux_release_complete_for_commit() {
|
||||
local sha=$1
|
||||
local current="$REPOSITORY/current"
|
||||
local opnsense="$current/opnsense"
|
||||
[[ -d "$CURRENT" ]] || return 1
|
||||
[[ -f "$CURRENT/apt/dists/$REPO_DISTRIBUTION/InRelease" ]] || return 1
|
||||
[[ -f "$CURRENT/rpm/x86_64/repodata/repomd.xml" ]] || return 1
|
||||
|
||||
if [[ -f "$CURRENT/LINUX-BUILD-INFO.txt" ]] && grep -Fqx "source_commit=$sha" "$CURRENT/LINUX-BUILD-INFO.txt"; then
|
||||
return 0
|
||||
fi
|
||||
|
||||
local state_sha=""
|
||||
[[ -r "$DATA_DIR/state/last_linux_commit" ]] && state_sha=$(cat "$DATA_DIR/state/last_linux_commit")
|
||||
[[ "$state_sha" == "$sha" ]] && return 0
|
||||
|
||||
# Migration from the older unified/Linux-only builder. Its last_commit
|
||||
# represented the Linux publication before per-branch state existed.
|
||||
local legacy_sha=""
|
||||
[[ -r "$DATA_DIR/state/last_commit" ]] && legacy_sha=$(cat "$DATA_DIR/state/last_commit")
|
||||
[[ "$legacy_sha" == "$sha" ]] || return 1
|
||||
return 0
|
||||
}
|
||||
|
||||
opnsense_release_complete_for_commit() {
|
||||
local sha=$1
|
||||
local opnsense="$CURRENT/opnsense"
|
||||
local package_dir="$opnsense/$OPNSENSE_ABI/amd64"
|
||||
|
||||
[[ -d "$current" ]] || return 1
|
||||
|
||||
# Linux side of the atomic release.
|
||||
[[ -f "$current/apt/dists/$REPO_DISTRIBUTION/InRelease" ]] || return 1
|
||||
[[ -f "$current/rpm/x86_64/repodata/repomd.xml" ]] || return 1
|
||||
|
||||
# OPNsense side. BUILD-INFO ties the published pkg repository to the same
|
||||
# source commit so an old Linux-only release cannot be mistaken for a
|
||||
# complete unified release after migration.
|
||||
[[ -d "$CURRENT" ]] || return 1
|
||||
[[ -f "$opnsense/meta.conf" ]] || return 1
|
||||
[[ -f "$opnsense/packagesite.pkg" ]] || return 1
|
||||
[[ -f "$opnsense/data.pkg" ]] || return 1
|
||||
@@ -30,7 +43,6 @@ published_release_complete_for_commit() {
|
||||
grep -Fqx "opnsense_series=$OPNSENSE_ABI" "$opnsense/BUILD-INFO.txt" || return 1
|
||||
[[ -d "$package_dir" ]] || return 1
|
||||
find "$package_dir" -maxdepth 1 -type f -name 'os-rustproxy-*.pkg' -print -quit | grep -q . || return 1
|
||||
|
||||
return 0
|
||||
}
|
||||
|
||||
@@ -38,19 +50,32 @@ log "checking repository"
|
||||
REMOTE_SHA=$(git ls-remote "$SOURCE_REPO" "refs/heads/$SOURCE_BRANCH" | awk 'NR == 1 {print $1}')
|
||||
[[ "$REMOTE_SHA" =~ ^[0-9a-fA-F]{40}$ ]] || fatal "cannot resolve branch $SOURCE_BRANCH from $SOURCE_REPO"
|
||||
|
||||
LAST_SHA=""
|
||||
[[ -r "$STATE_FILE" ]] && LAST_SHA=$(cat "$STATE_FILE")
|
||||
BUILD_LINUX=1
|
||||
BUILD_OPNSENSE=1
|
||||
if linux_release_complete_for_commit "$REMOTE_SHA"; then
|
||||
BUILD_LINUX=0
|
||||
# Persist migrated per-branch state when an older installation already has
|
||||
# a valid Linux repository for this exact commit.
|
||||
printf '%s\n' "$REMOTE_SHA" | atomic_write "$DATA_DIR/state/last_linux_commit"
|
||||
fi
|
||||
if opnsense_release_complete_for_commit "$REMOTE_SHA"; then
|
||||
BUILD_OPNSENSE=0
|
||||
printf '%s\n' "$REMOTE_SHA" | atomic_write "$DATA_DIR/state/last_opnsense_commit"
|
||||
fi
|
||||
|
||||
if [[ "$REMOTE_SHA" == "$LAST_SHA" ]]; then
|
||||
if published_release_complete_for_commit "$REMOTE_SHA"; then
|
||||
log "no changes and unified release is complete: $REMOTE_SHA"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
log "commit unchanged, but unified release is incomplete; rebuilding missing artifacts for $REMOTE_SHA"
|
||||
/opt/rust-package-builder/scripts/build-release.sh "$REMOTE_SHA" repair-missing-artifacts
|
||||
if [[ "$BUILD_LINUX" == "0" && "$BUILD_OPNSENSE" == "0" ]]; then
|
||||
printf '%s\n' "$REMOTE_SHA" | atomic_write "$DATA_DIR/state/last_commit"
|
||||
log "no changes: Linux and OPNsense are complete for $REMOTE_SHA"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
log "new commit detected: $REMOTE_SHA"
|
||||
/opt/rust-package-builder/scripts/build-release.sh "$REMOTE_SHA" new-commit
|
||||
if [[ "$BUILD_LINUX" == "1" && "$BUILD_OPNSENSE" == "1" ]]; then
|
||||
REASON="new-or-missing-both"
|
||||
elif [[ "$BUILD_LINUX" == "1" ]]; then
|
||||
REASON="repair-linux"
|
||||
else
|
||||
REASON="repair-opnsense"
|
||||
fi
|
||||
|
||||
log "build required: commit=$REMOTE_SHA linux=$BUILD_LINUX opnsense=$BUILD_OPNSENSE reason=$REASON"
|
||||
/opt/rust-package-builder/scripts/build-release.sh "$REMOTE_SHA" "$REASON" "$BUILD_LINUX" "$BUILD_OPNSENSE"
|
||||
Reference in new issue
Block a user