darwin: fix generate-sdk-packages.sh

This commit is contained in:
Weijia Wang 2023-01-09 13:08:09 +01:00
parent ebf9e988a9
commit 2bd3048ea4

View file

@ -1,5 +1,5 @@
#!/usr/bin/env nix-shell
#!nix-shell -i bash -p curl
#!nix-shell -i bash -p curl jq
# usage:
# generate-sdk-packages.sh macos 11.0.1
@ -16,14 +16,14 @@ outfile="$sdkName.nix"
{"
parse_line() {
readarray -t -d$'\t' package <<<$2
readarray -t -d$'-' package < <(printf "%s" $2)
local pname=${package[0]} version=${package[1]}
if [ -d $pname ]; then
sha256=$(nix-prefetch-url "https://opensource.apple.com/tarballs/$pname/$pname-$version.tar.gz")
sha256=$(nix-prefetch-url "https://github.com/apple-oss-distributions/$pname/archive/refs/tags/$pname-$version.tar.gz")
>>$outfile echo "$pname = applePackage' \"$pname\" \"$version\" \"$sdkName\" \"$sha256\" {};"
fi
}
readarray -s1 -c1 -C parse_line < <(curl -sS "https://opensource.apple.com/text/${sdkName//./}.txt")
readarray -s1 -c1 -C parse_line < <(curl -sSL "https://github.com/apple-oss-distributions/distribution-${1//-/_}/raw/${sdkName//./}/release.json" | jq -r ".projects[].tag")
>>$outfile echo '}'