diff options
author | gilice <104317939+gilice@users.noreply.github.com> | 2023-03-21 17:30:07 +0100 |
---|---|---|
committer | gilice <104317939+gilice@users.noreply.github.com> | 2023-03-21 17:43:36 +0100 |
commit | e31eb9a58d62043cdc9ba7db8b6b2dd19f6e1c5d (patch) | |
tree | 0a640fff07183c31f5e701aed799197c55a6c467 /pkgs/development/compilers/dart | |
parent | 8b7b6bac2c9cc5fd2888362f284a67271d29c4f1 (diff) |
dart: Make update script atomic
Diffstat (limited to 'pkgs/development/compilers/dart')
-rw-r--r-- | pkgs/development/compilers/dart/sources.nix | 3 | ||||
-rwxr-xr-x | pkgs/development/compilers/dart/update.sh | 19 |
2 files changed, 8 insertions, 14 deletions
diff --git a/pkgs/development/compilers/dart/sources.nix b/pkgs/development/compilers/dart/sources.nix index 13aaac2bb327f..40e25d3584773 100644 --- a/pkgs/development/compilers/dart/sources.nix +++ b/pkgs/development/compilers/dart/sources.nix @@ -1,5 +1,3 @@ -# This file was generated by ./update.sh. -# If you do not find a line of three #-s at the end, it is broken and should not be used. let version = "2.19.3"; in { fetchurl }: { versionUsed = version; @@ -24,4 +22,3 @@ let version = "2.19.3"; in sha256 = "0xksis14ff6bzjvycgxgldg96n88rh42adjyrrhcay2s183vh480"; }; } -### diff --git a/pkgs/development/compilers/dart/update.sh b/pkgs/development/compilers/dart/update.sh index c148f09b52a24..87f430cd5d2dc 100755 --- a/pkgs/development/compilers/dart/update.sh +++ b/pkgs/development/compilers/dart/update.sh @@ -3,7 +3,7 @@ set -euo pipefail -# so if the script fails, debug logs are on stdenv +# so if the script fails, debug logs are on stderr log() { >&2 echo "DART_UPDATER: $@" } @@ -13,12 +13,11 @@ NEW_VER_DETAILS=$(curl -sL https://storage.googleapis.com/dart-archive/channels/ NEW_VER=$(jq -r '.version' <<< "$NEW_VER_DETAILS") MY_PATH=$(dirname $(realpath "$0")) -SRC_FILE="$MY_PATH/sources.nix" +SRC_FILE=$(mktemp) + log "file to write is $SRC_FILE" -PRELUDE="# This file was generated by ./update.sh. -# If you do not find a line of three #-s at the end, it is broken and should not be used. -let version = \"$NEW_VER\"; in +PRELUDE="let version = \"$NEW_VER\"; in { fetchurl }: { versionUsed = version;" echo "$PRELUDE" > "$SRC_FILE" @@ -54,8 +53,7 @@ write_for_platform() { echo "$FETCHER" >> $SRC_FILE done - log "finished for $1 ----" + log "finished for $1" } @@ -73,8 +71,7 @@ declare -A LIN_PLATFORMS=( ["x86_64-linux"]="$X8664" write_for_platform "DARWIN_PLATFORMS" "macos" write_for_platform "LIN_PLATFORMS" "linux" -echo '} -###' >> $SRC_FILE +echo '}' >> $SRC_FILE -log "Replacing version in dart/default.nix" -sed -i "s/$UPDATE_NIX_OLD_VERSION/$NEW_VER/g" "$MY_PATH/default.nix" +log "moving tempfile to target directory" +mv "$SRC_FILE" "$MY_PATH/sources.nix" |