Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions build_tools/packaging/linux/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2487,6 +2487,7 @@
"Vendor": "Advanced Micro Devices, Inc",
"Homepage": "https://github.com/ROCm/rocm-libraries",
"Metapackage": "True",
"Postinstall": "True",
"Gfxarch": "True"
},
{
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
#!/bin/bash

is_debian_like() {
local id_like="$1"
case " $id_like " in
(*" debian "*|*" ubuntu "*)
return 0
;;
(*)
return 1
;;
esac
}

do_update_alternatives(){
# skip update if program doesn't exist
command -v update-alternatives >/dev/null || return 0
local binaries 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))

binaries=( amdclang amdclang++ amdclang-cl amdclang-cpp amdflang amdlld )

{% if target == "deb" %}
PKG_INSTALL_PREFIX={{ install_prefix }}
{% else %}
PKG_INSTALL_PREFIX="$RPM_INSTALL_PREFIX0"
{% endif %}

for i in "${binaries[@]}"
do
# No obvious recover strategy if things fail
# No manual or other slave pages to install
if [ -e $PKG_INSTALL_PREFIX/bin/"$i" ]
then
update-alternatives --install /usr/bin/"$i" "$i" \
$PKG_INSTALL_PREFIX/bin/"$i" "$altscore"
else
echo "$PKG_INSTALL_PREFIX/bin/$i not found, but that is OK" >&2
fi
done
true
}

if [ -e /etc/os-release ] && source /etc/os-release && is_debian_like "${ID_LIKE:-$ID}"
then
case "$1" in
(configure)
do_update_alternatives
;;
(abort-upgrade|abort-remove|abort-deconfigure)
echo "$1"
;;
(*)
exit 0
;;
esac
else
do_update_alternatives
fi
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
#!/bin/bash

binaries=( amdclang amdclang++ amdclang-cl amdclang-cpp amdflang amdlld )

is_debian_like() {
local id_like="$1"
case " $id_like " in
(*" debian "*|*" ubuntu "*)
return 0
;;
(*)
return 1
;;
esac
}

do_update_alternatives(){
# skip update if program doesn't exist
command -v update-alternatives >/dev/null || return 0

{% if target == "deb" %}
PKG_INSTALL_PREFIX={{ install_prefix }}
{% else %}
PKG_INSTALL_PREFIX="$RPM_INSTALL_PREFIX0"
{% endif %}

for i in "${binaries[@]}"
do
update-alternatives --remove "$i" \
"$PKG_INSTALL_PREFIX/bin/$i"
done
}

if [ -e /etc/os-release ] && source /etc/os-release && is_debian_like "${ID_LIKE:-$ID}"
then
case "$1" in
(remove|upgrade)
do_update_alternatives
;;
(purge)
# nothing to do
;;
(*)
exit 0
;;
esac
else
do_update_alternatives
fi
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ do_update_alternatives(){
# previous patch level is small.
altscore=$((altscore*1000000+(now-1600000000)/60))

binaries=( hipcc rocminfo amd-smi rocm_agent_enumerator rocm-smi rocprofv3 )
binaries=( hipcc hipcc_cmake_linker_helper hipconfig hipdemangleatp hipify-clang roc-obj roc-obj-extract roc-obj-ls rocminfo amd-smi rocm_agent_enumerator rocm-smi rocprofv3 rocprofv3-avail rocgdb )

{% if target == "deb" %}
PKG_INSTALL_PREFIX={{ install_prefix }}
Expand All @@ -61,10 +61,11 @@ do_update_alternatives(){
update-alternatives --install "/opt/rocm/lib" "rocm-lib" "$PKG_INSTALL_PREFIX/lib" "$altscore"
update-alternatives --install "/opt/rocm/include" "rocm-include" "$PKG_INSTALL_PREFIX/include" "$altscore"

# Install /opt/rocm/llvm, /opt/rocm/amdgcn, and /opt/rocm/libexec soft links
# Install /opt/rocm/llvm, /opt/rocm/amdgcn, /opt/rocm/libexec, and /opt/rocm/share soft links
update-alternatives --install "/opt/rocm/llvm" "rocm-llvm" "$PKG_INSTALL_PREFIX/llvm" "$altscore"
update-alternatives --install "/opt/rocm/amdgcn" "rocm-amdgcn" "$PKG_INSTALL_PREFIX/amdgcn" "$altscore"
update-alternatives --install "/opt/rocm/libexec" "rocm-libexec" "$PKG_INSTALL_PREFIX/libexec" "$altscore"
update-alternatives --install "/opt/rocm/share" "rocm-share" "$PKG_INSTALL_PREFIX/share" "$altscore"

for i in "${binaries[@]}"
do
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/bin/bash

binaries=( hipcc rocminfo amd-smi rocm_agent_enumerator rocm-smi rocprofv3 )
binaries=( hipcc hipcc_cmake_linker_helper hipconfig hipdemangleatp hipify-clang roc-obj roc-obj-extract roc-obj-ls rocminfo amd-smi rocm_agent_enumerator rocm-smi rocprofv3 rocprofv3-avail rocgdb )

is_debian_like() {
local id_like="$1"
Expand Down Expand Up @@ -39,10 +39,11 @@ do_update_alternatives(){
update-alternatives --remove "rocm-lib" "$PKG_INSTALL_PREFIX/lib"
update-alternatives --remove "rocm-include" "$PKG_INSTALL_PREFIX/include"

# Remove /opt/rocm/llvm, /opt/rocm/amdgcn, and /opt/rocm/libexec soft links
# Remove /opt/rocm/llvm, /opt/rocm/amdgcn, /opt/rocm/libexec, and /opt/rocm/share soft links
update-alternatives --remove "rocm-llvm" "$PKG_INSTALL_PREFIX/llvm"
update-alternatives --remove "rocm-amdgcn" "$PKG_INSTALL_PREFIX/amdgcn"
update-alternatives --remove "rocm-libexec" "$PKG_INSTALL_PREFIX/libexec"
update-alternatives --remove "rocm-share" "$PKG_INSTALL_PREFIX/share"
}

if [ -e /etc/os-release ] && source /etc/os-release && is_debian_like "${ID_LIKE:-$ID}"
Expand Down
Loading