python313Packages.traits: fix build (#373698)
[NixPkgs.git] / pkgs / tools / admin / google-cloud-sdk / update.sh
blob5b400dba334874e7e7abb3f55049a549628afecd
1 #!/usr/bin/env nix-shell
2 #! nix-shell -i bash -p nix jq curl
4 CHANNEL_URL="https://dl.google.com/dl/cloudsdk/channels/rapid"
5 BASE_URL="$CHANNEL_URL/downloads/google-cloud-sdk"
7 PACKAGE_DIR=$(dirname -- "$0")
9 VERSION=$(curl "https://storage.googleapis.com/storage/v1/b/cloud-sdk-release/o?delimiter=/&startOffset=google-cloud-sdk-${UPDATE_NIX_OLD_VERSION}&endOffset=google-cloud-sdk-9" | jq --raw-output '.items[-1].name | scan("\\d+\\.\\d+\\.\\d+")')
11 function genMainSrc() {
12 local url="${BASE_URL}-${VERSION}-${1}-${2}.tar.gz"
13 local sha256
14 sha256=$(nix-prefetch-url "$url")
15 echo " {"
16 echo " url = \"${url}\";"
17 echo " sha256 = \"${sha256}\";"
18 echo " };"
22 cat <<EOF
23 # DO NOT EDIT! This file is generated automatically by update.sh
24 { }:
26 version = "${VERSION}";
27 googleCloudSdkPkgs = {
28 EOF
30 echo " x86_64-linux ="
31 genMainSrc "linux" "x86_64"
33 echo " x86_64-darwin ="
34 genMainSrc "darwin" "x86_64"
36 echo " aarch64-linux ="
37 genMainSrc "linux" "arm"
39 echo " aarch64-darwin ="
40 genMainSrc "darwin" "arm"
42 echo " i686-linux ="
43 genMainSrc "linux" "x86"
45 echo " };"
46 echo "}"
48 } > "${PACKAGE_DIR}/data.nix"
50 curl "${CHANNEL_URL}/components-v${VERSION}.json" -w "\n" > "${PACKAGE_DIR}/components.json"