From 9cd074cb9bdac3f6d6d9a6294f42083cd957f896 Mon Sep 17 00:00:00 2001 From: Alex Clarke Date: Tue, 30 Jun 2026 14:54:59 -0600 Subject: [PATCH] build: fixed coyote install scripts --- scripts/install_coyote.ps1 | 6 +++--- scripts/install_coyote.sh | 35 +++++++++++++---------------------- 2 files changed, 16 insertions(+), 25 deletions(-) mode change 100644 => 100755 scripts/install_coyote.sh diff --git a/scripts/install_coyote.ps1 b/scripts/install_coyote.ps1 index 0c81e27..e342667 100644 --- a/scripts/install_coyote.ps1 +++ b/scripts/install_coyote.ps1 @@ -39,7 +39,7 @@ switch ([System.Runtime.InteropServices.RuntimeInformation]::OSArchitecture) { if (-not $BinDir) { if ($isWin) { $BinDir = Join-Path $env:LOCALAPPDATA 'coyote\bin' } - else { $home = $env:HOME; if (-not $home) { $home = (Get-Item -Path ~).FullName }; $BinDir = Join-Path $home '.local/bin' } + else { $userHome = $env:HOME; if (-not $userHome) { $userHome = (Get-Item -Path ~).FullName }; $BinDir = Join-Path $userHome '.local/bin' } } New-Item -ItemType Directory -Force -Path $BinDir | Out-Null @@ -95,13 +95,13 @@ if ($asset.name -match '\.zip$') { [System.IO.Compression.ZipFile]::ExtractToDirectory($archive, $extractDir) } elseif ($asset.name -match '\.tar\.gz$' -or $asset.name -match '\.tgz$') { $tar = Get-Command tar -ErrorAction SilentlyContinue - if ($tar) { & $tar.FullName -xzf $archive -C $extractDir } + if ($tar) { & $tar.Source -xzf $archive -C $extractDir } else { Fail "Asset is tar archive but 'tar' is not available." } } else { try { Add-Type -AssemblyName System.IO.Compression.FileSystem; [System.IO.Compression.ZipFile]::ExtractToDirectory($archive, $extractDir) } catch { $tar = Get-Command tar -ErrorAction SilentlyContinue - if ($tar) { & $tar.FullName -xf $archive -C $extractDir } else { Fail "Unknown archive format; neither zip nor tar workable." } + if ($tar) { & $tar.Source -xf $archive -C $extractDir } else { Fail "Unknown archive format; neither zip nor tar workable." } } } diff --git a/scripts/install_coyote.sh b/scripts/install_coyote.sh old mode 100644 new mode 100755 index d97e630..7d72a8c --- a/scripts/install_coyote.sh +++ b/scripts/install_coyote.sh @@ -133,30 +133,21 @@ else echo "Error: unsupported OS for this installer: $OS" >&2; exit 1 fi +DL_URLS=$(grep -oE '"browser_download_url":[[:space:]]*"[^"]+"' "$JSON" \ + | sed -E 's/.*"browser_download_url":[[:space:]]*"//; s/"$//' \ + || true) + ASSET_NAME=""; ASSET_URL="" for candidate in "${ASSET_CANDIDATES[@]}"; do - NAME=$(grep -oE '"name":\s*"[^"]+"' "$JSON" | sed 's/"name":\s*"//; s/"$//' | grep -Fx "$candidate" || true) - if [[ -n "$NAME" ]]; then - ASSET_NAME="$NAME" - ASSET_URL=$(awk -v pat="$NAME" ' - BEGIN{ FS=":"; want=0 } - /"name"/ { - line=$0; - gsub(/^\s+|\s+$/,"",line); - gsub(/"name"\s*:\s*"|"/ ,"", line); - want = (line==pat) ? 1 : 0; - next - } - want==1 && /"browser_download_url"/ { - u=$0; - gsub(/^\s+|\s+$/,"",u); - gsub(/.*"browser_download_url"\s*:\s*"|".*/ ,"", u); - print u; - exit - } - ' "$JSON") - if [[ -n "$ASSET_URL" ]]; then break; fi - fi + while IFS= read -r url; do + [[ -z "$url" ]] && continue + if [[ "$url" == */"$candidate" ]]; then + ASSET_NAME="$candidate" + ASSET_URL="$url" + break + fi + done <<< "$DL_URLS" + [[ -n "$ASSET_URL" ]] && break done if [[ -z "$ASSET_URL" ]]; then