Files
Galantsev, Dmitrii 51088382c8 [SWDEV-529762] CMAKE - Fix lintian issues (#325)
Change-Id: Ide3563a876cb530d0e80676e78f36f18a233a3ba

Signed-off-by: Galantsev, Dmitrii <dmitrii.galantsev@amd.com>

[ROCm/amdsmi commit: bd82e881f5]
2025-05-06 17:59:47 -05:00

137 строки
4.6 KiB
Bash
Исполняемый файл

#!/bin/bash
#
# 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..."
# Other prerm actions
rm_ldconfig() {
# left-hand term originates from ENABLE_LDCONFIG = ON/OFF at package build
if [ "@ENABLE_LDCONFIG@" == "ON" ]; then
rm -f /etc/ld.so.conf.d/x86_64-libamd_smi_lib.conf
ldconfig
fi
}
rm_leftovers() {
# remove pyc files generated by python
rm -rf "@CPACK_PACKAGING_INSTALL_PREFIX@/@CMAKE_INSTALL_LIBEXECDIR@/amdsmi_cli/__pycache__"
rm -rf "@CPACK_PACKAGING_INSTALL_PREFIX@/@SHARE_INSTALL_PREFIX@/amdsmi/__pycache__"
# 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"
# 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
}
rm_logFolder() {
rm -rf /var/log/amd_smi_lib
}
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
}
return_logrotateToOrigConfig() {
local logrotateConfFile=/etc/logrotate.d/amd_smi.conf
if [ -f $logrotateConfFile ]; then
rm -rf "$logrotateConfFile"
fi
if [ -f /etc/cron.hourly/logrotate ]; then
mv /etc/cron.hourly/logrotate /etc/cron.daily/logrotate
fi
if [ -f /lib/systemd/system/logrotate.timer.backup ]; then
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
fi
}
rm_python_lib() {
# get python version
local python3_minor_version
python3_minor_version=$(python3 -c 'import sys;print(sys.version_info.minor)')
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
echo "[WARNING] AMD-SMI python library is not supported on python version 3.$python3_minor_version. "\
"AMD-SMI python library will not be uninstalled."
return
fi
# Remove old python library
local pip_list_output
pip_list_output=$(python3 -m pip list --format=columns --disable-pip-version-check)
# check pip list output for amdsmi
if [[ $pip_list_output == *"amdsmi"* ]]; then
PIP_ROOT_USER_ACTION=ignore PIP_BREAK_SYSTEM_PACKAGES=1 python3 -m pip uninstall amdsmi --yes --quiet --disable-pip-version-check
fi
pip_list_output=$(python3 -m pip list --format=columns --disable-pip-version-check)
# check pip list output for amdsmi
if [[ $pip_list_output == *"amdsmi"* ]]; then
echo "[WARNING] AMD-SMI python library (amdsmi) is still installed in pip. "\
"Check post install to ensure version is correct"
else
echo "Removed AMD-SMI python library (amdsmi)..."
fi
}
case "$1" in
( remove | upgrade)
# remove old gpuv-smi symlink
rm -f @CPACK_PACKAGING_INSTALL_PREFIX@/bin/gpuv-smi &> /dev/null
echo "Removing AMDSMI Lib Packages..."
rm_python_lib
echo "python library removed"
rm_ldconfig
echo "ldconfig removed"
rm_leftovers
echo "leftovers removed"
rm_logFolder
echo "log folder removed"
rm_rocm_tests_dir
echo "rocm tests directory removed"
return_logrotateToOrigConfig
echo "logrotate configuration restored"
;;
( purge )
;;
( * )
exit 0
;;
esac