diff --git a/CMakeLists.txt b/CMakeLists.txt index 9d9f4244827..41079918081 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -506,6 +506,16 @@ execute_process(COMMAND ${DEBIAN_EXTRA_SCRIPT_SOURCE_DIR}/process_packaging_scri ${CMAKE_SYSTEM_PROCESSOR} WORKING_DIRECTORY ${PROJECT_BINARY_DIR}) +execute_process(COMMAND ${DEBIAN_EXTRA_SCRIPT_SOURCE_DIR}/process_packaging_script.bsh ${DEBIAN_EXTRA_SCRIPT_SOURCE_DIR}/preinst_rpm.in + ${DEBIAN_EXTRA_SCRIPT_DEST_DIR}/preinst_rpm + ${CPACK_PACKAGE_NAME} + ${HCC_PACKAGE_INSTALL_PREFIX} + ${CMAKE_INSTALL_LIBDIR} + ${CMAKE_SYSTEM_PROCESSOR} + ${HCC_VERSION_MAJOR} + ${HCC_VERSION_MINOR} + WORKING_DIRECTORY ${PROJECT_BINARY_DIR}) + set(CPACK_PACKAGE_VENDOR "Advanced Micro Devices, Inc") set(CPACK_PACKAGE_VERSION "${HCC_VERSION_MAJOR}.${HCC_VERSION_MINOR}.${HCC_VERSION_PATCH}") set(CPACK_PACKAGE_VERSION_MAJOR ${HCC_VERSION_MAJOR}) @@ -557,6 +567,7 @@ set(CPACK_DEBIAN_PACKAGE_DEPENDS "${HCC_GENERAL_DEBIAN_DEP} ${HCC_ROCR_DEP} ${HC # RPM package settings set(CPACK_RPM_PACKAGE_DESCRIPTION ${PACKAGE_DESCRIPTION}) set(CPACK_RPM_POST_INSTALL_SCRIPT_FILE "${PROJECT_BINARY_DIR}/packaging/debian/postinst") +set(CPACK_RPM_PRE_INSTALL_SCRIPT_FILE "${PROJECT_BINARY_DIR}/packaging/debian/preinst_rpm") set(CPACK_RPM_PRE_UNINSTALL_SCRIPT_FILE "${PROJECT_BINARY_DIR}/packaging/debian/prerm") # disable automatic shared libraries dependency detection diff --git a/packaging/debian/postinst.in b/packaging/debian/postinst.in index bf338b1855a..ed09b7b0561 100755 --- a/packaging/debian/postinst.in +++ b/packaging/debian/postinst.in @@ -27,10 +27,6 @@ SOFTLINKS=( do_softlinks() { - if [ $PACKAGE_NAME == "hcc_hsail" ] && [ -L "$ROCM_PATH/hcc" ] && [ $(readlink -f $ROCM_PATH/hcc) == "$ROCM_PATH/hcc-lc" ] ; then - return - fi - mkdir -p "$ROCM_PATH/lib" mkdir -p "$ROCM_PATH/lib/cmake" mkdir -p "$ROCM_PATH/bin" @@ -50,28 +46,10 @@ do_softlinks() { SOURCE_DIR=${SOFTLINKS[i]} DEST_DIR=${SOFTLINKS[i+1]} FILE=${SOFTLINKS[i+2]} - - if [ -e $ROCM_PATH/hcc/$SOURCE_DIR/$FILE ] ; then - if [ ! -e $ROCM_PATH/$DEST_DIR/$FILE ] ; then - ln -sf $ROCM_PATH/hcc/$SOURCE_DIR/$FILE $ROCM_PATH/$DEST_DIR/$FILE - fi - fi + ln -sf $ROCM_PATH/hcc/$SOURCE_DIR/$FILE $ROCM_PATH/$DEST_DIR/$FILE done } -case "$1" in - configure|upgrade|1|2) - do_softlinks - ;; - - abort-upgrade|abort-remove|abort-deconfigure) - echo "$1" - ;; - - *) - echo "postinst called with unknown argument: $1" >&2 - exit 0 - ;; - -esac - +if [ $1 == "configure" ] || [ $1 == "upgrade" ] || [ "$1" -ge "1" ] ; then + do_softlinks +fi \ No newline at end of file diff --git a/packaging/debian/preinst_rpm.in b/packaging/debian/preinst_rpm.in new file mode 100755 index 00000000000..1385adb4538 --- /dev/null +++ b/packaging/debian/preinst_rpm.in @@ -0,0 +1,45 @@ +#!/bin/bash + +set -e + +PACKAGE_NAME=@PACKAGE_NAME@ +INSTALL_PATH=@INSTALL_PATH@ +LIBRARY_DIR=@LIBRARY_DIR@ +PROCESSOR=@PROCESSOR@ +HCC_VERSION_MAJOR=@HCC_VERSION_MAJOR@ +HCC_VERSION_MINOR=@HCC_VERSION_MINOR@ + +ROCM_PATH="/opt/rocm" + +# NOTE: if you modify this table, also update the same table in postinst +SOFTLINKS=( +# + "bin" "bin" "clamp-config" + "bin" "bin" "extractkernel" + "bin" "bin" "hcc" + "bin" "bin" "hcc-config" + "$LIBRARY_DIR" "lib" "libhc_am.so*" + "$LIBRARY_DIR" "lib" "libmcwamp.so*" + "$LIBRARY_DIR" "lib" "libmcwamp_cpu.so*" + "$LIBRARY_DIR" "lib" "libmcwamp_hsa.so*" + "$LIBRARY_DIR" "lib" "libclang_rt.builtins-${PROCESSOR}.a" +) + +remove_all_softlinks_before_upgrade() { + + for (( i=0; i<${#SOFTLINKS[@]}; i+=3 )) + do + SOURCE_DIR=${SOFTLINKS[i]} + DEST_DIR=${SOFTLINKS[i+1]} + FILE=${SOFTLINKS[i+2]} + + rm -f $ROCM_PATH/$DEST_DIR/$FILE + done + rm -f $ROCM_PATH/include/hcc + rm -f $ROCM_PATH/lib/cmake/hcc +} + +if [ "$1" -ge "2" ] ; then + remove_all_softlinks_before_upgrade +fi + diff --git a/packaging/debian/prerm.in b/packaging/debian/prerm.in index 7b7906a2561..10698ad3259 100755 --- a/packaging/debian/prerm.in +++ b/packaging/debian/prerm.in @@ -25,14 +25,10 @@ SOFTLINKS=( "$LIBRARY_DIR" "lib" "libclang_rt.builtins-${PROCESSOR}.a" ) -do_softlinks() { +remove_all_softlinks() { rm -f $INSTALL_PATH/include/hcc - if [ $PACKAGE_NAME == "hcc_hsail" ] && [ -L "$ROCM_PATH/hcc" ] && [ $(readlink -f $ROCM_PATH/hcc) == "$ROCM_PATH/hcc-lc" ] ; then - return - fi - for (( i=0; i<${#SOFTLINKS[@]}; i+=3 )) do SOURCE_DIR=${SOFTLINKS[i]} @@ -51,17 +47,6 @@ do_softlinks() { rmdir --ignore-fail-on-non-empty /opt/rocm } - -case "$1" in - remove|purge|upgrade|0|1) - do_softlinks - ;; - - *) - echo "postrm called with unknown argument: $1" >&2 - exit 0 - ;; - -esac - - +if [ $1 == "remove" ] || [ $1 == "purge" ] || [ $1 == "upgrade" ] || [ "$1" -eq "0" ] ; then + remove_all_softlinks +fi \ No newline at end of file