2023-01-16 18:02:17 +00:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
|
|
|
|
set -o errexit -o nounset -o pipefail
|
|
|
|
|
2023-12-08 08:30:39 +00:00
|
|
|
JQ_FILTER='map({
|
2023-02-17 18:12:41 +00:00
|
|
|
"key": .tag_name,
|
|
|
|
"value": .assets
|
|
|
|
| map(select(
|
|
|
|
(.name | startswith("coreutils-")) and
|
2023-01-16 18:02:17 +00:00
|
|
|
((.name | endswith(".tar.gz")) or (.name | endswith(".zip"))) and
|
|
|
|
(.name | contains("i686") | not) and
|
|
|
|
(
|
2023-02-17 18:12:41 +00:00
|
|
|
( (.name | contains("windows")) and (.name | contains("gnu") | not) ) or
|
|
|
|
( (.name | contains("windows") | not) and (.name | contains("gnu") ) and (.name | contains("gnueabihf") | not) ) or
|
2023-01-16 18:02:17 +00:00
|
|
|
( .name | contains("darwin") )
|
|
|
|
)
|
|
|
|
))
|
2023-02-17 18:12:41 +00:00
|
|
|
| map({
|
|
|
|
key: .name |
|
|
|
|
ltrimstr("coreutils-") |
|
|
|
|
rtrimstr(".tar.gz") |
|
|
|
|
rtrimstr(".zip") |
|
|
|
|
sub("-pc"; "") |
|
2023-01-16 18:02:17 +00:00
|
|
|
sub("-apple"; "") |
|
|
|
|
sub("-unknown"; "") |
|
|
|
|
sub("x86_64"; "amd64") |
|
|
|
|
sub("aarch64"; "arm64") |
|
2023-02-17 18:12:41 +00:00
|
|
|
gsub("\\d+.\\d+.\\d+-"; "") |
|
|
|
|
rtrimstr("-msvc") |
|
2023-01-16 18:02:17 +00:00
|
|
|
rtrimstr("-gnu") |
|
|
|
|
split("-") |
|
|
|
|
reverse |
|
|
|
|
join("_"),
|
|
|
|
value: {
|
2023-02-17 18:12:41 +00:00
|
|
|
filename: .name,
|
|
|
|
sha256: "sha256-",
|
|
|
|
}
|
2023-01-16 18:02:17 +00:00
|
|
|
})
|
2023-02-17 18:12:41 +00:00
|
|
|
| from_entries
|
2023-01-16 18:02:17 +00:00
|
|
|
}) | from_entries
|
|
|
|
'
|
|
|
|
|
|
|
|
INFO="$(curl --silent -H "Accept: application/vnd.github.v3+json" https://api.github.com/repos/uutils/coreutils/releases?per_page=1 | jq "$JQ_FILTER")"
|
|
|
|
|
2023-12-08 08:30:39 +00:00
|
|
|
for VERSION in $(jq -r 'keys | join("\n")' <<<$INFO); do
|
|
|
|
for PLATFORM in $(jq -r ".[\"$VERSION\"] | keys | join(\"\n\")" <<<$INFO); do
|
|
|
|
FILENAME=$(jq -r ".[\"$VERSION\"][\"$PLATFORM\"].filename" <<<$INFO)
|
|
|
|
SHA256=$(curl -fLs "https://github.com/uutils/coreutils/releases/download/$VERSION/$FILENAME" | sha256sum | xxd -r -p | base64)
|
|
|
|
INFO=$(jq ".[\"$VERSION\"][\"$PLATFORM\"].sha256 = \"sha256-$SHA256\"" <<<$INFO)
|
|
|
|
done
|
2023-01-16 18:02:17 +00:00
|
|
|
done
|
|
|
|
|
|
|
|
echo -n "COREUTILS_VERSIONS = "
|
|
|
|
echo $INFO | jq -M
|
|
|
|
|
|
|
|
echo ""
|
2023-02-17 18:12:41 +00:00
|
|
|
echo "Copy the version info into lib/private/coreutils_toolchain.bzl"
|