lol
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

dart: update update.sh

emaryn 96afc845 fa50093d

+12 -71
+12 -71
pkgs/development/compilers/dart/update.sh
··· 1 1 #!/usr/bin/env nix-shell 2 - #!nix-shell -i bash -p curl jq 2 + #!nix-shell -i bash -p curl jq common-updater-scripts 3 3 4 4 set -euo pipefail 5 5 6 - # so if the script fails, debug logs are on stderr 7 - log() { 8 - >&2 echo "DART_UPDATER: $@" 9 - } 6 + latestVersion=$(curl -sL https://storage.googleapis.com/dart-archive/channels/stable/release/latest/VERSION | jq --raw-output .version) 7 + currentVersion=$(nix eval --raw -f . dart.version) 10 8 11 - # fetch the latest version number from upstream 12 - NEW_VER_DETAILS=$(curl -sL https://storage.googleapis.com/dart-archive/channels/stable/release/latest/VERSION) 13 - NEW_VER=$(jq -r '.version' <<< "$NEW_VER_DETAILS") 9 + if [[ "$latestVersion" == "$currentVersion" ]]; then 10 + exit 0 11 + fi 14 12 15 13 MY_PATH=$(dirname $(realpath "$0")) 16 - SRC_FILE=$(mktemp) 17 14 18 - log "file to write is $SRC_FILE" 19 - 20 - PRELUDE="let 21 - version = \"$NEW_VER\"; 22 - in 23 - { fetchurl }: 24 - { 25 - versionUsed = version;" 26 - echo "$PRELUDE" > "$SRC_FILE" 27 - log "wrote prelude" 15 + update-source-version dart $latestVersion --file=$MY_PATH/sources.nix 28 16 29 - # Fetches the source, then writes the fetcher and hash into the sources file. 30 - # Arguments: 31 - # - $1: VARIABLE NAME of (table of nix platform -> dart platform mappings) ("DARWIN_PLATFORMS"|"LIN_PLATFORMS") 32 - # - $2: Dart-OS ("macos"|"linux") 33 - write_for_platform() { 34 - BASE_OF_ALL_URLS='https://storage.googleapis.com/dart-archive/channels/stable/release' 35 - BASE_URL_WRITTEN="$BASE_OF_ALL_URLS/\${version}/sdk" 36 - BASE_URL_FETCHED="$BASE_OF_ALL_URLS/$NEW_VER/sdk" 37 - 38 - TABLE_NAME=$1 39 - declare -n TABLE=$TABLE_NAME 40 - 41 - for platform in "${!TABLE[@]}"; do 42 - DART_PLATFORM="${TABLE[$platform]}" 43 - log "trying for dartplatform $DART_PLATFORM (platform $platform) (OS $2)" 44 - 45 - URL_POSTFIX="dartsdk-$2-$DART_PLATFORM-release.zip" 46 - URL="$BASE_URL_FETCHED/$URL_POSTFIX" 47 - log "URL for $DART_PLATFORM: $URL" 48 - 49 - HASH=$(nix-prefetch-url "$URL" --type sha256) 50 - log "hash for platform $platform: $HASH" 51 - 52 - FETCHER=" \"\${version}-$platform\" = fetchurl { 53 - url = \"$BASE_URL_WRITTEN/$URL_POSTFIX\"; 54 - sha256 = \"$HASH\"; 55 - };" 56 - 57 - echo "$FETCHER" >> $SRC_FILE 58 - done 59 - log "finished for $1" 60 - 61 - } 62 - 63 - # Map nix platforms -> Dart platforms 64 - X8664="x64" 65 - AARCH64="arm64" 66 - I686="ia32" 67 - declare -A DARWIN_PLATFORMS=(["aarch64-darwin"]="$AARCH64" 68 - ["x86_64-darwin"]="$X8664") 69 - 70 - declare -A LIN_PLATFORMS=( ["x86_64-linux"]="$X8664" 71 - ["i686-linux"]="$I686" 72 - ["aarch64-linux"]="$AARCH64") 73 - 74 - write_for_platform "DARWIN_PLATFORMS" "macos" 75 - write_for_platform "LIN_PLATFORMS" "linux" 76 - 77 - echo '}' >> $SRC_FILE 78 - 79 - log "moving tempfile to target directory" 80 - mv "$SRC_FILE" "$MY_PATH/sources.nix" 17 + systems=$(nix eval --json -f . dart.meta.platforms | jq --raw-output '.[]') 18 + for system in $systems; do 19 + hash=$(nix hash convert --to sri --hash-algo sha256 $(nix-prefetch-url $(nix eval --raw -f . dart.src.url --system "$system"))) 20 + update-source-version dart $latestVersion $hash --file=$MY_PATH/sources.nix --system=$system --ignore-same-version --ignore-same-hash 21 + done