Files
TheRock/rocm-systems/projects/rocm-core/rocm-core.postinst
T
derek.holloway 7502bf64a4
CodeQL / Analyze (actions) (push) Canceled after 0s
CodeQL / Analyze (python) (push) Canceled after 0s
pre-commit / pre-commit (push) Canceled after 0s
Multi-Arch CI / setup (push) Canceled after 0s
Publish build_manylinux_x86_64 images / publish_build_manylinux_x86_64 (push) Canceled after 0s
Setup (Multi-Arch) / setup (push) Canceled after 0s
Multi-Arch CI / Linux::${{ fromJSON(needs.setup.outputs.linux_build_config || '{}').build_variant_label || 'skip' }} (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish no_rocm_image_ubi10 image / publish_no_rocm_image_ubi10 (push) Canceled after 0s
Multi-Arch CI / Windows::${{ fromJSON(needs.setup.outputs.windows_build_config || '{}').build_variant_label || 'skip' }} (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Multi-Arch CI / Manifest Diff (push) Canceled after 0s
TheRock Manifest Diff Report / Generate Manifest Diff Report (push) Canceled after 0s
Multi-Arch CI / CI Summary (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04 (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04_ocl_rt images / publish_no_rocm_image_ubuntu24_04_ocl_rt (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_rocgdb (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04_rocgdb images / publish_no_rocm_image_ubuntu24_04_rocgdb (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_ocl_rt (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Unit Tests / Unit Tests :: ubuntu-24.04 (push) Canceled after 0s
Unit Tests / Unit Tests :: windows-2022 (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_media (push) Canceled after 0s
Unit Tests / Unit Tests Summary (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_openmpi (push) Canceled after 0s
Flatten subprojects into a single base monorepo
2026-09-02 16:34:47 -07:00

77 lines
3.0 KiB
Bash
Executable File

#!/bin/bash
set -e
do_update_alternatives(){
# skip update if program doesn't exist
command -v update-alternatives >/dev/null || return 0
local altscore now
now=$(date -u +%s) # Number of seconds since 1 Jan 1970
# The reason for this approach rather than using the build number
# is to allow for jobs from different builds. In one build job the
# job number might be at 1200, whilst in a release job the number
# may be only 1. This approach assums that if you install a build
# with a different semantic version then the highest is the
# desired one, but if you install two with the same semver then
# the newest is the desired version.
# Build up a score. It needs to fit in 32 bits
altscore=$((@VERSION_MAJOR@ - 3))
altscore=$((altscore * 14 + @VERSION_MINOR@)) # Allow up to 14 minor
altscore=$((altscore * 14 + @VERSION_PATCH@)) # Allow up to 14 patch
# So far if the version is less than 9 we have a number (altscore)
# that is less than 1175. 2**31/1175 is about 1.8 million. So
# multiply altscore by 1,000,000 and add in a factor of how many
# minutes have passed from an arbitary point in time (1,600,000,000
# seconds after 1 Jan 1970 or Sep 13 12:26:40 2020) on the
# basis that no one is going to be installing a new version more
# often than every minute. This does get things wrong if a million
# minutes pass and you are downgrading, but the chances of someone
# waiting almost 2 years between installing a version and the
# previous patch level is small.
altscore=$((altscore*1000000+(now-1600000000)/60))
# Update the /opt/rocm symlink
# For custom location installation of rpm package, /opt/rocm symlink is not required
# TBD: For custom location installation of deb package.
if [[ ${ID_LIKE:-$ID} == "debian" ]] || [[ "$RPM_INSTALL_PREFIX0" == "/opt/rocm-"* ]] ; then
update-alternatives --install "/opt/rocm" "rocm" "@CPACK_PACKAGING_INSTALL_PREFIX@" "$altscore"
fi
for loc in "/usr/share/modules/modulefiles" "/usr/local/Modules/modulefiles" "/usr/share/Modules/modulefiles" "/usr/share/Modules/3.2.10/modulefiles"
do
if [ -d "$loc" ]
then
mkdir -p "$loc/rocm"
if [[ ${ID_LIKE:-$ID} == "debian" ]] ; then
update-alternatives --install "$loc/rocm/@ROCM_VERSION@" "rocmmod@ROCM_VERSION@" "@CPACK_PACKAGING_INSTALL_PREFIX@/@CMAKE_INSTALL_LIBDIR@/rocmmod" "$altscore"
else
update-alternatives --install "$loc/rocm/@ROCM_VERSION@" "rocmmod@ROCM_VERSION@" "$RPM_INSTALL_PREFIX0/@CMAKE_INSTALL_LIBDIR@/rocmmod" "$altscore"
fi
break;
fi
done
true
}
if [ -e /etc/os-release ] && source /etc/os-release && [[ ${ID_LIKE:-$ID} == "debian" ]]
then
case "$1" in
(configure)
do_update_alternatives
;;
(abort-upgrade|abort-remove|abort-deconfigure)
echo "$1"
;;
(*)
exit 0
;;
esac
else
do_update_alternatives
fi