From f990d775b79f1a06c934a8b8d7347ada189ef0ad Mon Sep 17 00:00:00 2001 From: Cole Nelson Date: Wed, 24 Mar 2021 15:25:00 -0700 Subject: [PATCH] CMakeLists.txt: add ENABLE_LDCONFIG to support multi-version install Signed-off-by: Cole Nelson Change-Id: If06e8b7b57ad12f22c1970622d241a42083d575e --- CMakeLists.txt | 15 +++++++++++---- DEBIAN/postinst | 19 ------------------- DEBIAN/postinst.in | 23 +++++++++++++++++++++++ DEBIAN/prerm | 19 ------------------- DEBIAN/prerm.in | 22 ++++++++++++++++++++++ RPM/post.in | 5 +++++ RPM/postun.in | 5 +++++ RPM/rpm_post | 2 -- RPM/rpm_postun | 3 --- 9 files changed, 66 insertions(+), 47 deletions(-) delete mode 100755 DEBIAN/postinst create mode 100755 DEBIAN/postinst.in delete mode 100755 DEBIAN/prerm create mode 100755 DEBIAN/prerm.in create mode 100755 RPM/post.in create mode 100755 RPM/postun.in delete mode 100755 RPM/rpm_post delete mode 100755 RPM/rpm_postun diff --git a/CMakeLists.txt b/CMakeLists.txt index 291f4438e1..aa8fc61063 100755 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -141,6 +141,7 @@ add_subdirectory("oam") ########################### set(CPACK_GENERATOR "DEB;RPM" CACHE STRING "Default packaging generators.") set(CPACK_PACKAGING_INSTALL_PREFIX "/opt/rocm" CACHE STRING "Default packaging prefix.") +set ( ENABLE_LDCONFIG ON CACHE BOOL "Set library links and caches using ldconfig.") set(CPACK_PACKAGE_NAME ${ROCM_SMI_PACKAGE}) set(CPACK_PACKAGE_VENDOR "Advanced Micro Devices, Inc.") set(CPACK_PACKAGE_CONTACT "RocmSMILib Support ") @@ -154,7 +155,6 @@ if(DEFINED ENV{ROCM_LIBPATCH_VERSION}) endif() #Debian package specific variables -set(CPACK_DEBIAN_PACKAGE_CONTROL_EXTRA "${CMAKE_CURRENT_SOURCE_DIR}/DEBIAN/postinst;${CMAKE_CURRENT_SOURCE_DIR}/DEBIAN/prerm") set(CPACK_DEBIAN_PACKAGE_HOMEPAGE ${CPACK_DEBIAN_PACKAGE_HOMEPAGE} CACHE STRING "https://github.com/RadeonOpenCompute/ROCm") if(DEFINED ENV{CPACK_DEBIAN_PACKAGE_RELEASE}) set(CPACK_DEBIAN_PACKAGE_RELEASE $ENV{CPACK_DEBIAN_PACKAGE_RELEASE}) @@ -163,10 +163,12 @@ else() endif() set (CPACK_DEBIAN_PACKAGE_PROVIDES "rocm-smi") set (CPACK_DEBIAN_PACKAGE_SUGGESTS "sudo") +## Process the Debian install/remove scripts to update the CPACK variables +configure_file ( ${CMAKE_CURRENT_SOURCE_DIR}/DEBIAN/postinst.in DEBIAN/postinst @ONLY ) +configure_file ( ${CMAKE_CURRENT_SOURCE_DIR}/DEBIAN/prerm.in DEBIAN/prerm @ONLY ) +set(CPACK_DEBIAN_PACKAGE_CONTROL_EXTRA "DEBIAN/postinst;DEBIAN/prerm") # RPM package specific variables -set(CPACK_RPM_PRE_INSTALL_SCRIPT_FILE "${CMAKE_CURRENT_SOURCE_DIR}/RPM/rpm_post") -set(CPACK_RPM_POST_UNINSTALL_SCRIPT_FILE "${CMAKE_CURRENT_SOURCE_DIR}/RPM/rpm_postun") set(CPACK_RPM_EXCLUDE_FROM_AUTO_FILELIST_ADDITION "${CPACK_PACKAGING_INSTALL_PREFIX} ${CPACK_PACKAGING_INSTALL_PREFIX}/${CMAKE_INSTALL_BINDIR}" ) if(DEFINED ENV{CPACK_RPM_PACKAGE_RELEASE}) set(CPACK_RPM_PACKAGE_RELEASE $ENV{CPACK_RPM_PACKAGE_RELEASE}) @@ -186,10 +188,15 @@ set (CPACK_RPM_PACKAGE_PROVIDES "rocm-smi") #Prepare final version for the CPACK use set(CPACK_PACKAGE_VERSION "${CPACK_PACKAGE_VERSION_MAJOR}.${CPACK_PACKAGE_VERSION_MINOR}.${CPACK_PACKAGE_VERSION_PATCH}.${ROCM_VERSION_FOR_PACKAGE}") +## 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/postun.in" RPM/postun @ONLY ) +set ( CPACK_RPM_POST_INSTALL_SCRIPT_FILE "${CMAKE_CURRENT_BINARY_DIR}/RPM/post" ) +set ( CPACK_RPM_POST_UNINSTALL_SCRIPT_FILE "${CMAKE_CURRENT_BINARY_DIR}/RPM/postun" ) + #Set the names now using CPACK utility set(CPACK_DEBIAN_FILE_NAME "DEB-DEFAULT") set(CPACK_RPM_FILE_NAME "RPM-DEFAULT") include (CPack) - diff --git a/DEBIAN/postinst b/DEBIAN/postinst deleted file mode 100755 index 011d291974..0000000000 --- a/DEBIAN/postinst +++ /dev/null @@ -1,19 +0,0 @@ -#/bin/bash - -set -e - -do_ldconfig() { - echo /opt/rocm/rocm_smi/lib > /etc/ld.so.conf.d/x86_64-librocm_smi_lib.conf && ldconfig -} - -case "$1" in - configure) - do_ldconfig - ;; - abort-upgrade|abort-remove|abort-deconfigure) - echo "$1" - ;; - *) - exit 0 - ;; -esac diff --git a/DEBIAN/postinst.in b/DEBIAN/postinst.in new file mode 100755 index 0000000000..74ee2db0a7 --- /dev/null +++ b/DEBIAN/postinst.in @@ -0,0 +1,23 @@ +#!/bin/bash + +set -e + +do_ldconfig() { + # left-hand term originates from ENABLE_LDCONFIG = ON/OFF at package build + if [ "@ENABLE_LDCONFIG@" == "ON" ]; then + echo @CPACK_PACKAGING_INSTALL_PREFIX@/rocm_smi/lib > /etc/ld.so.conf.d/x86_64-librocm_smi_lib.conf + ldconfig + fi +} + +case "$1" in + ( configure ) + do_ldconfig + ;; + ( abort-upgrade | abort-remove | abort-deconfigure ) + echo "$1" + ;; + ( * ) + exit 0 + ;; +esac diff --git a/DEBIAN/prerm b/DEBIAN/prerm deleted file mode 100755 index 9b38307ae0..0000000000 --- a/DEBIAN/prerm +++ /dev/null @@ -1,19 +0,0 @@ -#!/bin/bash - -set -e - -rm_ldconfig() { - rm -f /etc/ld.so.conf.d/x86_64-librocm_smi_lib.conf && ldconfig -} - -case "$1" in - remove) - rm_ldconfig - ;; - purge) - ;; - *) - exit 0 - ;; -esac - diff --git a/DEBIAN/prerm.in b/DEBIAN/prerm.in new file mode 100755 index 0000000000..09404a612b --- /dev/null +++ b/DEBIAN/prerm.in @@ -0,0 +1,22 @@ +#!/bin/bash + +set -e + +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-librocm_smi_lib.conf + ldconfig + fi +} + +case "$1" in + ( remove ) + rm_ldconfig + ;; + ( purge ) + ;; + ( * ) + exit 0 + ;; +esac diff --git a/RPM/post.in b/RPM/post.in new file mode 100755 index 0000000000..52e78fce17 --- /dev/null +++ b/RPM/post.in @@ -0,0 +1,5 @@ +# left-hand term originates from ENABLE_LDCONFIG = ON/OFF at package build +if [ "@ENABLE_LDCONFIG@" == "ON" ]; then + echo -e "@CPACK_PACKAGING_INSTALL_PREFIX@/rocm_smi/lib\n@CPACK_PACKAGING_INSTALL_PREFIX@/rocm_smi/lib64" > /etc/ld.so.conf.d/x86_64-librocm_smi_lib.conf + ldconfig +fi diff --git a/RPM/postun.in b/RPM/postun.in new file mode 100755 index 0000000000..05c2a309ab --- /dev/null +++ b/RPM/postun.in @@ -0,0 +1,5 @@ +# second term originates from ENABLE_LDCONFIG = ON/OFF at package build +if [ $1 -eq 0 ] && [ "@ENABLE_LDCONFIG@" == "ON" ]; then + rm -f /etc/ld.so.conf.d/x86_64-librocm_smi_lib.conf + ldconfig +fi diff --git a/RPM/rpm_post b/RPM/rpm_post deleted file mode 100755 index 4045596578..0000000000 --- a/RPM/rpm_post +++ /dev/null @@ -1,2 +0,0 @@ -echo -e "/opt/rocm/rocm_smi/lib\n/opt/rocm/rocm_smi/lib64" > /etc/ld.so.conf.d/x86_64-librocm_smi_lib.conf && ldconfig - diff --git a/RPM/rpm_postun b/RPM/rpm_postun deleted file mode 100755 index 80a0da7b5d..0000000000 --- a/RPM/rpm_postun +++ /dev/null @@ -1,3 +0,0 @@ -if [ $1 -eq 0 ]; then - rm -f /etc/ld.so.conf.d/x86_64-librocm_smi_lib.conf && ldconfig -fi