Merge pull request #205226 from wegank/darwin-sdk-sh

This commit is contained in:
Sandro 2023-01-09 15:47:44 +01:00 committed by GitHub
commit 880d36a180
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -1,8 +1,16 @@
#!/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
usage() {
cat <<EOF
usage: $0 macos 11.0.1
EOF
}
if [ "$#" != 2 ]; then
usage
exit 1
fi
cd $(dirname "$0")
@ -16,14 +24,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 '}'