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
170 lines
6.2 KiB
Bash
Executable File
170 lines
6.2 KiB
Bash
Executable File
#!/bin/bash
|
|
|
|
do_configureLogrotate() {
|
|
local packageName="amd-smi-lib"
|
|
local logPath=/var/log/amd_smi_lib
|
|
local logFile="${logPath}/AMD-SMI-lib.log"
|
|
local logrotateConfFile=/etc/logrotate.d/amd_smi.conf
|
|
|
|
mkdir -p "${logPath}"
|
|
touch "${logFile}"
|
|
chmod -R a+rw "${logPath}"
|
|
chmod a+rw "${logFile}"
|
|
|
|
if ! command -v logrotate &>/dev/null; then
|
|
echo "[WARNING] Detected logrotate is not installed."\
|
|
"$packageName logs (when turned on) will not rotate properly."
|
|
return
|
|
fi
|
|
|
|
if [ ! -f $logrotateConfFile ]; then
|
|
touch "${logrotateConfFile}"
|
|
chmod 644 "${logrotateConfFile}" # root r/w, all others read
|
|
# AMD SMI logging rotation, rotates files using root user/group
|
|
# Hourly logrotation check
|
|
# Only rotates if size grew larger than 1MB
|
|
# Max of 4 rotation files, oldest will be removed
|
|
# Rotated files use date extension of ex. AMD-SMI-lib.log.2023-05-09_16:51:42
|
|
cat << EOF > "${logrotateConfFile}"
|
|
${logFile} {
|
|
su root root
|
|
hourly
|
|
missingok
|
|
notifempty
|
|
rotate 4
|
|
size 1M
|
|
copytruncate
|
|
dateext
|
|
dateformat .%%Y-%%m-%%d_%H:%%M:%%S
|
|
}
|
|
EOF
|
|
# Fix for % S argument not found (now we escape with %%)
|
|
# issue was RPM build thought we were using macros
|
|
# https://gitlab.kitware.com/cmake/cmake/-/issues/22965
|
|
# https://rpm-software-management.github.io/rpm/manual/spec.html
|
|
sed -i s/%%/%/g "${logrotateConfFile}"
|
|
# workaround: remove extra 'OURCE' text
|
|
# from amd_smi.conf. Unsure if CMAKE,
|
|
# bash, or here document
|
|
# issue (only seen on RHEL 8.7)
|
|
sed -i s/OURCE//g "${logrotateConfFile}"
|
|
fi
|
|
# NOTE: we deliberately do NOT touch /lib/systemd/system/logrotate.timer
|
|
# or move /etc/cron.daily/logrotate to /etc/cron.hourly. Those are
|
|
# system-wide knobs shared with every other package that uses
|
|
# logrotate (rsyslog, apt, nginx, ...) and mutating them on our
|
|
# behalf changes rotation cadence for unrelated services.
|
|
# The drop-in above already declares its own `hourly` directive, so
|
|
# whatever cadence the distro runs logrotate at, our log will only
|
|
# rotate when the size threshold is met.
|
|
}
|
|
|
|
do_ldconfig() {
|
|
# left-hand term originates from ENABLE_LDCONFIG = ON/OFF at package build
|
|
if [ "@ENABLE_LDCONFIG@" == "ON" ]; then
|
|
echo $RPM_INSTALL_PREFIX0/@CMAKE_INSTALL_LIBDIR@ > /etc/ld.so.conf.d/x86_64-libamd_smi_lib.conf
|
|
ldconfig
|
|
fi
|
|
}
|
|
|
|
do_install_amdsmi_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 installed."
|
|
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 installed."
|
|
return
|
|
fi
|
|
|
|
local PREVIOUS_PIP_ROOT_USER_ACTION="$PIP_ROOT_USER_ACTION"
|
|
export PIP_ROOT_USER_ACTION=ignore
|
|
# python3.11 requires --break-system-packages
|
|
local PREVIOUS_PIP_BREAK_SYSTEM_PACKAGES="$PIP_BREAK_SYSTEM_PACKAGES"
|
|
export PIP_BREAK_SYSTEM_PACKAGES=1
|
|
|
|
|
|
# Remove old python library
|
|
local amdsmi_pip_list_output
|
|
amdsmi_pip_list_output=$(python3 -m pip list --format=columns --disable-pip-version-check)
|
|
# check pip list output for amdsmi
|
|
if [[ $amdsmi_pip_list_output == *"amdsmi"* ]]; then
|
|
echo "Detected old AMD-SMI python library (amdsmi)..."
|
|
python3 -m pip uninstall amdsmi --yes --quiet --disable-pip-version-check
|
|
echo "Removed old AMD-SMI python library (amdsmi)..."
|
|
fi
|
|
|
|
# static builds don't include python lib
|
|
if [ "@BUILD_SHARED_LIBS@" != "ON" ]; then
|
|
return
|
|
fi
|
|
|
|
check_and_install_amdsmi() {
|
|
local setuptools_version
|
|
setuptools_version=$(python3 -c 'import setuptools; print(setuptools.__version__)')
|
|
if [ $? -ne 0 ]; then
|
|
echo "[WARNING] Could not determine setuptools version. "\
|
|
"AMD-SMI python library will not be installed."
|
|
return
|
|
fi
|
|
|
|
# install python library at $RPM_INSTALL_PREFIX0/@SHARE_INSTALL_PREFIX@/amdsmi
|
|
local python_lib_path=$RPM_INSTALL_PREFIX0/@SHARE_INSTALL_PREFIX@
|
|
local amdsmi_python_lib_path="$python_lib_path"
|
|
local amdsmi_setup_py_path="$python_lib_path/setup.py"
|
|
|
|
# Decide installation method based on setuptools version
|
|
if [[ "$(printf '%s\n' "$setuptools_version" "28.5" | sort -V | head -n1)" == "$setuptools_version" ]]; then
|
|
echo "[WARNING] Setuptools version is less than 28.5. AMD-SMI will not be installed."
|
|
elif [[ "$(printf '%s\n' "$setuptools_version" "41.0.1" | sort -V | head -n1)" != "41.0.1" ]]; then
|
|
echo "Using setup.py for installation due to setuptools version $setuptools_version"
|
|
cd $amdsmi_python_lib_path
|
|
python3 setup.py install
|
|
cd -
|
|
else
|
|
echo "Using pyproject.toml for installation due to setuptools version $setuptools_version"
|
|
python3 -m pip install "$amdsmi_python_lib_path" --quiet --disable-pip-version-check --no-build-isolation --no-index
|
|
fi
|
|
}
|
|
|
|
# Call the function
|
|
check_and_install_amdsmi
|
|
|
|
export PIP_ROOT_USER_ACTION="$PREVIOUS_PIP_ROOT_USER_ACTION"
|
|
export PIP_BREAK_SYSTEM_PACKAGES="$PREVIOUS_PIP_BREAK_SYSTEM_PACKAGES"
|
|
|
|
# only try to activate argcomplete if such command exists
|
|
# python3-argcomplete is recommended but optional, we handle its absence gracefully
|
|
if command -v activate-global-python-argcomplete &>/dev/null; then
|
|
activate-global-python-argcomplete 2>/dev/null || {
|
|
echo "[INFO] Bash completion activation skipped. You can manually enable it with: activate-global-python-argcomplete"
|
|
}
|
|
else
|
|
# try older argcomplete3 version
|
|
if command -v activate-global-python-argcomplete3 &>/dev/null; then
|
|
activate-global-python-argcomplete3 2>/dev/null || {
|
|
echo "[INFO] Bash completion activation skipped. You can manually enable it with: activate-global-python-argcomplete3"
|
|
}
|
|
else
|
|
echo "[WARNING] Could not find argcomplete activation command. "\
|
|
"Argument completion will not work. Install python3-argcomplete package to enable it."
|
|
fi
|
|
fi
|
|
}
|
|
|
|
|
|
# post install or upgrade, $i is 1 or 2 -> do these actions
|
|
if [ "$1" -ge 1 ]; then
|
|
do_install_amdsmi_python_lib
|
|
do_ldconfig
|
|
do_configureLogrotate || exit 0
|
|
fi
|