e0a1a6ca96
Upgraded python3-yaml into a dependency; needed for cli Added checks before uninstalling amdsmi system Made argcomplete activation only for installing user Corrected returns outside of function to exit Removed returns if python3 library install fails Signed-off-by: Maisam Arif <maisarif@amd.com> Change-Id: I299dc01e07029b255a3469fd63fdc8ffec943828
90 righe
2.9 KiB
Bash
Executable File
90 righe
2.9 KiB
Bash
Executable File
#!/bin/bash
|
|
|
|
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 leftover doc files
|
|
rm -rf @CPACK_PACKAGING_INSTALL_PREFIX@/@SHARE_INSTALL_PREFIX@/../doc/amd_smi*
|
|
rm -rf @CPACK_PACKAGING_INSTALL_PREFIX@/@SHARE_INSTALL_PREFIX@/
|
|
|
|
# remove leftover libs
|
|
rm -rf @CPACK_PACKAGING_INSTALL_PREFIX@/@CMAKE_INSTALL_LIBDIR@/libamd_smi.so*
|
|
}
|
|
|
|
rm_logFolder() {
|
|
rm -rf /var/log/amd_smi_lib
|
|
}
|
|
|
|
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() {
|
|
echo "Removing AMD-SMI python library (amdsmi)..."
|
|
# 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 --disable-pip-version-check)
|
|
# check pip list output for amdsmi
|
|
if [[ $pip_list_output == *"amdsmi"* ]]; then
|
|
local PREVIOUS_PIP_ROOT_ACTION="$PIP_ROOT_USER_ACTION"
|
|
export PIP_ROOT_USER_ACTION=ignore
|
|
|
|
echo "Detected AMD-SMI python library (amdsmi)..."
|
|
python3 -m pip uninstall amdsmi --yes --quiet --disable-pip-version-check
|
|
echo "Removed AMD-SMI python library (amdsmi)..."
|
|
|
|
unset PIP_ROOT_USER_ACTION
|
|
export PIP_ROOT_USER_ACTION="$PREVIOUS_PIP_ROOT_ACTION"
|
|
fi
|
|
|
|
local pip_list_output
|
|
pip_list_output=$(python3 -m pip list --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"
|
|
return
|
|
fi
|
|
echo "Removed AMD-SMI python library (amdsmi)..."
|
|
}
|
|
|
|
|
|
if [ "$1" -le 1 ]; then
|
|
# perform the below actions for rpm remove($1=0) or upgrade($1=1) operations
|
|
# remove old gpuv-smi symlink
|
|
rm -f @CPACK_PACKAGING_INSTALL_PREFIX@/bin/gpuv-smi &> /dev/null
|
|
rm_python_lib
|
|
rm_leftovers
|
|
rm_logFolder
|
|
return_logrotateToOrigConfig
|
|
fi
|