diff --git a/runtime/hsa-runtime/CMakeLists.txt b/runtime/hsa-runtime/CMakeLists.txt index dee4036885..a0a5cd58c2 100644 --- a/runtime/hsa-runtime/CMakeLists.txt +++ b/runtime/hsa-runtime/CMakeLists.txt @@ -386,6 +386,7 @@ endif() ## Packaging directives set ( CPACK_GENERATOR "DEB;RPM" CACHE STRING "Package types to build") +set ( ENABLE_LDCONFIG ON CACHE BOOL "Set library links and caches using ldconfig.") ## Only pack the "binary" and "dev" components, post install script will add the directory link. set (CPACK_DEB_COMPONENT_INSTALL ON) @@ -399,9 +400,9 @@ set ( CPACK_PACKAGE_CONTACT "TODO Advanced Micro Devices, Inc." ) set ( CPACK_PACKAGE_DESCRIPTION_SUMMARY "AMD Heterogeneous System Architecture HSA - Linux HSA Runtime for Boltzmann (ROCm) platforms" ) set ( CPACK_RESOURCE_FILE_LICENSE "${CMAKE_CURRENT_SOURCE_DIR}/LICENSE.md" ) -## Process the install scripts to update the CPACK variables -configure_file(${CMAKE_CURRENT_SOURCE_DIR}/DEBIAN/post_install DEBIAN/postinst @ONLY) -configure_file(${CMAKE_CURRENT_SOURCE_DIR}/DEBIAN/pre_remove DEBIAN/prerm @ONLY) +## 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 ) if ( DEFINED ENV{ROCM_LIBPATCH_VERSION} ) set ( CPACK_PACKAGE_VERSION "${CPACK_PACKAGE_VERSION}.$ENV{ROCM_LIBPATCH_VERSION}" ) @@ -452,8 +453,12 @@ set ( CPACK_RPM_PACKAGE_PROVIDES "hsa-ext-rocr-dev" ) set ( CPACK_RPM_PACKAGE_OBSOLETES "hsa-ext-rocr-dev" ) set ( CPACK_RPM_PACKAGE_CONFLICTS "hsa-ext-rocr-dev" ) -set ( CPACK_RPM_POST_INSTALL_SCRIPT_FILE "${CMAKE_CURRENT_SOURCE_DIR}/RPM/rpm_post" ) -set ( CPACK_RPM_POST_UNINSTALL_SCRIPT_FILE "${CMAKE_CURRENT_SOURCE_DIR}/RPM/rpm_postun" ) +## 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" ) ## Include packaging include ( CPack ) diff --git a/runtime/hsa-runtime/DEBIAN/post_install b/runtime/hsa-runtime/DEBIAN/postinst.in similarity index 92% rename from runtime/hsa-runtime/DEBIAN/post_install rename to runtime/hsa-runtime/DEBIAN/postinst.in index 1b8ce96efa..6c8a8b652d 100644 --- a/runtime/hsa-runtime/DEBIAN/post_install +++ b/runtime/hsa-runtime/DEBIAN/postinst.in @@ -44,12 +44,16 @@ set -e +# left-hand term originates from @ENABLE_LDCONFIG@ = ON/OFF at package build do_ldconfig() { - echo @CPACK_PACKAGING_INSTALL_PREFIX@/hsa/lib > /etc/ld.so.conf.d/hsa-rocr-dev.conf && ldconfig + if [ "@ENABLE_LDCONFIG@" == "ON" ]; then + echo @CPACK_PACKAGING_INSTALL_PREFIX@/hsa/lib > /etc/ld.so.conf.d/hsa-rocr-dev.conf + ldconfig + fi } case "$1" in - configure) + ( configure ) do_ldconfig # Workaround for CPACK directory symlink handling error. mkdir -p @CPACK_PACKAGING_INSTALL_PREFIX@/hsa/include @@ -58,7 +62,7 @@ case "$1" in abort-upgrade|abort-remove|abort-deconfigure) echo "$1" ;; - *) + ( * ) exit 0 ;; esac diff --git a/runtime/hsa-runtime/DEBIAN/pre_remove b/runtime/hsa-runtime/DEBIAN/prerm.in similarity index 91% rename from runtime/hsa-runtime/DEBIAN/pre_remove rename to runtime/hsa-runtime/DEBIAN/prerm.in index c168ebc4f4..aa212593ba 100644 --- a/runtime/hsa-runtime/DEBIAN/pre_remove +++ b/runtime/hsa-runtime/DEBIAN/prerm.in @@ -44,20 +44,23 @@ set -e +# left-hand term originates from @ENABLE_LDCONFIG@ = ON/OFF at package build rm_ldconfig() { - rm -f /etc/ld.so.conf.d/hsa-rocr-dev.conf && ldconfig + if [ "@ENABLE_LDCONFIG@" == "ON" ]; then + rm -f /etc/ld.so.conf.d/hsa-rocr-dev.conf + ldconfig + fi } case "$1" in - remove) + ( remove ) rm_ldconfig # Workaround for CPACK directory symlink handling error. rm -rf @CPACK_PACKAGING_INSTALL_PREFIX@/hsa ;; - purge) + ( purge ) ;; - *) + ( * ) exit 0 ;; esac - diff --git a/runtime/hsa-runtime/RPM/rpm_post b/runtime/hsa-runtime/RPM/post.in similarity index 90% rename from runtime/hsa-runtime/RPM/rpm_post rename to runtime/hsa-runtime/RPM/post.in index 7fcbaabda2..117148233a 100644 --- a/runtime/hsa-runtime/RPM/rpm_post +++ b/runtime/hsa-runtime/RPM/post.in @@ -40,4 +40,8 @@ ## ################################################################################ -echo /opt/rocm/hsa/lib > /etc/ld.so.conf.d/hsa-rocr-dev.conf && ldconfig +# left-hand term originates from @ENABLE_LDCONFIG@ = ON/OFF at package build +if [ "@ENABLE_LDCONFIG@" == "ON" ]; then + echo @CPACK_PACKAGING_INSTALL_PREFIX@/hsa/lib > /etc/ld.so.conf.d/hsa-rocr-dev.conf + ldconfig +fi diff --git a/runtime/hsa-runtime/RPM/rpm_postun b/runtime/hsa-runtime/RPM/postun.in similarity index 91% rename from runtime/hsa-runtime/RPM/rpm_postun rename to runtime/hsa-runtime/RPM/postun.in index 4948447470..801525d682 100644 --- a/runtime/hsa-runtime/RPM/rpm_postun +++ b/runtime/hsa-runtime/RPM/postun.in @@ -40,6 +40,8 @@ ## ################################################################################ -if [ $1 -eq 0 ]; then - rm -f /etc/ld.so.conf.d/hsa-rocr-dev.conf && ldconfig +# left-hand 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/hsa-rocr-dev.conf + ldconfig fi