feat(installer): fetch latest SDRconnect/RigControl build hashes from upstream
Introduce dynamic resolution of git build hashes by fetching the upstream installer script and parsing the values, with fallbacks to built-in defaults and support for user overrides via environment variables. Add fetch_gitbuilds() to retrieve and parse hashes, and resolve_artifacts() to populate artifact filenames and URLs based on resolved hashes. Call these functions early in main() to ensure up-to-date artifacts before downloading. Skip upstream fetch if DONOTDOWNLOAD=1 is set.
This commit is contained in:
parent
681180b811
commit
b430c23506
@ -11,23 +11,30 @@ set -Eeuo pipefail
|
|||||||
# CONFIG
|
# CONFIG
|
||||||
#######################################
|
#######################################
|
||||||
|
|
||||||
SDRCONNECT_GITBUILD="a4b8da76b"
|
# Build hashes are resolved at runtime from the upstream installer
|
||||||
RIGCONTROL_GITBUILD="4a50e06"
|
# (https://www.sdrplay.com/software/install.sh). The values below are used
|
||||||
|
# as fallbacks if upstream is unreachable, and are also honoured as user
|
||||||
|
# overrides when set in the environment before invocation.
|
||||||
|
_SDRCONNECT_GITBUILD_USER_SET="${SDRCONNECT_GITBUILD+set}"
|
||||||
|
_RIGCONTROL_GITBUILD_USER_SET="${RIGCONTROL_GITBUILD+set}"
|
||||||
|
: "${SDRCONNECT_GITBUILD:=a4b8da76b}"
|
||||||
|
: "${RIGCONTROL_GITBUILD:=4a50e06}"
|
||||||
|
|
||||||
|
UPSTREAM_INSTALLER_URL="https://www.sdrplay.com/software/install.sh"
|
||||||
|
|
||||||
SDRCONNECT_DIR="/opt/sdrconnect"
|
SDRCONNECT_DIR="/opt/sdrconnect"
|
||||||
RIGCONTROL_DIR="/opt/rigcontrol"
|
RIGCONTROL_DIR="/opt/rigcontrol"
|
||||||
|
|
||||||
SDRCONNECT_TAR_X86_64="sdrconnect_linux-x64_${SDRCONNECT_GITBUILD}.tar.gz"
|
# Artifact filenames and URLs depend on the resolved build hashes and are
|
||||||
SDRCONNECT_TAR_ARM64="sdrconnect_linux-arm64_${SDRCONNECT_GITBUILD}.tar.gz"
|
# populated by resolve_artifacts() after fetch_gitbuilds() runs.
|
||||||
|
SDRCONNECT_TAR_X86_64=""
|
||||||
RIGCONTROL_TAR_X86_64="rigcontrol_linux-x64_${RIGCONTROL_GITBUILD}.tar.gz"
|
SDRCONNECT_TAR_ARM64=""
|
||||||
RIGCONTROL_TAR_ARM64="rigcontrol_linux-arm64_${RIGCONTROL_GITBUILD}.tar.gz"
|
RIGCONTROL_TAR_X86_64=""
|
||||||
|
RIGCONTROL_TAR_ARM64=""
|
||||||
SDRCONNECT_URL_X86_64="https://www.sdrplay.com/software/${SDRCONNECT_TAR_X86_64}"
|
SDRCONNECT_URL_X86_64=""
|
||||||
SDRCONNECT_URL_ARM64="https://www.sdrplay.com/software/${SDRCONNECT_TAR_ARM64}"
|
SDRCONNECT_URL_ARM64=""
|
||||||
|
RIGCONTROL_URL_X86_64=""
|
||||||
RIGCONTROL_URL_X86_64="https://www.sdrplay.com/software/${RIGCONTROL_TAR_X86_64}"
|
RIGCONTROL_URL_ARM64=""
|
||||||
RIGCONTROL_URL_ARM64="https://www.sdrplay.com/software/${RIGCONTROL_TAR_ARM64}"
|
|
||||||
|
|
||||||
PROFILE_SCRIPT="/etc/profile.d/sdrconnect.sh"
|
PROFILE_SCRIPT="/etc/profile.d/sdrconnect.sh"
|
||||||
UDEV_RULES="/etc/udev/rules.d/66-sdrplay.rules"
|
UDEV_RULES="/etc/udev/rules.d/66-sdrplay.rules"
|
||||||
@ -312,6 +319,60 @@ show_license() {
|
|||||||
esac
|
esac
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#######################################
|
||||||
|
# VERSION RESOLUTION
|
||||||
|
#######################################
|
||||||
|
fetch_gitbuilds(){
|
||||||
|
if [[ "${DONOTDOWNLOAD:-0}" == "1" ]]; then
|
||||||
|
info "DONOTDOWNLOAD=1: skipping upstream version lookup"
|
||||||
|
return
|
||||||
|
fi
|
||||||
|
if [[ "$DRY_RUN" -eq 1 ]]; then
|
||||||
|
info "[DRY-RUN] would fetch $UPSTREAM_INSTALLER_URL for current build hashes"
|
||||||
|
return
|
||||||
|
fi
|
||||||
|
|
||||||
|
info "Fetching current build hashes from upstream..."
|
||||||
|
local upstream
|
||||||
|
if ! upstream=$(curl -fsSL --retry 2 "$UPSTREAM_INSTALLER_URL" 2>/dev/null); then
|
||||||
|
warn "Could not fetch $UPSTREAM_INSTALLER_URL; using built-in fallback hashes"
|
||||||
|
return
|
||||||
|
fi
|
||||||
|
|
||||||
|
local up_sdrc up_rig
|
||||||
|
up_sdrc=$(grep -E '^SDRCONNECT_GITBUILD=' <<<"$upstream" | head -1 | cut -d'"' -f2)
|
||||||
|
up_rig=$(grep -E '^RIGCONTROL_GITBUILD=' <<<"$upstream" | head -1 | cut -d'"' -f2)
|
||||||
|
|
||||||
|
if [[ "$_SDRCONNECT_GITBUILD_USER_SET" == "set" ]]; then
|
||||||
|
info "Honouring SDRCONNECT_GITBUILD override: $SDRCONNECT_GITBUILD"
|
||||||
|
elif [[ -n "$up_sdrc" ]]; then
|
||||||
|
SDRCONNECT_GITBUILD="$up_sdrc"
|
||||||
|
else
|
||||||
|
warn "Could not parse SDRCONNECT_GITBUILD from upstream; using fallback $SDRCONNECT_GITBUILD"
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [[ "$_RIGCONTROL_GITBUILD_USER_SET" == "set" ]]; then
|
||||||
|
info "Honouring RIGCONTROL_GITBUILD override: $RIGCONTROL_GITBUILD"
|
||||||
|
elif [[ -n "$up_rig" ]]; then
|
||||||
|
RIGCONTROL_GITBUILD="$up_rig"
|
||||||
|
else
|
||||||
|
warn "Could not parse RIGCONTROL_GITBUILD from upstream; using fallback $RIGCONTROL_GITBUILD"
|
||||||
|
fi
|
||||||
|
|
||||||
|
info "Resolved SDRconnect=$SDRCONNECT_GITBUILD, RigControl=$RIGCONTROL_GITBUILD"
|
||||||
|
}
|
||||||
|
|
||||||
|
resolve_artifacts(){
|
||||||
|
SDRCONNECT_TAR_X86_64="sdrconnect_linux-x64_${SDRCONNECT_GITBUILD}.tar.gz"
|
||||||
|
SDRCONNECT_TAR_ARM64="sdrconnect_linux-arm64_${SDRCONNECT_GITBUILD}.tar.gz"
|
||||||
|
RIGCONTROL_TAR_X86_64="rigcontrol_linux-x64_${RIGCONTROL_GITBUILD}.tar.gz"
|
||||||
|
RIGCONTROL_TAR_ARM64="rigcontrol_linux-arm64_${RIGCONTROL_GITBUILD}.tar.gz"
|
||||||
|
SDRCONNECT_URL_X86_64="https://www.sdrplay.com/software/${SDRCONNECT_TAR_X86_64}"
|
||||||
|
SDRCONNECT_URL_ARM64="https://www.sdrplay.com/software/${SDRCONNECT_TAR_ARM64}"
|
||||||
|
RIGCONTROL_URL_X86_64="https://www.sdrplay.com/software/${RIGCONTROL_TAR_X86_64}"
|
||||||
|
RIGCONTROL_URL_ARM64="https://www.sdrplay.com/software/${RIGCONTROL_TAR_ARM64}"
|
||||||
|
}
|
||||||
|
|
||||||
#######################################
|
#######################################
|
||||||
# DOWNLOAD
|
# DOWNLOAD
|
||||||
#######################################
|
#######################################
|
||||||
@ -576,6 +637,9 @@ main(){
|
|||||||
check_dependencies
|
check_dependencies
|
||||||
ensure_sudo
|
ensure_sudo
|
||||||
|
|
||||||
|
fetch_gitbuilds
|
||||||
|
resolve_artifacts
|
||||||
|
|
||||||
[[ "$ARCH" == "x86_64" ]] && {
|
[[ "$ARCH" == "x86_64" ]] && {
|
||||||
U1="$SDRCONNECT_URL_X86_64"; U2="$RIGCONTROL_URL_X86_64"
|
U1="$SDRCONNECT_URL_X86_64"; U2="$RIGCONTROL_URL_X86_64"
|
||||||
F1="$SDRCONNECT_TAR_X86_64"; F2="$RIGCONTROL_TAR_X86_64"
|
F1="$SDRCONNECT_TAR_X86_64"; F2="$RIGCONTROL_TAR_X86_64"
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user