Clone of https://github.com/NixOS/nixpkgs.git (to stress-test knotserver)
at devShellTools-shell 56 lines 2.4 kB view raw
1#!/usr/bin/env nix-shell 2#!nix-shell -I nixpkgs=./. -i bash -p curl jq nix-prefetch common-updater-scripts nix coreutils 3# shellcheck shell=bash 4set -euo pipefail 5 6VERSION=$(curl -s https://api.github.com/repos/facebook/buck2/releases \ 7 | jq -r 'sort_by(.created_at) | reverse | 8 (map 9 (select ((.prerelease == true) and (.name != "latest"))) | 10 first 11 ) | .name') 12PRELUDE_HASH=$(curl -sLo - "https://github.com/facebook/buck2/releases/download/${VERSION}/prelude_hash") 13PRELUDE_DL_URL="https://github.com/facebook/buck2-prelude/archive/${PRELUDE_HASH}.tar.gz" 14 15echo "Latest buck2 prerelease: $VERSION" 16echo "Compatible buck2-prelude hash: $PRELUDE_HASH" 17 18ARCHS=( 19 "x86_64-linux:x86_64-unknown-linux-musl" 20 "x86_64-darwin:x86_64-apple-darwin" 21 "aarch64-linux:aarch64-unknown-linux-musl" 22 "aarch64-darwin:aarch64-apple-darwin" 23) 24 25NFILE=pkgs/by-name/bu/buck2/package.nix 26HFILE=pkgs/by-name/bu/buck2/hashes.json 27rm -f "$HFILE" && touch "$HFILE" 28 29PRELUDE_SHA256HASH="$(nix-prefetch-url --type sha256 "$PRELUDE_DL_URL")" 30PRELUDE_SRIHASH="$(nix --extra-experimental-features nix-command hash to-sri --type sha256 "$PRELUDE_SHA256HASH")" 31 32printf "{ \"_comment\": \"@generated by pkgs/by-name/bu/buck2/update.sh\"\n" >> "$HFILE" 33printf ", \"_prelude\": \"$PRELUDE_SRIHASH\"\n" >> "$HFILE" 34 35for arch in "${ARCHS[@]}"; do 36 IFS=: read -r arch_name arch_target <<< "$arch" 37 sha256hash="$(nix-prefetch-url --type sha256 "https://github.com/facebook/buck2/releases/download/${VERSION}/buck2-${arch_target}.zst")" 38 srihash="$(nix --extra-experimental-features nix-command hash to-sri --type sha256 "$sha256hash")" 39 echo ", \"buck2-$arch_name\": \"$srihash\"" >> "$HFILE" 40 41 IFS=: read -r arch_name arch_target <<< "$arch" 42 sha256hash="$(nix-prefetch-url --type sha256 "https://github.com/facebook/buck2/releases/download/${VERSION}/rust-project-${arch_target}.zst")" 43 srihash="$(nix --extra-experimental-features nix-command hash to-sri --type sha256 "$sha256hash")" 44 echo ", \"rust-project-$arch_name\": \"$srihash\"" >> "$HFILE" 45done 46echo "}" >> "$HFILE" 47 48sed -i \ 49 '0,/version\s*=\s*".*";/s//version = "'"$VERSION"'";/' \ 50 "$NFILE" 51 52sed -i \ 53 '0,/prelude-hash\s*=\s*".*";/s//prelude-hash = "'"$PRELUDE_HASH"'";/' \ 54 "$NFILE" 55 56echo "Done; wrote $HFILE and updated version in $NFILE."