this repo has no description

updated script

altagos.dev 113eaa05 06c9423c

verified
Changed files
+29 -45
zig
+29 -45
zig/download.sh
··· 2 set -e 3 4 [ -z "$ZIG_VERSION" ] && ZIG_VERSION="master" 5 - command -v jq >/dev/null || { echo "Error: jq is required to parse Zig's download manifest"; exit 1; } 6 - command -v minisign >/dev/null || { echo "Error: minisign is required to verify Zig's signature"; exit 1; } 7 - mkdir -p zig 8 9 case "$(uname -s)" in 10 Linux) ··· 13 aarch64) p="aarch64-linux" ;; 14 armv7l) p="arm-linux" ;; 15 i686) p="x86-linux" ;; 16 - *) echo "Error: Unsupported architecture $(uname -m)"; exit 1 ;; 17 esac 18 ;; 19 Darwin) 20 case "$(uname -m)" in 21 x86_64) p="x86_64-macos" ;; 22 arm64) p="aarch64-macos" ;; 23 - *) echo "Error: Unsupported architecture $(uname -m)"; exit 1 ;; 24 esac 25 ;; 26 - *) echo "Error: Unsupported OS $(uname -s)"; exit 1 ;; 27 esac 28 29 u=$(curl -s https://ziglang.org/download/index.json | jq -r ".\"$ZIG_VERSION\".\"$p\".tarball") 30 - [ -z "$u" ] && { echo "Error: Could not find download URL for version $ZIG_VERSION on $p"; exit 1; } 31 32 f=$(basename "$u") 33 - echo "Downloading $u to zig/$f..." 34 - curl -L "$u" -o "zig/$f" || { echo "Error: Failed to download Zig compiler"; exit 1; } 35 - curl -L "$u.minisig" -o "zig/$f.minisig" || { echo "Error: Failed to download minisig signature"; exit 1; } 36 - echo "RWSGOq2NVecA2UPNdBUZykf1CCb147pkmdtYxgb3Ti+JO/wCYvhbAb/U" > zig/zig.pub 37 - echo "Verifying signature..." 38 - minisign -Vm "zig/$f" -P zig/zig.pub || { echo "Error: Signature verification failed - this is critical for security"; exit 1; } 39 40 - # Create temporary extraction directory 41 - mkdir -p zig/extract 42 - 43 - # Extract to temporary location with --no-same-owner for CI environments 44 if [[ "$f" == *.zip ]]; then 45 - echo "Extracting ZIP archive..." 46 - unzip -q "zig/$f" -d zig/extract 47 else 48 - echo "Extracting TAR archive with --no-same-owner (fixes CI permission issues)..." 49 - tar -xJf "zig/$f" --no-same-owner -C zig/extract 50 fi 51 52 - # Find the first directory at the top level (should be the Zig directory) 53 - d=$(find "zig/extract" -mindepth 1 -maxdepth 1 -type d -print -quit) 54 - if [ -z "$d" ]; then 55 - echo "Error: Could not determine extracted directory structure" 56 - echo "Contents of extract directory:" 57 - ls -la zig/extract 58 - exit 1 59 - fi 60 - d=$(basename "$d") 61 62 - echo "Found Zig directory: $d" 63 64 - # Verify the binary exists before creating symlink 65 - if [ ! -f "zig/extract/$d/bin/zig" ]; then 66 - echo "Error: Zig binary not found at expected location: zig/extract/$d/bin/zig" 67 - echo "Available files:" 68 - find "zig/extract" -type f 69 - exit 1 70 - fi 71 - 72 - # Create symlink with verification 73 - ln -sfv "zig/extract/$d/bin/zig" zig/zig || { echo "Error: Failed to create symlink"; exit 1; } 74 75 # Cleanup 76 - rm -f "zig/$f" "zig/$f.minisig" zig/zig.pub 77 - rm -rf "zig/extract" 78 79 - echo "Zig compiler installed successfully!" 80 - echo "Run with: ./zig/zig --version"
··· 2 set -e 3 4 [ -z "$ZIG_VERSION" ] && ZIG_VERSION="master" 5 + [ -z "$ZIG_PUBLIC_KEY" ] && ZIG_PUBLIC_KEY="RWSGOq2NVecA2UPNdBUZykf1CCb147pkmdtYxgb3Ti+JO/wCYvhbAb/U" 6 + 7 + command -v jq >/dev/null || { echo "jq required"; exit 1; } 8 + command -v minisign >/dev/null || { echo "minisign required"; exit 1; } 9 + 10 + # Clean up previous installation 11 + if [ -L "zig/zig" ]; then 12 + prev_dir=$(readlink zig/zig | cut -d '/' -f 2) 13 + [ -d "zig/$prev_dir" ] && rm -rf "zig/$prev_dir" 14 + rm -f "zig/zig" 15 + fi 16 17 case "$(uname -s)" in 18 Linux) ··· 21 aarch64) p="aarch64-linux" ;; 22 armv7l) p="arm-linux" ;; 23 i686) p="x86-linux" ;; 24 + *) echo "Arch unsupported"; exit 1 ;; 25 esac 26 ;; 27 Darwin) 28 case "$(uname -m)" in 29 x86_64) p="x86_64-macos" ;; 30 arm64) p="aarch64-macos" ;; 31 + *) echo "Arch unsupported"; exit 1 ;; 32 esac 33 ;; 34 + *) echo "OS unsupported"; exit 1 ;; 35 esac 36 37 u=$(curl -s https://ziglang.org/download/index.json | jq -r ".\"$ZIG_VERSION\".\"$p\".tarball") 38 + [ -z "$u" ] && { echo "Version not found"; exit 1; } 39 40 f=$(basename "$u") 41 + curl -sfL "$u" -o "zig/$f" || { echo "Download failed"; exit 1; } 42 + curl -sfL "$u.minisig" -o "zig/$f.minisig" || { echo "Sig download failed"; exit 1; } 43 + minisign -Vm "zig/$f" -P "$ZIG_PUBLIC_KEY" || { echo "Sig verification failed"; exit 1; } 44 45 + # Extract directly to zig folder 46 if [[ "$f" == *.zip ]]; then 47 + unzip -q "zig/$f" -d zig 48 else 49 + tar -xJf "zig/$f" --no-same-owner -C zig 50 fi 51 52 + # Derive directory name 53 + d=$(echo "$f" | sed -E 's/\.(tar\.xz|tar\.gz|zip|tgz|tar)$//') 54 55 + # Verify binary exists 56 + [ ! -f "zig/$d/zig" ] && { echo "Binary not found"; exit 1; } 57 58 + # Create symlink with absolute paths 59 + ln -sf "$(pwd)/zig/$d/zig" "$(pwd)/zig/zig" 60 61 # Cleanup 62 + rm -f "zig/$f" "zig/$f.minisig" 63 64 + echo "Zig installed successfully"