feat(installer): fetch licence text from upstream
Update the installer to resolve licence text at runtime from the upstream installer, similar to build hashes. Add fallback handling with warnings if upstream is unreachable or unparseable. Rename fetch_gitbuilds to fetch_upstream to reflect expanded scope.
This commit is contained in:
parent
c9518643ca
commit
fb1c961655
@ -11,10 +11,11 @@ set -Eeuo pipefail
|
|||||||
# CONFIG
|
# CONFIG
|
||||||
#######################################
|
#######################################
|
||||||
|
|
||||||
# Build hashes are resolved at runtime from the upstream installer
|
# Build hashes and the licence text are resolved at runtime from the upstream
|
||||||
# (https://www.sdrplay.com/software/install.sh). The values below are used
|
# installer (https://www.sdrplay.com/software/install.sh). The values below
|
||||||
# as fallbacks if upstream is unreachable, and are also honoured as user
|
# are used as fallbacks if upstream is unreachable or unparseable, and the
|
||||||
# overrides when set in the environment before invocation.
|
# build hashes are also honoured as user overrides when set in the
|
||||||
|
# environment before invocation.
|
||||||
_SDRCONNECT_GITBUILD_USER_SET="${SDRCONNECT_GITBUILD+set}"
|
_SDRCONNECT_GITBUILD_USER_SET="${SDRCONNECT_GITBUILD+set}"
|
||||||
_RIGCONTROL_GITBUILD_USER_SET="${RIGCONTROL_GITBUILD+set}"
|
_RIGCONTROL_GITBUILD_USER_SET="${RIGCONTROL_GITBUILD+set}"
|
||||||
: "${SDRCONNECT_GITBUILD:=a4b8da76b}"
|
: "${SDRCONNECT_GITBUILD:=a4b8da76b}"
|
||||||
@ -136,6 +137,18 @@ info(){ echo -e "${GREEN}[INFO]${NC} $*"; }
|
|||||||
warn(){ echo -e "${YELLOW}[WARN]${NC} $*"; }
|
warn(){ echo -e "${YELLOW}[WARN]${NC} $*"; }
|
||||||
error(){ echo -e "${RED}[ERROR]${NC} $*" >&2; }
|
error(){ echo -e "${RED}[ERROR]${NC} $*" >&2; }
|
||||||
|
|
||||||
|
warn_license_fallback(){
|
||||||
|
local reason="$1"
|
||||||
|
echo
|
||||||
|
echo -e "${YELLOW}========================================================================${NC}"
|
||||||
|
echo -e "${YELLOW} WARNING: ${reason}${NC}"
|
||||||
|
echo -e "${YELLOW} Falling back to the licence text embedded in this installer.${NC}"
|
||||||
|
echo -e "${YELLOW} This may differ from the current upstream licence at:${NC}"
|
||||||
|
echo -e "${YELLOW} ${UPSTREAM_INSTALLER_URL}${NC}"
|
||||||
|
echo -e "${YELLOW}========================================================================${NC}"
|
||||||
|
echo
|
||||||
|
}
|
||||||
|
|
||||||
#######################################
|
#######################################
|
||||||
# ARGS
|
# ARGS
|
||||||
#######################################
|
#######################################
|
||||||
@ -328,28 +341,30 @@ show_license() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#######################################
|
#######################################
|
||||||
# VERSION RESOLUTION
|
# UPSTREAM RESOLUTION
|
||||||
#######################################
|
#######################################
|
||||||
fetch_gitbuilds(){
|
fetch_upstream(){
|
||||||
if [[ "${DONOTDOWNLOAD:-0}" == "1" ]]; then
|
if [[ "${DONOTDOWNLOAD:-0}" == "1" ]]; then
|
||||||
info "DONOTDOWNLOAD=1: skipping upstream version lookup"
|
info "DONOTDOWNLOAD=1: skipping upstream lookup"
|
||||||
return
|
return
|
||||||
fi
|
fi
|
||||||
if [[ "$DRY_RUN" -eq 1 ]]; then
|
if [[ "$DRY_RUN" -eq 1 ]]; then
|
||||||
info "[DRY-RUN] would fetch $UPSTREAM_INSTALLER_URL for current build hashes"
|
info "[DRY-RUN] would fetch $UPSTREAM_INSTALLER_URL for current build hashes and licence"
|
||||||
return
|
return
|
||||||
fi
|
fi
|
||||||
|
|
||||||
info "Fetching current build hashes from upstream..."
|
info "Fetching current build hashes and licence from upstream..."
|
||||||
local upstream
|
local upstream
|
||||||
if ! upstream=$(curl -fsSL --retry 2 "$UPSTREAM_INSTALLER_URL" 2>/dev/null); then
|
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"
|
warn "Could not fetch $UPSTREAM_INSTALLER_URL; using built-in fallback hashes"
|
||||||
|
warn_license_fallback "Could not fetch $UPSTREAM_INSTALLER_URL"
|
||||||
return
|
return
|
||||||
fi
|
fi
|
||||||
|
|
||||||
local up_sdrc up_rig
|
local up_sdrc up_rig up_license
|
||||||
up_sdrc=$(grep -E '^SDRCONNECT_GITBUILD=' <<<"$upstream" | head -1 | cut -d'"' -f2)
|
up_sdrc=$(grep -E '^SDRCONNECT_GITBUILD=' <<<"$upstream" | head -1 | cut -d'"' -f2)
|
||||||
up_rig=$(grep -E '^RIGCONTROL_GITBUILD=' <<<"$upstream" | head -1 | cut -d'"' -f2)
|
up_rig=$(grep -E '^RIGCONTROL_GITBUILD=' <<<"$upstream" | head -1 | cut -d'"' -f2)
|
||||||
|
up_license=$(awk '/^LICENSE_TEXT=\$\(cat/{flag=1; next} flag && /^EOF$/{flag=0; exit} flag' <<<"$upstream")
|
||||||
|
|
||||||
if [[ "$_SDRCONNECT_GITBUILD_USER_SET" == "set" ]]; then
|
if [[ "$_SDRCONNECT_GITBUILD_USER_SET" == "set" ]]; then
|
||||||
info "Honouring SDRCONNECT_GITBUILD override: $SDRCONNECT_GITBUILD"
|
info "Honouring SDRCONNECT_GITBUILD override: $SDRCONNECT_GITBUILD"
|
||||||
@ -367,6 +382,15 @@ fetch_gitbuilds(){
|
|||||||
warn "Could not parse RIGCONTROL_GITBUILD from upstream; using fallback $RIGCONTROL_GITBUILD"
|
warn "Could not parse RIGCONTROL_GITBUILD from upstream; using fallback $RIGCONTROL_GITBUILD"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
if [[ -n "$up_license" ]] \
|
||||||
|
&& [[ ${#up_license} -gt 500 ]] \
|
||||||
|
&& grep -q "SDRPLAY LIMITED" <<<"$up_license"; then
|
||||||
|
LICENSE_TEXT="$up_license"
|
||||||
|
info "Licence text refreshed from upstream"
|
||||||
|
else
|
||||||
|
warn_license_fallback "Could not extract licence text from upstream"
|
||||||
|
fi
|
||||||
|
|
||||||
info "Resolved SDRconnect=$SDRCONNECT_GITBUILD, RigControl=$RIGCONTROL_GITBUILD"
|
info "Resolved SDRconnect=$SDRCONNECT_GITBUILD, RigControl=$RIGCONTROL_GITBUILD"
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -641,13 +665,14 @@ refresh(){
|
|||||||
main(){
|
main(){
|
||||||
check_platform
|
check_platform
|
||||||
setup_sudo
|
setup_sudo
|
||||||
|
|
||||||
|
fetch_upstream
|
||||||
|
resolve_artifacts
|
||||||
|
|
||||||
show_license
|
show_license
|
||||||
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