From 26ad77dace60cf397a5fc1985ef3174f14609949 Mon Sep 17 00:00:00 2001 From: "Galantsev, Dmitrii" Date: Thu, 11 Aug 2022 19:34:40 -0500 Subject: [PATCH] Remove python pyc file before uninstall I6520b51aac34060b5b90f94a016cec1827a4973f happens after uninstall, which leaves a dangling directory under /opt/rocm/libexec/rocm_smi. Removing __pycache__ before uninstall fixes the issue. Signed-off-by: Galantsev, Dmitrii Change-Id: I695bd085d4a43b678b563b4c35f6d2e8ddfa7d7c [ROCm/rocm_smi_lib commit: cd11d7530b19f0ae74537521f4ddfbf5e7934bcf] --- projects/rocm-smi-lib/CMakeLists.txt | 2 ++ projects/rocm-smi-lib/RPM/postun.in | 3 --- projects/rocm-smi-lib/RPM/preun.in | 5 +++++ 3 files changed, 7 insertions(+), 3 deletions(-) create mode 100755 projects/rocm-smi-lib/RPM/preun.in diff --git a/projects/rocm-smi-lib/CMakeLists.txt b/projects/rocm-smi-lib/CMakeLists.txt index 3b778e174f..1c3446fd4e 100755 --- a/projects/rocm-smi-lib/CMakeLists.txt +++ b/projects/rocm-smi-lib/CMakeLists.txt @@ -253,8 +253,10 @@ set(CPACK_PACKAGE_VERSION "${CPACK_PACKAGE_VERSION_MAJOR}.${CPACK_PACKAGE_VERSIO ## Process the Rpm install/remove scripts to update the CPACK variables configure_file ( "${CMAKE_CURRENT_SOURCE_DIR}/RPM/post.in" RPM/post @ONLY ) +configure_file ( "${CMAKE_CURRENT_SOURCE_DIR}/RPM/preun.in" RPM/preun @ONLY ) configure_file ( "${CMAKE_CURRENT_SOURCE_DIR}/RPM/postun.in" RPM/postun @ONLY ) set ( CPACK_RPM_POST_INSTALL_SCRIPT_FILE "${CMAKE_CURRENT_BINARY_DIR}/RPM/post" ) +set ( CPACK_RPM_PRE_UNINSTALL_SCRIPT_FILE "${CMAKE_CURRENT_BINARY_DIR}/RPM/preun" ) set ( CPACK_RPM_POST_UNINSTALL_SCRIPT_FILE "${CMAKE_CURRENT_BINARY_DIR}/RPM/postun" ) #Set the names now using CPACK utility diff --git a/projects/rocm-smi-lib/RPM/postun.in b/projects/rocm-smi-lib/RPM/postun.in index 72f4c565e2..d54cd9b2ea 100755 --- a/projects/rocm-smi-lib/RPM/postun.in +++ b/projects/rocm-smi-lib/RPM/postun.in @@ -4,6 +4,3 @@ if [ $1 -le 1 ] && [ "@ENABLE_LDCONFIG@" == "ON" ]; then rm -f /etc/ld.so.conf.d/x86_64-librocm_smi_lib.conf ldconfig fi - -# remove pyc file generated by python -rm -rf @CPACK_PACKAGING_INSTALL_PREFIX@/@CMAKE_INSTALL_LIBEXECDIR@/rocm_smi/__pycache__ diff --git a/projects/rocm-smi-lib/RPM/preun.in b/projects/rocm-smi-lib/RPM/preun.in new file mode 100755 index 0000000000..33acd7f401 --- /dev/null +++ b/projects/rocm-smi-lib/RPM/preun.in @@ -0,0 +1,5 @@ +if [ $1 -le 1 ]; then + # perform the below actions for rpm remove($1=0) or upgrade($1=1) operations + # remove pyc file generated by python + rm -rf @CPACK_PACKAGING_INSTALL_PREFIX@/@CMAKE_INSTALL_LIBEXECDIR@/rocm_smi/__pycache__ +fi