52 lines
1.6 KiB
Nix
52 lines
1.6 KiB
Nix
|
{ lib
|
||
|
, writeScript
|
||
|
}:
|
||
|
|
||
|
{ version }:
|
||
|
|
||
|
let
|
||
|
prefix = "hsa-amd-aqlprofile";
|
||
|
extVersion = lib.strings.concatStrings (lib.strings.intersperse "0" (lib.versions.splitVersion version));
|
||
|
major = lib.versions.major version;
|
||
|
minor = lib.versions.minor version;
|
||
|
patch = lib.versions.patch version;
|
||
|
|
||
|
updateScript = writeScript "update.sh" ''
|
||
|
#!/usr/bin/env nix-shell
|
||
|
#!nix-shell -i bash -p curl common-updater-scripts
|
||
|
apt="https://repo.radeon.com/rocm/apt"
|
||
|
pool="pool/main/h/${prefix}/"
|
||
|
url="$apt/latest/$pool"
|
||
|
res="$(curl -sL "$url")"
|
||
|
deb="${prefix}$(echo "$res" | grep -o -P "(?<=href=\"${prefix}).*(?=\">)" | tail -1)"
|
||
|
patch="${patch}"
|
||
|
|
||
|
# Try up to 10 patch versions
|
||
|
for i in {1..10}; do
|
||
|
((patch++))
|
||
|
extVersion="$(echo "$deb" | grep -o -P "(?<=\.....).*(?=\..*-)")"
|
||
|
|
||
|
if (( ''${#extVersion} == 5 )) && (( $extVersion <= ${extVersion} )); then
|
||
|
url="https://repo.radeon.com/rocm/apt/${major}.${minor}.$patch/pool/main/h/${prefix}/"
|
||
|
res="$(curl -sL "$url")"
|
||
|
deb="${prefix}$(echo "$res" | grep -o -P "(?<=href=\"${prefix}).*(?=\">)" | tail -1)"
|
||
|
else
|
||
|
break
|
||
|
fi
|
||
|
done
|
||
|
|
||
|
extVersion="$(echo $deb | grep -o -P "(?<=\.....).*(?=\..*-)")"
|
||
|
version="$(echo $extVersion | sed "s/0/./1" | sed "s/0/./1")"
|
||
|
|
||
|
if (( ''${#extVersion} == 5 )); then
|
||
|
repoVersion="$version"
|
||
|
|
||
|
if (( ''${version:4:1} == 0 )); then
|
||
|
repoVersion=''${version:0:3}
|
||
|
fi
|
||
|
|
||
|
update-source-version rocmPackages_5.${prefix}-bin "$version" "" "$apt/$repoVersion/$pool$deb" --ignore-same-hash
|
||
|
fi
|
||
|
'';
|
||
|
in [ updateScript ]
|