From 9bbd32046e13ca765aa2ce9f51558f2c83d0aa31 Mon Sep 17 00:00:00 2001 From: Maisam Arif Date: Tue, 12 Mar 2024 15:35:31 -0500 Subject: [PATCH] SWDEV-449314 - Added pyyaml check before installing via pip Signed-off-by: Maisam Arif Change-Id: Ie6d0d664e74b47c1efce6e6fac19ee4a1bf0d5eb [ROCm/amdsmi commit: 25c8ff6c2af92e363723ab3a17923399c516d0fa] --- projects/amdsmi/DEBIAN/postinst.in | 15 +++++++++++---- projects/amdsmi/RPM/post.in | 15 +++++++++++---- 2 files changed, 22 insertions(+), 8 deletions(-) diff --git a/projects/amdsmi/DEBIAN/postinst.in b/projects/amdsmi/DEBIAN/postinst.in index d991cf6b2a..f0d58d529b 100755 --- a/projects/amdsmi/DEBIAN/postinst.in +++ b/projects/amdsmi/DEBIAN/postinst.in @@ -143,13 +143,20 @@ do_install_amdsmi_python_lib() { local pip_version pip_version=$(python3 -m pip --version | grep -Eo '^[^\ ]+ ([0-9]+)' | grep -Eo '[0-9]+$') if [[ "$pip_version" -lt 19 ]]; then - echo "Detected ancient pip version ($pip_version)... Upgrading..." - python3 -m pip install --upgrade pip --quiet --disable-pip-version-check + echo "Detected ancient pip version ($pip_version)... Upgrading..." + python3 -m pip install --upgrade pip --quiet --disable-pip-version-check fi unset pip_version - # install PyYAML dependency - python3 -m pip install 'PyYAML>=5.1' --quiet --disable-pip-version-check --ignore-installed + # Check PyYAML dependency + local pyyaml_version + pyyaml_version=$(pip show pyyaml | grep -Po '(?<=Version: )[0-9]') + if [[ "$pyyaml_version" -lt 5 ]]; then + echo "Detected ancient pyyaml version ($pyyaml_version)... Upgrading..." + python3 -m pip install 'PyYAML>=5.1' --quiet --disable-pip-version-check --ignore-installed + fi + unset pyyaml_version + # install python library at @CPACK_PACKAGING_INSTALL_PREFIX@/@SHARE_INSTALL_PREFIX@/amdsmi local python_lib_path=@CPACK_PACKAGING_INSTALL_PREFIX@/@SHARE_INSTALL_PREFIX@ python3 -m pip install "$python_lib_path" --quiet --disable-pip-version-check diff --git a/projects/amdsmi/RPM/post.in b/projects/amdsmi/RPM/post.in index a58a5f4e8f..5b5fc9595d 100755 --- a/projects/amdsmi/RPM/post.in +++ b/projects/amdsmi/RPM/post.in @@ -142,13 +142,20 @@ do_install_amdsmi_python_lib() { local pip_version pip_version=$(python3 -m pip --version | grep -Eo '^[^\ ]+ ([0-9]+)' | grep -Eo '[0-9]+$') if [[ "$pip_version" -lt 19 ]]; then - echo "Detected ancient pip version ($pip_version)... Upgrading..." - python3 -m pip install --upgrade pip --quiet --disable-pip-version-check + echo "Detected ancient pip version ($pip_version)... Upgrading..." + python3 -m pip install --upgrade pip --quiet --disable-pip-version-check fi unset pip_version - # install PyYAML dependency - python3 -m pip install 'PyYAML>=5.1' --quiet --disable-pip-version-check --ignore-installed + # Check PyYAML dependency + local pyyaml_version + pyyaml_version=$(pip show pyyaml | grep -Po '(?<=Version: )[0-9]') + if [[ "$pyyaml_version" -lt 5 ]]; then + echo "Detected ancient pyyaml version ($pyyaml_version)... Upgrading..." + python3 -m pip install 'PyYAML>=5.1' --quiet --disable-pip-version-check --ignore-installed + fi + unset pyyaml_version + # install python library at @CPACK_PACKAGING_INSTALL_PREFIX@/@SHARE_INSTALL_PREFIX@/amdsmi local python_lib_path=@CPACK_PACKAGING_INSTALL_PREFIX@/@SHARE_INSTALL_PREFIX@ python3 -m pip install "$python_lib_path" --quiet --disable-pip-version-check