2
0
Fork 0
mirror of https://github.com/bazel-contrib/bazel-lib synced 2024-11-30 01:41:21 +00:00
bazel-lib/tools/coreutils_mirror_release.sh
Malte Poll 1697a3275b
fix: coreutils toolchain: Use statically linked linux amd64 variant (#706)
* coreutils toolchain: Use statically linked linux amd64 variant

Uutils has a musl release artifact for linux amd64.
In the future, it should probably also be possible to add a
aarch64 musl toolchain. At the moment, this is not an upstream release
artifact.

* coreutils toolchain: temporarily add back old darwin variant

On release 0.0.26 of uutils/coreutils, the darwin x86_64 binary is missing.
Also, any releases between 0.0.23 and 0.0.26 are missing binary artifacts.
Downgrade coreutils toolchain on darwin x86_64 for now.

https://github.com/uutils/coreutils/releases/tag/0.0.26
2024-05-08 07:06:12 -07:00

58 lines
1.9 KiB
Bash
Executable file

#!/usr/bin/env bash
set -o errexit -o nounset -o pipefail
JQ_FILTER='map({
"key": .tag_name,
"value": .assets
| map(select(
(.name | startswith("coreutils-")) and
((.name | endswith(".tar.gz")) or (.name | endswith(".zip"))) and
(.name | contains("i686") | not) and
(
( (.name | contains("windows")) and (.name | contains("gnu") | not) ) or
( .name | contains("musl") ) or
( .name | contains("darwin") )
)
))
| map({
key: .name |
ltrimstr("coreutils-") |
rtrimstr(".tar.gz") |
rtrimstr(".zip") |
sub("-pc"; "") |
sub("-apple"; "") |
sub("-unknown"; "") |
sub("x86_64"; "amd64") |
sub("aarch64"; "arm64") |
gsub("\\d+.\\d+.\\d+-"; "") |
rtrimstr("-msvc") |
rtrimstr("-musl") |
split("-") |
reverse |
join("_"),
value: {
filename: .name,
sha256: "sha256-",
}
})
| from_entries
}) | 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")"
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
done
echo -n "COREUTILS_VERSIONS = "
echo $INFO | jq -M
echo ""
echo "Copy the version info into lib/private/coreutils_toolchain.bzl"