Unverified Commit 3376d1ef authored by Luna Nova's avatar Luna Nova
Browse files

rocmPackages.miopen: add updateScript for DVC S3 kdb files

Files were moved to DVC in rocm-libraries PR 1594
parent 331070f8
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -285,6 +285,7 @@ stdenv.mkDerivation (finalAttrs: {
      inherit frugally-deep nlohmann_json;
    };
  };
  passthru.updateScript = ./update.sh;

  meta = {
    description = "Machine intelligence library for ROCm";
+1 −0
Original line number Diff line number Diff line
# Generated by update.sh
{
  gfx1030 = {
    url = "https://therock-dvc.s3.amazonaws.com/rocm-libraries/files/md5/22/c4bd38cc34d3906add061ee57b099b";
+48 −0
Original line number Diff line number Diff line
#!/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/MIOpen/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/MIOpen/contents/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