From 5987230f99a2c8e62c793c200e3d9faaed9e37d9 Mon Sep 17 00:00:00 2001 From: Grant Labutis <46079274+glabutis@users.noreply.github.com> Date: Mon, 16 Mar 2026 18:55:10 -0400 Subject: [PATCH] fix: parse API JSON by package object to ensure version/URL stay in sync --- install/companion-install.sh | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/install/companion-install.sh b/install/companion-install.sh index 73099d08..1c9ddd31 100644 --- a/install/companion-install.sh +++ b/install/companion-install.sh @@ -18,13 +18,28 @@ $STD apt-get install -y \ curl \ sudo \ mc \ + python3 \ libusb-1.0-0 msg_ok "Installed Dependencies" msg_info "Fetching Latest Bitfocus Companion Release" RELEASE_JSON=$(curl -fsSL "https://api.bitfocus.io/v1/product/companion/packages?limit=20") -RELEASE=$(echo "$RELEASE_JSON" | grep -o '"version":"[^"]*","target":"linux-tgz"' | head -1 | awk -F'"' '{print $4}') -ASSET_URL=$(echo "$RELEASE_JSON" | grep -o '"uri":"[^"]*linux-x64[^"]*"' | head -1 | awk -F'"' '{print $4}') +RELEASE=$(echo "$RELEASE_JSON" | python3 -c " +import sys, json +data = json.load(sys.stdin) +for pkg in data.get('packages', data if isinstance(data, list) else []): + if pkg.get('target') == 'linux-tgz': + print(pkg.get('version', '')) + break +") +ASSET_URL=$(echo "$RELEASE_JSON" | python3 -c " +import sys, json +data = json.load(sys.stdin) +for pkg in data.get('packages', data if isinstance(data, list) else []): + if pkg.get('target') == 'linux-tgz': + print(pkg.get('uri', '')) + break +") if [[ -z "$ASSET_URL" ]]; then msg_error "Could not locate a Linux x64 release from the Bitfocus API."