blob: 8e2e92585760de7b510e40d14f71f9c913e84d91 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
|
#!/usr/bin/env nix-shell
#!nix-shell -i bash -p curl jq nix common-updater-scripts
set -euo pipefail
gh_curl() { curl ${GITHUB_TOKEN:+-u ":$GITHUB_TOKEN"} -sf "$@"; }
version="${1:-$(gh_curl "https://api.github.com/repos/ROCm/rocm-libraries/releases?per_page=4" \
| jq -re 'map(.tag_name // .name)
| map(select(test("^rocm-[0-9]+\\.[0-9]+(\\.[0-9]+)?$")))
| first | ltrimstr("rocm-")')}"
# main source version
echo "Updating MIOpen to $version" >&2
update-source-version rocmPackages.miopen "$version" --ignore-same-hash
# kdbs.nix from s3 bucket
cd "$(dirname "${BASH_SOURCE[0]}")"
bucket="https://therock-dvc.s3.amazonaws.com/rocm-libraries/files/md5"
# Fetch directory listing; extract name + download_url for .dvc files
dvc_entries=$(gh_curl "https://api.github.com/repos/ROCm/rocm-libraries/contents/projects/miopen/src/kernels?ref=rocm-${version}" \
| jq -r '.[] | select(.name | endswith(".kdb.bz2.dvc")) | "\(.name)\t\(.download_url)"')
[[ -n "$dvc_entries" ]] || { echo "No .kdb.bz2.dvc files found, upstream likely changed packaging again" >&2; exit 1; }
{
echo "# Generated by update.sh"
echo "{"
while IFS=$'\t' read -r dvc_file raw_url; do
arch="${dvc_file%.kdb.bz2.dvc}"
md5=$(curl -sf "$raw_url" | awk '/- md5:/{print $3}')
url="${bucket}/${md5:0:2}/${md5:2}"
sri=$(nix --extra-experimental-features nix-command store prefetch-file --json "$url" --name "${arch}.kdb.bz2" | jq -r .hash)
echo " $arch: $sri" >&2
cat <<EOF
$arch = {
url = "$url";
hash = "$sri";
};
EOF
done <<< "$dvc_entries"
echo "}"
} > kdbs.nix
echo "Wrote kdbs.nix" >&2
|