From 7db31dbcc75377b4cc52fd3e7d210eff7f9a73a3 Mon Sep 17 00:00:00 2001 From: Maneesh Gupta Date: Fri, 6 May 2016 14:39:10 +0530 Subject: [PATCH] Add packaging scripts for creating hip_samples package Change-Id: I38205ce851ee2d8affce532c80c9a9fd4f66b345 [ROCm/hip commit: 9a25f6ad8f42f19f578e760f162417689fb4a61b] --- projects/hip/CMakeLists.txt | 15 +++++++-- .../packaging/create_hip_samples_installer.sh | 23 +++++++++++++ projects/hip/packaging/hip_samples.txt | 32 +++++++++++++++++++ 3 files changed, 68 insertions(+), 2 deletions(-) create mode 100755 projects/hip/packaging/create_hip_samples_installer.sh create mode 100644 projects/hip/packaging/hip_samples.txt diff --git a/projects/hip/CMakeLists.txt b/projects/hip/CMakeLists.txt index 72f1609f99..f16e38ca49 100644 --- a/projects/hip/CMakeLists.txt +++ b/projects/hip/CMakeLists.txt @@ -204,6 +204,17 @@ add_custom_target(pkg_hip_doc COMMAND ${CMAKE_COMMAND} . COMMAND cp *.tar.gz ${PROJECT_BINARY_DIR} WORKING_DIRECTORY ${BUILD_DIR}) -# Package: all -add_custom_target(package DEPENDS pkg_hip_base pkg_hip_hcc pkg_hip_nvcc pkg_hip_doc) +# Package: hip_samples +set(BUILD_DIR ${CMAKE_CURRENT_BINARY_DIR}/packages/hip_samples) +configure_file(packaging/hip_samples.txt ${BUILD_DIR}/CMakeLists.txt @ONLY) +add_custom_target(pkg_hip_samples COMMAND ${CMAKE_COMMAND} . + COMMAND rm -rf *.deb *.rpm *.tar.gz + COMMAND make package + COMMAND cp *.deb ${PROJECT_BINARY_DIR} + COMMAND cp *.rpm ${PROJECT_BINARY_DIR} + COMMAND cp *.tar.gz ${PROJECT_BINARY_DIR} + WORKING_DIRECTORY ${BUILD_DIR}) + +# Package: all +add_custom_target(package DEPENDS pkg_hip_base pkg_hip_hcc pkg_hip_nvcc pkg_hip_doc pkg_hip_samples) diff --git a/projects/hip/packaging/create_hip_samples_installer.sh b/projects/hip/packaging/create_hip_samples_installer.sh new file mode 100755 index 0000000000..91789d2524 --- /dev/null +++ b/projects/hip/packaging/create_hip_samples_installer.sh @@ -0,0 +1,23 @@ +#!/bin/bash +function die { + echo "${1-Died}." >&2 + exit 1 +} + +payload=$1 +script=$2 +[ "$payload" != "" ] || [ "$script" != "" ] || die "Invalid arguments!" +tmp=__extract__$RANDOM + +printf "#!/bin/bash +samples_dir=\$1 +[ \"\$samples_dir\" != \"\" ] || read -e -p \"Enter the path to extract the HIP samples: \" samples_dir +mkdir -p \$samples_dir +PAYLOAD=\`awk '/^__PAYLOAD_BELOW__/ {print NR + 1; exit 0; }' \$0\` +tail -n+\$PAYLOAD \$0 | tar -xz -C \$samples_dir +echo \"HIP samples installed in \$samples_dir\" +exit 0 +__PAYLOAD_BELOW__\n" > "$tmp" + +cat "$tmp" "$payload" > "$script" && rm "$tmp" +chmod +x "$script" diff --git a/projects/hip/packaging/hip_samples.txt b/projects/hip/packaging/hip_samples.txt new file mode 100644 index 0000000000..c3873bf05f --- /dev/null +++ b/projects/hip/packaging/hip_samples.txt @@ -0,0 +1,32 @@ +cmake_minimum_required(VERSION 2.8.3) +project(hip_samples) + +add_custom_target(create_installer_script ALL + COMMAND tar cvzf ${PROJECT_BINARY_DIR}/samples.tgz --exclude='*.o' . + COMMAND @hip_SOURCE_DIR@/packaging/create_hip_samples_installer.sh ${PROJECT_BINARY_DIR}/samples.tgz ${PROJECT_BINARY_DIR}/unpack_hip_samples.sh + WORKING_DIRECTORY @hip_SOURCE_DIR@/samples) +install(PROGRAMS unpack_hip_samples.sh DESTINATION bin) + +############################# +# Packaging steps +############################# +set(CPACK_SET_DESTDIR TRUE) +set(CPACK_INSTALL_PREFIX "/opt/rocm/hip") +set(CPACK_PACKAGE_NAME "hip_samples") +set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "HIP: Heterogenous-computing Interface for Portability [SAMPLES]") +set(CPACK_PACKAGE_VENDOR "Advanced Micro Devices, Inc.") +set(CPACK_PACKAGE_CONTACT "Maneesh Gupta ") +set(CPACK_PACKAGE_VERSION @HIP_VERSION_MAJOR@.@HIP_VERSION_MINOR@.@HIP_VERSION_PATCH@) +set(CPACK_PACKAGE_VERSION_MAJOR @HIP_VERSION_MAJOR@) +set(CPACK_PACKAGE_VERSION_MINOR @HIP_VERSION_MINOR@) +set(CPACK_PACKAGE_VERSION_PATCH @HIP_VERSION_PATCH@) +set(CPACK_PACKAGE_FILE_NAME ${CPACK_PACKAGE_NAME}-${CPACK_PACKAGE_VERSION_MAJOR}.${CPACK_PACKAGE_VERSION_MINOR}.${CPACK_PACKAGE_VERSION_PATCH}) +set(CPACK_GENERATOR "TGZ;DEB;RPM") +set(CPACK_BINARY_DEB "ON") +set(CPACK_DEBIAN_PACKAGE_DEPENDS "hip_base (= ${CPACK_PACKAGE_VERSION})") +set(CPACK_BINARY_RPM "ON") +set(CPACK_RPM_PACKAGE_ARCHITECTURE "x86_64") +set(CPACK_RPM_PACKAGE_AUTOREQPROV " no") +set(CPACK_RPM_PACKAGE_REQUIRES "hip_base = ${CPACK_PACKAGE_VERSION}") +set(CPACK_SOURCE_GENERATOR "TGZ") +include(CPack)