2021-03-24 15:25:00 -07:00
|
|
|
#!/bin/bash
|
2025-05-06 17:59:47 -05:00
|
|
|
#
|
|
|
|
|
# Copyright (C) Advanced Micro Devices. All rights reserved.
|
|
|
|
|
#
|
|
|
|
|
# Permission is hereby granted, free of charge, to any person obtaining a copy of
|
|
|
|
|
# this software and associated documentation files (the "Software"), to deal in
|
|
|
|
|
# the Software without restriction, including without limitation the rights to
|
|
|
|
|
# use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
|
|
|
|
# the Software, and to permit persons to whom the Software is furnished to do so,
|
|
|
|
|
# subject to the following conditions:
|
|
|
|
|
#
|
|
|
|
|
# The above copyright notice and this permission notice shall be included in all
|
|
|
|
|
# copies or substantial portions of the Software.
|
|
|
|
|
#
|
|
|
|
|
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
|
|
|
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
|
|
|
|
# FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
|
|
|
|
# COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
|
|
|
|
# IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
|
|
|
|
# CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
|
|
|
|
|
|
|
|
echo "Removing AMDSMI LIB Packages..."
|
2024-09-03 16:45:56 -05:00
|
|
|
|
|
|
|
|
# Other prerm actions
|
2021-03-24 15:25:00 -07:00
|
|
|
rm_ldconfig() {
|
|
|
|
|
# left-hand term originates from ENABLE_LDCONFIG = ON/OFF at package build
|
|
|
|
|
if [ "@ENABLE_LDCONFIG@" == "ON" ]; then
|
2023-08-17 01:33:12 -05:00
|
|
|
rm -f /etc/ld.so.conf.d/x86_64-libamd_smi_lib.conf
|
2021-03-24 15:25:00 -07:00
|
|
|
ldconfig
|
|
|
|
|
fi
|
|
|
|
|
}
|
|
|
|
|
|
2024-09-03 16:45:56 -05:00
|
|
|
|
2023-11-05 01:22:20 -06:00
|
|
|
rm_leftovers() {
|
2023-09-15 03:04:50 -05:00
|
|
|
# remove pyc files generated by python
|
2024-09-20 14:17:20 -04:00
|
|
|
rm -rf "@CPACK_PACKAGING_INSTALL_PREFIX@/@CMAKE_INSTALL_LIBEXECDIR@/amdsmi_cli/__pycache__"
|
2023-11-16 12:18:17 -06:00
|
|
|
rm -rf "@CPACK_PACKAGING_INSTALL_PREFIX@/@SHARE_INSTALL_PREFIX@/amdsmi/__pycache__"
|
2023-11-05 01:22:20 -06:00
|
|
|
|
2023-11-16 12:18:17 -06:00
|
|
|
# remove build and egg files
|
|
|
|
|
rm -rf "@CPACK_PACKAGING_INSTALL_PREFIX@/@SHARE_INSTALL_PREFIX@/amdsmi.egg-info"
|
|
|
|
|
rm -rf "@CPACK_PACKAGING_INSTALL_PREFIX@/@SHARE_INSTALL_PREFIX@/build"
|
2023-11-05 01:22:20 -06:00
|
|
|
|
2023-11-16 12:18:17 -06:00
|
|
|
# remove leftover doc files
|
|
|
|
|
if test -e "@CPACK_PACKAGING_INSTALL_PREFIX@/@SHARE_INSTALL_PREFIX@/../doc/amd_smi*"; then
|
|
|
|
|
rm -rf "@CPACK_PACKAGING_INSTALL_PREFIX@/@SHARE_INSTALL_PREFIX@/../doc/amd_smi*"
|
|
|
|
|
fi
|
2022-03-23 10:28:48 -04:00
|
|
|
}
|
|
|
|
|
|
2023-05-01 19:08:47 -05:00
|
|
|
rm_logFolder() {
|
2023-09-21 19:10:41 -05:00
|
|
|
rm -rf /var/log/amd_smi_lib
|
2023-05-01 19:08:47 -05:00
|
|
|
}
|
|
|
|
|
|
2024-09-03 16:45:56 -05:00
|
|
|
|
|
|
|
|
rm_rocm_tests_dir(){
|
|
|
|
|
if [ -d "@CPACK_PACKAGING_INSTALL_PREFIX@/share/amd_smi/tests/" ]; then
|
|
|
|
|
rm -rf "@CPACK_PACKAGING_INSTALL_PREFIX@/share/amd_smi/tests/"
|
|
|
|
|
echo "Removed ROCm tests directory."
|
|
|
|
|
fi
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2023-05-01 19:08:47 -05:00
|
|
|
return_logrotateToOrigConfig() {
|
2023-09-21 19:10:41 -05:00
|
|
|
local logrotateConfFile=/etc/logrotate.d/amd_smi.conf
|
2023-07-20 15:20:36 -05:00
|
|
|
if [ -f $logrotateConfFile ]; then
|
2023-09-15 02:59:28 -05:00
|
|
|
rm -rf "$logrotateConfFile"
|
2023-05-01 19:08:47 -05:00
|
|
|
fi
|
|
|
|
|
if [ -f /etc/cron.hourly/logrotate ]; then
|
2023-09-15 02:59:28 -05:00
|
|
|
mv /etc/cron.hourly/logrotate /etc/cron.daily/logrotate
|
2023-05-01 19:08:47 -05:00
|
|
|
fi
|
|
|
|
|
if [ -f /lib/systemd/system/logrotate.timer.backup ]; then
|
2023-09-15 02:59:28 -05:00
|
|
|
cp /lib/systemd/system/logrotate.timer.backup /lib/systemd/system/logrotate.timer
|
|
|
|
|
rm -rf /lib/systemd/system/logrotate.timer.backup
|
|
|
|
|
systemctl reenable --now logrotate.timer
|
2023-05-01 19:08:47 -05:00
|
|
|
fi
|
|
|
|
|
}
|
|
|
|
|
|
2023-10-25 18:52:46 -05:00
|
|
|
rm_python_lib() {
|
|
|
|
|
# get python version
|
2023-10-31 01:45:38 -05:00
|
|
|
local python3_minor_version
|
|
|
|
|
python3_minor_version=$(python3 -c 'import sys;print(sys.version_info.minor)')
|
2023-10-25 18:52:46 -05:00
|
|
|
if [ $? -ne 0 ]; then
|
|
|
|
|
echo "[WARNING] Could not determine python version. "\
|
|
|
|
|
"AMD-SMI python library will not be uninstalled."
|
|
|
|
|
return
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
# check if python version is supported
|
|
|
|
|
if [ "$python3_minor_version" -lt 6 ]; then
|
2023-10-31 01:45:38 -05:00
|
|
|
echo "[WARNING] AMD-SMI python library is not supported on python version 3.$python3_minor_version. "\
|
2023-10-25 18:52:46 -05:00
|
|
|
"AMD-SMI python library will not be uninstalled."
|
|
|
|
|
return
|
|
|
|
|
fi
|
|
|
|
|
|
2023-11-05 01:22:20 -06:00
|
|
|
# Remove old python library
|
|
|
|
|
local pip_list_output
|
2023-12-14 23:15:03 -06:00
|
|
|
pip_list_output=$(python3 -m pip list --format=columns --disable-pip-version-check)
|
2023-11-05 01:22:20 -06:00
|
|
|
# check pip list output for amdsmi
|
|
|
|
|
if [[ $pip_list_output == *"amdsmi"* ]]; then
|
2023-11-16 12:18:17 -06:00
|
|
|
PIP_ROOT_USER_ACTION=ignore PIP_BREAK_SYSTEM_PACKAGES=1 python3 -m pip uninstall amdsmi --yes --quiet --disable-pip-version-check
|
2023-11-05 01:22:20 -06:00
|
|
|
fi
|
|
|
|
|
|
2023-12-14 23:15:03 -06:00
|
|
|
pip_list_output=$(python3 -m pip list --format=columns --disable-pip-version-check)
|
2023-11-05 01:22:20 -06:00
|
|
|
# check pip list output for amdsmi
|
|
|
|
|
if [[ $pip_list_output == *"amdsmi"* ]]; then
|
|
|
|
|
echo "[WARNING] AMD-SMI python library (amdsmi) is still installed in pip. "\
|
2023-10-25 18:52:46 -05:00
|
|
|
"Check post install to ensure version is correct"
|
2023-11-16 12:18:17 -06:00
|
|
|
else
|
|
|
|
|
echo "Removed AMD-SMI python library (amdsmi)..."
|
2023-10-25 18:52:46 -05:00
|
|
|
fi
|
|
|
|
|
}
|
2023-07-20 15:20:36 -05:00
|
|
|
|
2023-11-05 01:22:20 -06:00
|
|
|
|
2021-03-24 15:25:00 -07:00
|
|
|
case "$1" in
|
2022-02-24 09:59:02 -05:00
|
|
|
( remove | upgrade)
|
2023-09-24 20:16:06 -05:00
|
|
|
# remove old gpuv-smi symlink
|
|
|
|
|
rm -f @CPACK_PACKAGING_INSTALL_PREFIX@/bin/gpuv-smi &> /dev/null
|
2025-05-06 17:59:47 -05:00
|
|
|
echo "Removing AMDSMI Lib Packages..."
|
2023-11-05 01:22:20 -06:00
|
|
|
rm_python_lib
|
2025-05-06 17:59:47 -05:00
|
|
|
echo "python library removed"
|
2021-03-24 15:25:00 -07:00
|
|
|
rm_ldconfig
|
2025-05-06 17:59:47 -05:00
|
|
|
echo "ldconfig removed"
|
2023-11-05 01:22:20 -06:00
|
|
|
rm_leftovers
|
2025-05-06 17:59:47 -05:00
|
|
|
echo "leftovers removed"
|
2023-05-01 19:08:47 -05:00
|
|
|
rm_logFolder
|
2025-05-06 17:59:47 -05:00
|
|
|
echo "log folder removed"
|
2024-09-03 16:45:56 -05:00
|
|
|
rm_rocm_tests_dir
|
2025-05-06 17:59:47 -05:00
|
|
|
echo "rocm tests directory removed"
|
2023-05-01 19:08:47 -05:00
|
|
|
return_logrotateToOrigConfig
|
2025-05-06 17:59:47 -05:00
|
|
|
echo "logrotate configuration restored"
|
2021-03-24 15:25:00 -07:00
|
|
|
;;
|
|
|
|
|
( purge )
|
|
|
|
|
;;
|
|
|
|
|
( * )
|
|
|
|
|
exit 0
|
|
|
|
|
;;
|
|
|
|
|
esac
|