diff --git a/CMakeLists.txt b/CMakeLists.txt index f5c1d73c..f3b99c2b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -176,6 +176,7 @@ install ( TARGETS "kfdwrapper64" LIBRARY DESTINATION ${DEST_NAME}/lib ) ## Packaging directives set ( CPACK_GENERATOR "DEB" "RPM" "TGZ" ) +set ( ENABLE_LDCONFIG ON CACHE BOOL "Set library links and caches using ldconfig.") set ( CPACK_PACKAGE_NAME "${ROCTRACER_NAME}-dev" ) set ( CPACK_PACKAGE_VENDOR "Advanced Micro Devices, Inc." ) set ( CPACK_PACKAGE_VERSION_MAJOR ${BUILD_VERSION_MAJOR} ) @@ -198,7 +199,10 @@ else() endif() message ( "Using CPACK_DEBIAN_PACKAGE_RELEASE ${CPACK_DEBIAN_PACKAGE_RELEASE}" ) set ( CPACK_DEBIAN_FILE_NAME "DEB-DEFAULT" ) -set ( CPACK_DEBIAN_PACKAGE_CONTROL_EXTRA "${CMAKE_CURRENT_SOURCE_DIR}/DEBIAN/postinst;${CMAKE_CURRENT_SOURCE_DIR}/DEBIAN/prerm" ) +## 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 if ( DEFINED ENV{CPACK_RPM_PACKAGE_RELEASE} ) @@ -220,8 +224,12 @@ if ( PROC_RESULT EQUAL "0" AND NOT EVAL_RESULT STREQUAL "" ) endif() set ( CPACK_RPM_FILE_NAME "RPM-DEFAULT" ) message("CPACK_RPM_PACKAGE_RELEASE: ${CPACK_RPM_PACKAGE_RELEASE}") -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 ( CPack ) diff --git a/DEBIAN/postinst b/DEBIAN/postinst deleted file mode 100644 index 141a4de6..00000000 --- a/DEBIAN/postinst +++ /dev/null @@ -1,19 +0,0 @@ -#/bin/bash - -set -e - -do_ldconfig() { - echo /opt/rocm/roctracer/lib > /etc/ld.so.conf.d/libroctracer64.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 100644 index 00000000..21607ffb --- /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@/roctracer/lib > /etc/ld.so.conf.d/libroctracer64.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 100644 index 886d3e17..00000000 --- a/DEBIAN/prerm +++ /dev/null @@ -1,18 +0,0 @@ -#!/bin/bash - -set -e - -rm_ldconfig() { - rm -f /etc/ld.so.conf.d/libroctracer64.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 100644 index 00000000..f19ee548 --- /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/libroctracer64.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 100644 index 00000000..29f3278e --- /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 @CPACK_PACKAGING_INSTALL_PREFIX@/roctracer/lib > /etc/ld.so.conf.d/libroctracer64.conf + ldconfig +fi diff --git a/RPM/postun.in b/RPM/postun.in new file mode 100644 index 00000000..8ee50096 --- /dev/null +++ b/RPM/postun.in @@ -0,0 +1,5 @@ +# left-hand term originates from ENABLE_LDCONFIG = ON/OFF at package build +if [ "@ENABLE_LDCONFIG@" == "ON" ]; then + rm -f /etc/ld.so.conf.d/libroctracer64.conf + ldconfig +fi diff --git a/RPM/rpm_post b/RPM/rpm_post deleted file mode 100644 index a19ea861..00000000 --- a/RPM/rpm_post +++ /dev/null @@ -1 +0,0 @@ -echo /opt/rocm/roctracer/lib > /etc/ld.so.conf.d/libroctracer64.conf && ldconfig diff --git a/RPM/rpm_postun b/RPM/rpm_postun deleted file mode 100644 index a737490b..00000000 --- a/RPM/rpm_postun +++ /dev/null @@ -1 +0,0 @@ -rm -f /etc/ld.so.conf.d/libroctracer64.conf && ldconfig