From a9fc578fe7ee4fb7158a45771aebeb74bfb72c93 Mon Sep 17 00:00:00 2001 From: mdarocha Date: Wed, 21 Sep 2022 06:50:00 +0200 Subject: [PATCH] dotnet-sdk: update.sh - allow early exit. If updating to the latest version, and the local expression already is the latest version, exit without regenerating everything. --- pkgs/development/compilers/dotnet/update.sh | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/pkgs/development/compilers/dotnet/update.sh b/pkgs/development/compilers/dotnet/update.sh index dc9ff0538c74..8f59e58ff5a5 100755 --- a/pkgs/development/compilers/dotnet/update.sh +++ b/pkgs/development/compilers/dotnet/update.sh @@ -297,17 +297,32 @@ Examples: major_minor=$(sed 's/^\([0-9]*\.[0-9]*\).*$/\1/' <<< "$sem_version") content=$(curl -sL https://dotnetcli.blob.core.windows.net/dotnet/release-metadata/"$major_minor"/releases.json) major_minor_patch=$([ "$patch_specified" == true ] && echo "$sem_version" || jq -r '."latest-release"' <<< "$content") + major_minor_underscore=${major_minor/./_} release_content=$(release "$content" "$major_minor_patch") aspnetcore_version=$(jq -r '."aspnetcore-runtime".version' <<< "$release_content") runtime_version=$(jq -r '.runtime.version' <<< "$release_content") sdk_version=$(jq -r '.sdk.version' <<< "$release_content") + # If patch was not specified, check if the package is already the latest version + # If it is, exit early + if [ "$patch_specified" == false ] && [ -f "./versions/${sem_version}.nix" ]; then + current_version=$(nix-instantiate --eval -E "(import ./versions/${sem_version}.nix { \ + buildAspNetCore = { ... }: {}; \ + buildNetRuntime = { ... }: {}; \ + buildNetSdk = { version, ... }: version; \ + icu = null; }).sdk_${major_minor_underscore}" | jq -r) + + if [[ "$current_version" == "$sdk_version" ]]; then + echo "Nothing to update." + exit + fi + fi + aspnetcore_files="$(release_files "$release_content" "aspnetcore-runtime")" runtime_files="$(release_files "$release_content" "runtime")" sdk_files="$(release_files "$release_content" "sdk")" - major_minor_underscore=${major_minor/./_} channel_version=$(jq -r '."channel-version"' <<< "$content") support_phase=$(jq -r '."support-phase"' <<< "$content") echo "{ buildAspNetCore, buildNetRuntime, buildNetSdk, icu }: