dotnet: Update print-hashes script
* Update script to use dotnets releases-index urls specified in https://dotnetcli.blob.core.windows.net/dotnet/release-metadata/releases-index.json * Can get source information for multiple versions * Outputs the whole src expression for all available/mapped platforms
This commit is contained in:
parent
d96018d299
commit
feaf708634
1 changed files with 96 additions and 55 deletions
|
@ -1,69 +1,110 @@
|
||||||
#!/usr/bin/env nix-shell
|
#!/usr/bin/env nix-shell
|
||||||
#!nix-shell -i bash -p curl
|
#!nix-shell -i bash -p curl jq
|
||||||
|
|
||||||
set -eu
|
set -eu
|
||||||
|
|
||||||
if [[ $# -lt 1 ]]; then
|
release () {
|
||||||
echo \"usage: $0 version\" >&2
|
local content="$1"
|
||||||
|
local version="$2"
|
||||||
|
|
||||||
|
jq -r '.releases[] | select(."release-version" == "'"$version"'")' <<< "$content"
|
||||||
|
}
|
||||||
|
|
||||||
|
release_files () {
|
||||||
|
local release="$1"
|
||||||
|
local type="$2"
|
||||||
|
|
||||||
|
jq -r '[."'"$type"'".files[] | select(.name | test("^.*.tar.gz$"))]' <<< "$release"
|
||||||
|
}
|
||||||
|
|
||||||
|
release_platform_attr () {
|
||||||
|
local release_files="$1"
|
||||||
|
local platform="$2"
|
||||||
|
local attr="$3"
|
||||||
|
|
||||||
|
jq -r '.[] | select(.rid == "'"$platform"'") | ."'"$attr"'"' <<< "$release_files"
|
||||||
|
}
|
||||||
|
|
||||||
|
platform_sources () {
|
||||||
|
local release_files="$1"
|
||||||
|
local platforms=( \
|
||||||
|
"x86_64-linux linux-x64" \
|
||||||
|
"aarch64-linux linux-arm64" \
|
||||||
|
"x86_64-darwin osx-x64" \
|
||||||
|
"aarch64-darwin osx-arm64" \
|
||||||
|
)
|
||||||
|
|
||||||
|
echo "srcs = {"
|
||||||
|
for kv in "${platforms[@]}"; do
|
||||||
|
local nix_platform=${kv%% *}
|
||||||
|
local ms_platform=${kv##* }
|
||||||
|
|
||||||
|
local url=$(release_platform_attr "$release_files" "$ms_platform" url)
|
||||||
|
local hash=$(release_platform_attr "$release_files" "$ms_platform" hash)
|
||||||
|
|
||||||
|
[[ -z "$url" || -z "$hash" ]] && continue
|
||||||
|
echo " $nix_platform = {
|
||||||
|
url = \"$url\";
|
||||||
|
sha512 = \"$hash\";
|
||||||
|
}; "
|
||||||
|
done
|
||||||
|
echo " };"
|
||||||
|
}
|
||||||
|
|
||||||
|
main () {
|
||||||
|
pname=$(basename "$0")
|
||||||
|
if [[ ! "$*" =~ ^.*[0-9]{1,}\.[0-9]{1,}.*$ ]]; then
|
||||||
|
echo "Usage: $pname [sem-versions]
|
||||||
|
Get updated dotnet src (platform - url & sha512) expressions for specified versions
|
||||||
|
|
||||||
|
Examples:
|
||||||
|
$pname 3.1.21 5.0.12 - specific x.y.z versions
|
||||||
|
$pname 3.1 5.0 6.0 - latest x.y versions
|
||||||
|
" >&2
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
VERSION=$1
|
for sem_version in "$@"; do
|
||||||
HASHFILE=$(mktemp /tmp/dotnet.hashes.XXXXXXXX)
|
patch_specified=false
|
||||||
trap "rm -f $HASHFILE" EXIT
|
if [[ "$sem_version" =~ ^[0-9]{1,}\.[0-9]{1,}\.[0-9]{1,}$ ]]; then
|
||||||
|
patch_specified=true
|
||||||
|
elif [[ ! "$sem_version" =~ ^[0-9]{1,}\.[0-9]{1,}$ ]]; then
|
||||||
|
continue
|
||||||
|
fi
|
||||||
|
|
||||||
curl -L https://dotnetcli.blob.core.windows.net/dotnet/checksums/$VERSION-sha.txt -o $HASHFILE
|
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")
|
||||||
|
|
||||||
ASPNETCORE_VERSION=$(grep aspnetcore-runtime- $HASHFILE | grep -- -linux-x64.tar.gz | tail -n -1 | sed -e 's:.*aspnetcore-runtime-::' -e 's:-linux-x64.tar.gz.*$::' )
|
release_content=$(release "$content" "$major_minor_patch")
|
||||||
ASPNETCORE_HASH_LINUX_X64=$(grep aspnetcore-runtime- $HASHFILE | grep -- -linux-x64.tar.gz | cut -d ' ' -f 1)
|
aspnetcore_version=$(jq -r '."aspnetcore-runtime".version' <<< "$release_content")
|
||||||
ASPNETCORE_HASH_LINUX_ARM64=$(grep aspnetcore-runtime- $HASHFILE | grep -- -linux-arm64.tar.gz | cut -d ' ' -f 1)
|
runtime_version=$(jq -r '.runtime.version' <<< "$release_content")
|
||||||
ASPNETCORE_HASH_OSX_X64=$(grep aspnetcore-runtime- $HASHFILE | grep -- -osx-x64.tar.gz | cut -d ' ' -f 1)
|
sdk_version=$(jq -r '.sdk.version' <<< "$release_content")
|
||||||
ASPNETCORE_HASH_OSX_ARM64=$(grep aspnetcore-runtime- $HASHFILE | grep -- -osx-arm64.tar.gz | cut -d ' ' -f 1)
|
|
||||||
|
|
||||||
RUNTIME_VERSION=$(grep dotnet-runtime- $HASHFILE | grep -- -linux-x64.tar.gz | tail -n -1 | sed -e 's:.*dotnet-runtime-::' -e 's:-linux-x64.tar.gz.*$::' )
|
aspnetcore_files="$(release_files "$release_content" "aspnetcore-runtime")"
|
||||||
RUNTIME_HASH_LINUX_X64=$(grep dotnet-runtime- $HASHFILE | grep -- -linux-x64.tar.gz | cut -d ' ' -f 1)
|
runtime_files="$(release_files "$release_content" "runtime")"
|
||||||
RUNTIME_HASH_LINUX_ARM64=$(grep dotnet-runtime- $HASHFILE | grep -- -linux-arm64.tar.gz | cut -d ' ' -f 1)
|
sdk_files="$(release_files "$release_content" "sdk")"
|
||||||
RUNTIME_HASH_OSX_X64=$(grep dotnet-runtime- $HASHFILE | grep -- -osx-x64.tar.gz | cut -d ' ' -f 1)
|
|
||||||
RUNTIME_HASH_OSX_ARM64=$(grep dotnet-runtime- $HASHFILE | grep -- -osx-arm64.tar.gz | cut -d ' ' -f 1)
|
|
||||||
|
|
||||||
# dotnet-sdk has multiple entries in file, but the latest is the newest
|
major_minor_underscore=${major_minor/./_}
|
||||||
SDK_VERSION=$(grep dotnet-sdk- $HASHFILE | grep -- -linux-x64.tar.gz | tail -n -1 | sed -e 's:.*dotnet-sdk-::' -e 's:-linux-x64.tar.gz.*$::' )
|
channel_version=$(jq -r '."channel-version"' <<< "$content")
|
||||||
SDK_HASH_LINUX_X64=$(grep dotnet-sdk- $HASHFILE | grep -- -linux-x64.tar.gz | tail -n 1 | cut -d ' ' -f 1)
|
support_phase=$(jq -r '."support-phase"' <<< "$content")
|
||||||
SDK_HASH_LINUX_ARM64=$(grep dotnet-sdk- $HASHFILE | grep -- -linux-arm64.tar.gz | tail -n 1 | cut -d ' ' -f 1)
|
echo "
|
||||||
SDK_HASH_OSX_X64=$(grep dotnet-sdk- $HASHFILE | grep -- -osx-x64.tar.gz | tail -n 1 | cut -d ' ' -f 1)
|
# v$channel_version ($support_phase)
|
||||||
SDK_HASH_OSX_ARM64=$(grep dotnet-sdk- $HASHFILE | grep -- -osx-arm64.tar.gz | tail -n 1 | cut -d ' ' -f 1)
|
aspnetcore_$major_minor_underscore = buildAspNetCore {
|
||||||
|
version = \"${aspnetcore_version}\";
|
||||||
V=${VERSION/./_}
|
$(platform_sources "$aspnetcore_files")
|
||||||
MAJOR_MINOR_VERSION=${V%%.*}
|
|
||||||
|
|
||||||
echo """
|
|
||||||
aspnetcore_${MAJOR_MINOR_VERSION} = buildAspNetCore {
|
|
||||||
version = \"${ASPNETCORE_VERSION}\";
|
|
||||||
sha512 = {
|
|
||||||
x86_64-linux = \"${ASPNETCORE_HASH_LINUX_X64}\";
|
|
||||||
aarch64-linux = \"${ASPNETCORE_HASH_LINUX_ARM64}\";
|
|
||||||
x86_64-darwin = \"${ASPNETCORE_HASH_OSX_X64}\";
|
|
||||||
aarch64-darwin = \"${ASPNETCORE_HASH_OSX_ARM64}\";
|
|
||||||
};
|
|
||||||
};
|
};
|
||||||
|
|
||||||
runtime_${MAJOR_MINOR_VERSION} = buildNetRuntime {
|
runtime_$major_minor_underscore = buildNetRuntime {
|
||||||
version = \"${RUNTIME_VERSION}\";
|
version = \"${runtime_version}\";
|
||||||
sha512 = {
|
$(platform_sources "$runtime_files")
|
||||||
x86_64-linux = \"${RUNTIME_HASH_LINUX_X64}\";
|
|
||||||
aarch64-linux = \"${RUNTIME_HASH_LINUX_ARM64}\";
|
|
||||||
x86_64-darwin = \"${RUNTIME_HASH_OSX_X64}\";
|
|
||||||
aarch64-darwin = \"${RUNTIME_HASH_OSX_ARM64}\";
|
|
||||||
};
|
|
||||||
};
|
};
|
||||||
|
|
||||||
sdk_${MAJOR_MINOR_VERSION} = buildNetSdk {
|
sdk_$major_minor_underscore = buildNetSdk {
|
||||||
version = \"${SDK_VERSION}\";
|
version = \"${sdk_version}\";
|
||||||
sha512 = {
|
$(platform_sources "$sdk_files")
|
||||||
x86_64-linux = \"${SDK_HASH_LINUX_X64}\";
|
}; "
|
||||||
aarch64-linux = \"${SDK_HASH_LINUX_ARM64}\";
|
done
|
||||||
x86_64-darwin = \"${SDK_HASH_OSX_X64}\";
|
}
|
||||||
aarch64-darwin = \"${SDK_HASH_OSX_ARM64}\";
|
|
||||||
};
|
main "$@"
|
||||||
};
|
|
||||||
"""
|
|
||||||
|
|
Loading…
Reference in a new issue