From b93ee2fe7a028d0016eeb939ef0f4a3c9d102dbe Mon Sep 17 00:00:00 2001 From: Jeremy Newton Date: Thu, 18 Nov 2021 15:51:09 -0500 Subject: [PATCH] Fix packaging of license file CPACK doesn't have proper logic for installing the license as described by CPACK_RESOURCE_FILE_LICENSE. For Debian packaging, the license is expected to be installed as: /usr/share/doc/PACKAGENAME/copyright To do this, I've added a bit of logic for CPACK to copy this into the package using CPACK_INSTALL_COMMANDS to prep the directory, and CPACK_INSTALLED_DIRECTORIES to add it to the package. This applies to both RPM and DEB, so I've added some logic to the spec file to exclude this file (note that CPACK_RPM_EXCLUDE_FROM_AUTO_FILELIST_ADDITION does not work for files installed with CPACK_INSTALLED_DIRECTORIES). For RPM install, I've just added a small bit of logic to the spec file to handle it. The file needs to be copied into the spec working directory, then a macro is used to handle the rest. Note the license macro does not work on EL6, but I don't think we want to support this. Change-Id: I06ce63d300419893cb8274bc504a15633e304d91 Signed-off-by: Jeremy Newton [ROCm/ROCR-Runtime commit: 7649cd862e378a5727008fdcac7439ddcc7851e0] --- projects/rocr-runtime/CMakeLists.txt | 7 ++++++- projects/rocr-runtime/RPM/hsakmt-roct-devel.spec.in | 7 +++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/projects/rocr-runtime/CMakeLists.txt b/projects/rocr-runtime/CMakeLists.txt index 994b00fbf2..e563552c5d 100644 --- a/projects/rocr-runtime/CMakeLists.txt +++ b/projects/rocr-runtime/CMakeLists.txt @@ -211,7 +211,7 @@ install ( TARGETS ${HSAKMT_TARGET} EXPORT ${HSAKMT_TARGET}Targets ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT devel LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT devel ) -install ( FILES ${CMAKE_CURRENT_SOURCE_DIR}/LICENSE.md DESTINATION ${CMAKE_INSTALL_DOCDIR} COMPONENT devel ) +#install ( FILES ${CMAKE_CURRENT_SOURCE_DIR}/LICENSE.md DESTINATION ${CMAKE_INSTALL_DOCDIR} COMPONENT devel ) # Install public headers install ( DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/include/ DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} @@ -303,6 +303,11 @@ if (DEFINED ENV{CPACK_DEBIAN_PACKAGE_RELEASE}) else() set(CPACK_DEBIAN_PACKAGE_RELEASE "local") endif() +# Logic to install debian copyright file (i.e. the license file) +set(CPACK_INSTALL_COMMANDS "install -m 644 -D ${CPACK_RESOURCE_FILE_LICENSE} \ + ${PROJECT_BINARY_DIR}/doc/${CPACK_DEBIAN_PACKAGE_NAME}/copyright") +set(CPACK_INSTALLED_DIRECTORIES "${PROJECT_BINARY_DIR}/doc/${CPACK_DEBIAN_PACKAGE_NAME}" + "/usr/share/doc/${CPACK_DEBIAN_PACKAGE_NAME}") ## 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 ) diff --git a/projects/rocr-runtime/RPM/hsakmt-roct-devel.spec.in b/projects/rocr-runtime/RPM/hsakmt-roct-devel.spec.in index cb8b7e39b9..2cc9e9f8ad 100644 --- a/projects/rocr-runtime/RPM/hsakmt-roct-devel.spec.in +++ b/projects/rocr-runtime/RPM/hsakmt-roct-devel.spec.in @@ -55,6 +55,9 @@ Recommends: @CPACK_RPM_PACKAGE_RECOMMENDS@ %prep mv $RPM_BUILD_ROOT %_topdir/tmpBBroot +# The license macro expects the license to be copied into the working directory +cp -a @CPACK_RESOURCE_FILE_LICENSE@ ./LICENSE.md + %install if [ -e $RPM_BUILD_ROOT ]; then @@ -91,6 +94,10 @@ mv %_topdir/tmpBBroot $RPM_BUILD_ROOT @CPACK_RPM_ABSOLUTE_INSTALL_FILES@ @CPACK_RPM_USER_INSTALL_FILES@ +# RPM has a different way of packaging the license, ignore the debian one: +%license LICENSE.md +%exclude /usr/share/doc/@CPACK_DEBIAN_PACKAGE_NAME@ + %changelog @CPACK_RPM_SPEC_CHANGELOG@