Skip to content

Commit 82a6eaa

Browse files
authored
Enable Lintian Support hipcc (#445)
Added function configure_pkg to install changelog, copyright, and lintian override for debian. Install changelog, copyright, and lintian override files to fix lintian errors: no-copyright-file debian-changelog-file-missing dir-or-file-in-opt
1 parent f5dae9d commit 82a6eaa

File tree

4 files changed

+133
-1
lines changed

4 files changed

+133
-1
lines changed

amd/hipcc/CMakeLists.txt

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,14 @@ project(hipcc VERSION "1.1.1" LANGUAGES C CXX)
88
include(CMakePackageConfigHelpers)
99
include(GNUInstallDirs)
1010

11+
include( utils.cmake )
12+
set( HIPCC "hipcc" )
13+
set( HIPCC_NVIDIA "hipcc-nvidia")
14+
set( COMP_TYPE "AMD" )
15+
set( COMP_TYPE_NVIDIA "NVIDIA" )
16+
set( BUILD_ENABLE_LINTIAN_OVERRIDES ON CACHE BOOL "Enable/Disable Lintian Overrides" )
17+
set( BUILD_DEBIAN_PKGING_FLAG ON CACHE BOOL "Internal Status Flag to indicate Debian Packaging Build" )
18+
1119
# Generate static package, when BUILD_SHARED_LIBS is set to OFF.
1220
# Default to ON
1321
option(BUILD_SHARED_LIBS "Build using shared libraries" ON)
@@ -48,11 +56,13 @@ endif()
4856
file(COPY ${PROJECT_SOURCE_DIR}/bin/ DESTINATION ${PROJECT_BINARY_DIR})
4957

5058
# Packaging:
59+
set(PKG_MAINTAINER_NM "ROCm Compiler Support")
60+
set(PKG_MAINTAINER_EMAIL "[email protected]")
5161
set(CPACK_RPM_COMPONENT_INSTALL ON)
5262
set(CPACK_ARCHIVE_COMPONENT_INSTALL ON)
5363
set(CPACK_COMPONENTS_ALL AMD NVIDIA)
5464
set(CPACK_GENERATOR "DEB;RPM;ZIP" CACHE STRING "Default packaging generators")
55-
set(CPACK_PACKAGE_CONTACT "ROCm Compiler Support <[email protected]>")
65+
set(CPACK_PACKAGE_CONTACT "${PKG_MAINTAINER_NM} <${PKG_MAINTAINER_EMAIL}>")
5666
set(CPACK_PACKAGE_DESCRIPTION "HIP Compiler Driver")
5767
set(CPACK_PACKAGE_NAME "${PROJECT_NAME}")
5868
set(CPACK_PACKAGE_VENDOR "Advanced Micro Devices, Inc.")
@@ -174,6 +184,8 @@ install(TARGETS ${HIPCONFIG_BIN}
174184
COMPONENT AMD
175185
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
176186

187+
configure_pkg( ${HIPCC} ${COMP_TYPE} ${CPACK_PACKAGE_VERSION} ${PKG_MAINTAINER_NM} ${PKG_MAINTAINER_EMAIL} )
188+
177189
# NVIDIA specific.
178190
install(FILES
179191
"LICENSE.txt"
@@ -187,6 +199,8 @@ install(TARGETS ${HIPCONFIG_BIN}
187199
COMPONENT NVIDIA
188200
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
189201

202+
configure_pkg( ${HIPCC_NVIDIA} ${COMP_TYPE_NVIDIA} ${CPACK_PACKAGE_VERSION} ${PKG_MAINTAINER_NM} ${PKG_MAINTAINER_EMAIL} )
203+
190204
# TODO: WIN32 check need to be removed if backward
191205
# compatibility is required for WIN32.
192206
option(HIPCC_BACKWARD_COMPATIBILITY "Enable HIPCC backward compatibility" ON)

amd/hipcc/DEBIAN/changelog.in

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
@DEB_PACKAGE_NAME@ (@DEB_PACKAGE_VERSION@) stable; urgency=low
2+
3+
* ROCm Runtime software stack Base Package.
4+
-- @DEB_MAINTAINER_NAME@ <@DEB_MAINTAINER_EMAIL@> @DEB_TIMESTAMP@
5+

amd/hipcc/DEBIAN/copyright.in

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
Format: https://www.debian.org/doc/packaging-manuals/copyright-format/1.0/
2+
Upstream-Name: @DEB_PACKAGE_NAME@
3+
Upstream-Contact: @DEB_MAINTAINER_NAME@ <@DEB_MAINTAINER_EMAIL@>
4+
Source: https://github.com/ROCm/@DEB_PACKAGE_NAME@
5+
Files: *
6+
License: @DEB_LICENSE@
7+
Copyright: @DEB_COPYRIGHT_YEAR@ Advanced Micro Devices, Inc. All rights Reserved.
8+
9+
Permission is hereby granted, free of charge, to any person obtaining a copy
10+
of this software and associated documentation files (the "Software"), to deal
11+
in the Software without restriction, including without limitation the rights
12+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13+
copies of the Software, and to permit persons to whom the Software is
14+
furnished to do so, subject to the following conditions:
15+
16+
The above copyright notice and this permission notice shall be included in all
17+
copies or substantial portions of the Software.
18+
19+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
25+
SOFTWARE.

amd/hipcc/utils.cmake

Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
## Configure Copyright File for Debian Package
2+
function( configure_pkg PACKAGE_NAME_T COMPONENT_NAME_T PACKAGE_VERSION_T MAINTAINER_NM_T MAINTAINER_EMAIL_T)
3+
# Check If Debian Platform
4+
find_file (DEBIAN debian_version debconf.conf PATHS /etc)
5+
if(DEBIAN)
6+
set( BUILD_DEBIAN_PKGING_FLAG ON CACHE BOOL "Internal Status Flag to indicate Debian Packaging Build" FORCE )
7+
set_debian_pkg_cmake_flags( ${PACKAGE_NAME_T} ${PACKAGE_VERSION_T}
8+
${MAINTAINER_NM_T} ${MAINTAINER_EMAIL_T} )
9+
10+
# Create debian directory in build tree
11+
file(MAKE_DIRECTORY "${CMAKE_BINARY_DIR}/DEBIAN")
12+
13+
# Configure the copyright file
14+
configure_file(
15+
"${CMAKE_SOURCE_DIR}/DEBIAN/copyright.in"
16+
"${CMAKE_BINARY_DIR}/DEBIAN/copyright"
17+
@ONLY
18+
)
19+
20+
# Install copyright file
21+
install ( FILES "${CMAKE_BINARY_DIR}/DEBIAN/copyright"
22+
DESTINATION "${CMAKE_INSTALL_DOCDIR}"
23+
COMPONENT ${COMPONENT_NAME_T} )
24+
25+
# Configure the changelog file
26+
configure_file(
27+
"${CMAKE_SOURCE_DIR}/DEBIAN/changelog.in"
28+
"${CMAKE_BINARY_DIR}/DEBIAN/changelog.Debian"
29+
@ONLY
30+
)
31+
32+
# Install Change Log
33+
find_program ( DEB_GZIP_EXEC gzip )
34+
if(EXISTS "${CMAKE_BINARY_DIR}/DEBIAN/changelog.Debian" )
35+
execute_process(
36+
COMMAND ${DEB_GZIP_EXEC} -f -n -9 "${CMAKE_BINARY_DIR}/DEBIAN/changelog.Debian"
37+
WORKING_DIRECTORY "${CMAKE_BINARY_DIR}/DEBIAN"
38+
RESULT_VARIABLE result
39+
OUTPUT_VARIABLE output
40+
ERROR_VARIABLE error
41+
)
42+
if(NOT ${result} EQUAL 0)
43+
message(FATAL_ERROR "Failed to compress: ${error}")
44+
endif()
45+
install ( FILES "${CMAKE_BINARY_DIR}/DEBIAN/${DEB_CHANGELOG_INSTALL_FILENM}"
46+
DESTINATION ${CMAKE_INSTALL_DOCDIR}
47+
COMPONENT ${COMPONENT_NAME_T})
48+
endif()
49+
50+
endif()
51+
endfunction()
52+
53+
# Set variables for changelog and copyright
54+
# For Debian specific Packages
55+
function( set_debian_pkg_cmake_flags DEB_PACKAGE_NAME_T DEB_PACKAGE_VERSION_T DEB_MAINTAINER_NM_T DEB_MAINTAINER_EMAIL_T )
56+
# Setting configure flags
57+
set( DEB_PACKAGE_NAME "${DEB_PACKAGE_NAME_T}" CACHE STRING "Debian Package Name" FORCE )
58+
set( DEB_PACKAGE_VERSION "${DEB_PACKAGE_VERSION_T}" CACHE STRING "Debian Package Version String" )
59+
set( DEB_MAINTAINER_NAME "${DEB_MAINTAINER_NM_T}" CACHE STRING "Debian Package Maintainer Name" )
60+
set( DEB_MAINTAINER_EMAIL "${DEB_MAINTAINER_EMAIL_T}" CACHE STRING "Debian Package Maintainer Email" )
61+
set( DEB_COPYRIGHT_YEAR "2025" CACHE STRING "Debian Package Copyright Year" )
62+
set( DEB_LICENSE "MIT" CACHE STRING "Debian Package License Type" )
63+
set( DEB_CHANGELOG_INSTALL_FILENM "changelog.Debian.gz" CACHE STRING "Debian Package ChangeLog File Name" )
64+
65+
if( BUILD_ENABLE_LINTIAN_OVERRIDES )
66+
set( DEB_OVERRIDES_INSTALL_FILENM "${DEB_PACKAGE_NAME}" CACHE STRING "Debian Package Lintian Override File Name" FORCE )
67+
set( DEB_OVERRIDES_INSTALL_PATH "/usr/share/lintian/overrides/" CACHE STRING "Deb Pkg Lintian Override Install Loc" )
68+
endif()
69+
70+
# Get TimeStamp
71+
find_program( DEB_DATE_TIMESTAMP_EXEC date )
72+
set ( DEB_TIMESTAMP_FORMAT_OPTION "-R" )
73+
execute_process (
74+
COMMAND ${DEB_DATE_TIMESTAMP_EXEC} ${DEB_TIMESTAMP_FORMAT_OPTION}
75+
OUTPUT_VARIABLE TIMESTAMP_T
76+
)
77+
set( DEB_TIMESTAMP "${TIMESTAMP_T}" CACHE STRING "Current Time Stamp for Copyright/Changelog" )
78+
79+
message(STATUS "DEB_PACKAGE_NAME : ${DEB_PACKAGE_NAME}" )
80+
message(STATUS "DEB_PACKAGE_VERSION : ${DEB_PACKAGE_VERSION}" )
81+
message(STATUS "DEB_MAINTAINER_NAME : ${DEB_MAINTAINER_NAME}" )
82+
message(STATUS "DEB_MAINTAINER_EMAIL : ${DEB_MAINTAINER_EMAIL}" )
83+
message(STATUS "DEB_COPYRIGHT_YEAR : ${DEB_COPYRIGHT_YEAR}" )
84+
message(STATUS "DEB_LICENSE : ${DEB_LICENSE}" )
85+
message(STATUS "DEB_TIMESTAMP : ${DEB_TIMESTAMP}" )
86+
message(STATUS "DEB_CHANGELOG_INSTALL_FILENM : ${DEB_CHANGELOG_INSTALL_FILENM}" )
87+
endfunction()
88+

0 commit comments

Comments
 (0)