1 #! /usr/bin/env nix-shell
2 #! nix-shell -i bash -p bash curl jq
6 LATEST_VERSION
=$
(curl
-L -s https
://download.sysdig.com
/scanning
/sysdig-cli-scanner
/latest_version.txt
)
7 SUPPORTED_OPERATING_SYSTEMS
=("linux" "darwin")
8 SUPPORTED_ARCHITECTURES
=("x86_64" "aarch64")
9 SCRIPT_DIR
=$
( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev
/null
&& pwd )
10 VERSIONS_FILE
="${SCRIPT_DIR}/sysdig-cli-scanner.versions.nix"
13 echo "{" > "$VERSIONS_FILE"
14 echo " version = \"${LATEST_VERSION}\";" >> "$VERSIONS_FILE"
15 for os
in "${SUPPORTED_OPERATING_SYSTEMS[@]}"; do
16 for arch
in "${SUPPORTED_ARCHITECTURES[@]}"; do
17 formatted_arch
=$
(formatArchitectureForURL
"$arch")
18 download_url
="https://download.sysdig.com/scanning/bin/sysdig-cli-scanner/${LATEST_VERSION}/${os}/${formatted_arch}/sysdig-cli-scanner"
19 file_hash
=$
(fetchFileHash
"$download_url")
20 appendToVersionsFile
"$VERSIONS_FILE" "$arch" "$os" "$download_url" "$file_hash"
23 echo "}" >> "$VERSIONS_FILE"
26 formatArchitectureForURL
() {
27 local architecture
="$1"
28 case "$architecture" in
29 x86_64
) echo "amd64" ;;
30 aarch64
) echo "arm64" ;;
31 *) echo "Unsupported architecture: $architecture" >&2; return 1 ;;
37 nix store prefetch-file
--json "$url" | jq
-r .
hash
40 appendToVersionsFile
() {
42 local architecture
="$2"
43 local operating_system
="$3"
48 ${architecture}-${operating_system} = {