description="AMD ROCm platform (HIP, runtimes, tools)"
homepage="https://rocm.docs.amd.com/"
maintainer="Fraggle, fraggle at disroot dot org"

name=rocm
version=7.2
release=1
source="rocm-installer_1.2.5.70200-25-43~22.04.run::https://repo.radeon.com/rocm/installer/rocm-runfile-installer/rocm-rel-7.2/ubuntu/22.04/rocm-installer_1.2.5.70200-25-43~22.04.run
	rocm.sh
	70-rocm.rules"
noextract="rocm-installer_1.2.5.70200-25-43~22.04.run"

build() {
	mkdir -p $PKG/opt
	echo "==> Extracting ROCm runfile (this may take several minutes)..."
	bash "$SRC"/rocm-installer_*.run untar "$PKG/opt"
	rocmdir=$(ls -d $PKG/opt/rocm-* 2>/dev/null | head -1)
	if [ -z "$rocmdir" ]; then
		echo "ERROR: ROCm extraction did not produce rocm-* directory" >&2
		exit 1
	fi
	mv "$rocmdir" $PKG/opt/rocm

	# Environment for new shells
	install -Dm644 $SRC/rocm.sh $PKG/etc/profile.d/rocm.sh

	# udev rules for GPU access (kfd, render)
	install -Dm644 $SRC/70-rocm.rules $PKG/etc/udev/rules.d/70-rocm.rules
}
