# For dotnet.sh, with json.awk: in the release metadata of a .NET channel (releases.json of # builds.dotnet.microsoft.com/dotnet/release-metadata//), the newest SDK («latest-sdk») and the address and # SHA-512 of its archive for the rid asked: # # LC_ALL=C awk -v rid=linux-x64 -f json.awk -f dotnet-sdk.awk releases.json # # Prints «
» and exits with 0, or says why on stderr and exits with 1. The archive # is the file object with that address: https, on one of Microsoft's two hosts of .NET builds, named # dotnet-sdk--.tar.gz, with a hash of 128 hexadecimal digits. function json_begin(file) {} function json_open(kind) { if (kind == "o") { address[json_depth] = "" hash[json_depth] = "" } } function json_scalar(kind, value) { if (kind != "s" || json_depth == 0 || json_stack[json_depth] != "o") return if (json_depth == 1 && json_at[1] == "latest-sdk") latest = value if (json_at[json_depth] == "url") address[json_depth] = value if (json_at[json_depth] == "hash") hash[json_depth] = value } function json_close(kind) { if (kind == "o" && address[json_depth] != "") sha512[address[json_depth]] = hash[json_depth] } function json_end(file, error) { problem = error } END { if (problem != "") { print "metadati dei rilasci .NET non validi: " problem > "/dev/stderr" exit 1 } if (latest !~ /^[0-9]+[.][0-9]+[.][0-9]+(-[0-9A-Za-z.]+)?$/) { print "nei metadati dei rilasci .NET manca «latest-sdk» o non è una versione: «" substr(latest, 1, 40) "»" > "/dev/stderr" exit 1 } name = "dotnet-sdk-" latest "-" rid ".tar.gz" for (candidate in sha512) { if (substr(candidate, length(candidate) - length(name)) != "/" name) continue if (candidate !~ /^https:[/][/](builds[.]dotnet[.]microsoft[.]com|dotnetcli[.]blob[.]core[.]windows[.]net)[/]/) continue if (sha512[candidate] !~ /^[0-9a-fA-F]+$/ || length(sha512[candidate]) != 128) continue found = candidate } if (found == "") { print "nei metadati dei rilasci .NET non c'è l'archivio " name " con la sua impronta" > "/dev/stderr" exit 1 } print latest "\t" found "\t" tolower(sha512[found]) }