From a1fd39eb0555da129a0e67c9cf25fe96ece80f26 Mon Sep 17 00:00:00 2001 From: Hayodea Hekol Date: Fri, 6 Mar 2026 01:12:46 -0400 Subject: [PATCH] Improve CPack deb generation --- CMakeLists.txt | 26 ++++++-- cmake/CPackConfig.cmake | 74 +++++++++++++++++---- cmake/debian/postinst | 5 ++ cmake/debian/postrm | 5 ++ cmake/debian/triggers | 1 + commonLibs/attachmentSupport/CMakeLists.txt | 9 ++- commonLibs/livoxProto1/CMakeLists.txt | 9 ++- commonLibs/xcbXorg/CMakeLists.txt | 9 ++- libspinscale | 2 +- stimBuffApis/livoxGen1/CMakeLists.txt | 9 ++- stimBuffApis/xcbWindow/CMakeLists.txt | 9 ++- 11 files changed, 135 insertions(+), 23 deletions(-) create mode 100755 cmake/debian/postinst create mode 100755 cmake/debian/postrm create mode 100644 cmake/debian/triggers diff --git a/CMakeLists.txt b/CMakeLists.txt index d808521..88dbaf7 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -5,6 +5,7 @@ include(CMakeDependentOption) include(${CMAKE_CURRENT_SOURCE_DIR}/cmake/DAPSS.cmake) include(${CMAKE_CURRENT_SOURCE_DIR}/cmake/DebugOpts.cmake) include(${CMAKE_CURRENT_SOURCE_DIR}/cmake/VerifyBoostDynamic.cmake) +include(GNUInstallDirs) # Set C++ standard set(CMAKE_EXPORT_COMPILE_COMMANDS ON) @@ -19,6 +20,13 @@ endif() # Compiler flags set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -pedantic") +# Ensure installed directories use Debian-standard permissions instead of +# inheriting group-writable bits from the build tree. +set(CMAKE_INSTALL_DEFAULT_DIRECTORY_PERMISSIONS + OWNER_READ OWNER_WRITE OWNER_EXECUTE + GROUP_READ GROUP_EXECUTE + WORLD_READ WORLD_EXECUTE) + # Mind oscillator configuration set(MIND_VOSCILLATOR_PERIOD_MS 33 CACHE STRING "Mind's virtual osc clock rate (ms)") if(NOT MIND_VOSCILLATOR_PERIOD_MS GREATER 0) @@ -210,21 +218,29 @@ if(ENABLE_TESTS) add_subdirectory(tests) endif() -install(TARGETS salmanoff DESTINATION bin) +install(TARGETS salmanoff DESTINATION ${CMAKE_INSTALL_BINDIR}) # Install device configuration files (preprocessed .daps files) install(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/devices/ - DESTINATION share/salmanoff/devices + DESTINATION ${CMAKE_INSTALL_DATADIR}/salmanoff/devices + DIRECTORY_PERMISSIONS + OWNER_READ OWNER_WRITE OWNER_EXECUTE + GROUP_READ GROUP_EXECUTE + WORLD_READ WORLD_EXECUTE + FILE_PERMISSIONS + OWNER_READ OWNER_WRITE + GROUP_READ + WORLD_READ FILES_MATCHING PATTERN "*.daps" ) # Install documentation -install(FILES README.md DESTINATION share/doc/salmanoff) -install(FILES LICENSE DESTINATION share/doc/salmanoff) +install(FILES README.md DESTINATION ${CMAKE_INSTALL_DOCDIR}) +install(FILES LICENSE DESTINATION ${CMAKE_INSTALL_DOCDIR}) # Install example configurations if they exist if(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/examples") - install(DIRECTORY examples/ DESTINATION share/salmanoff/examples) + install(DIRECTORY examples/ DESTINATION ${CMAKE_INSTALL_DATADIR}/salmanoff/examples) endif() # Include CPack configuration diff --git a/cmake/CPackConfig.cmake b/cmake/CPackConfig.cmake index 3e25f53..e3eb6bc 100644 --- a/cmake/CPackConfig.cmake +++ b/cmake/CPackConfig.cmake @@ -5,22 +5,48 @@ set(CPACK_PACKAGE_NAME "${PROJECT_NAME}") set(CPACK_PACKAGE_VERSION "${PROJECT_VERSION}") set(CPACK_PACKAGE_DESCRIPTION_SUMMARY - "Salmanoff - A sensor management and control system") + "Cognitive robotics runtime") set(CPACK_PACKAGE_VENDOR "Salmanoff Project") set(CPACK_PACKAGE_CONTACT "maintainer@salmanoff.org") -# Set package description -set(CPACK_PACKAGE_DESCRIPTION - "Salmanoff is a comprehensive sensor management and control system that\n" - "provides unified interfaces for various sensor devices including LiDAR\n" - "systems. It features modular architecture with support for multiple\n" - "device types, asynchronous processing, and real-time data handling." -) +# Set package description. +# Use a single joined string so CMake does not serialize it as a semicolon list +# in the generated Debian control file. +string(JOIN "\n " + CPACK_PACKAGE_DESCRIPTION + "Comprehensive sensor management and control runtime." + "" + "Salmanoff provides unified interfaces for various sensor devices," + "including LiDAR systems." + "It features modular architecture with support for multiple device" + "types, asynchronous processing, and real-time data handling.") # License information set(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_CURRENT_SOURCE_DIR}/LICENSE") set(CPACK_RESOURCE_FILE_README "${CMAKE_CURRENT_SOURCE_DIR}/README.md") +# Debian-specific packaged documentation. +set(SALMANOFF_CHANGELOG_TXT "${CMAKE_CURRENT_BINARY_DIR}/changelog") +set(SALMANOFF_CHANGELOG_GZ "${CMAKE_CURRENT_BINARY_DIR}/changelog.gz") +file(WRITE "${SALMANOFF_CHANGELOG_TXT}" + "salmanoff (${PROJECT_VERSION}) unstable; urgency=medium\n\n" + " * Package release.\n\n" + " -- Salmanoff Project Fri, 06 Mar 2026 00:00:00 +0000\n") +execute_process( + COMMAND gzip -n -9 -c "${SALMANOFF_CHANGELOG_TXT}" + OUTPUT_FILE "${SALMANOFF_CHANGELOG_GZ}" +) + +set(SALMANOFF_MANPAGE_GZ "${CMAKE_CURRENT_BINARY_DIR}/salmanoff.1.gz") +execute_process( + COMMAND gzip -n -9 -c "${CMAKE_CURRENT_SOURCE_DIR}/docs/salmanoff.1" + OUTPUT_FILE "${SALMANOFF_MANPAGE_GZ}" +) + +install(FILES "${SALMANOFF_CHANGELOG_GZ}" DESTINATION ${CMAKE_INSTALL_DOCDIR}) +install(FILES "${SALMANOFF_MANPAGE_GZ}" DESTINATION ${CMAKE_INSTALL_MANDIR}/man1) +install(FILES LICENSE DESTINATION ${CMAKE_INSTALL_DOCDIR} RENAME copyright) + # Enable deb and rpm generators set(CPACK_GENERATOR "DEB;RPM") @@ -36,9 +62,12 @@ set(CPACK_DEBIAN_PACKAGE_DISTRIBUTION "ubuntu") set(CPACK_DEBIAN_PACKAGE_BUILD_DEPENDS "build-essential, cmake (>= 3.16), libboost-all-dev, flex, bison, ocl-icd-opencl-dev, liburing-dev") -# Runtime dependencies (from builddeps file - runtime equivalents) -set(CPACK_DEBIAN_PACKAGE_DEPENDS - "libboost-system1.74.0 | libboost-system1.73.0 | libboost-system1.72.0, libboost-log1.74.0 | libboost-log1.73.0 | libboost-log1.72.0, libc6, libstdc++6, ocl-icd-libopencl1 | libopencl1, liburing2 | liburing1") +# Runtime dependencies. +# Let dpkg-shlibdeps derive the actual ELF dependencies from the built +# binaries/libraries. Hard-coding old Boost soname packages here makes the +# package unnecessarily pull obsolete runtimes on newer distros, and in this +# tree the generated binaries are not currently linked against Boost DSOs. +set(CPACK_DEBIAN_PACKAGE_DEPENDS "") set(CPACK_DEBIAN_PACKAGE_RECOMMENDS "libxcb1, libx11-6") set(CPACK_DEBIAN_PACKAGE_SUGGESTS "livox-sdk") @@ -49,9 +78,19 @@ set(CPACK_RPM_PACKAGE_URL "https://github.com/salmanoff/salmanoff") set(CPACK_RPM_PACKAGE_REQUIRES "boost-system >= 1.72.0, boost-log >= 1.72.0, glibc, libstdc++, ocl-icd, liburing") set(CPACK_RPM_PACKAGE_SUGGESTS "xcb, libX11, livox-sdk") +# Package file naming using Debian's architecture naming when available. +set(CPACK_DEBIAN_PACKAGE_ARCHITECTURE "${CMAKE_SYSTEM_PROCESSOR}") +if(EXISTS "/usr/bin/dpkg") + execute_process( + COMMAND /usr/bin/dpkg --print-architecture + OUTPUT_VARIABLE CPACK_DEBIAN_PACKAGE_ARCHITECTURE + OUTPUT_STRIP_TRAILING_WHITESPACE + ) +endif() + # Package file naming using project variables set(CPACK_PACKAGE_FILE_NAME - "${CPACK_PACKAGE_NAME}-${CPACK_PACKAGE_VERSION}-${CMAKE_SYSTEM_PROCESSOR}") + "${CPACK_PACKAGE_NAME}-${CPACK_PACKAGE_VERSION}-${CPACK_DEBIAN_PACKAGE_ARCHITECTURE}") # Enable automatic dependency detection for Debian packages # This uses dpkg-shlibdeps to automatically detect shared library dependencies @@ -60,3 +99,14 @@ set(CPACK_DEBIAN_PACKAGE_SHLIBDEPS ON) # Set compression set(CPACK_DEB_COMPONENT_INSTALL ON) set(CPACK_RPM_COMPONENT_INSTALL ON) + +# Generate standard Debian shared-library metadata and use triggers instead of +# maintainer scripts for ldconfig handling. +set(CPACK_DEBIAN_PACKAGE_GENERATE_SHLIBS ON) +set(CPACK_DEBIAN_PACKAGE_CONTROL_EXTRA + "${CMAKE_CURRENT_SOURCE_DIR}/cmake/debian/postinst" + "${CMAKE_CURRENT_SOURCE_DIR}/cmake/debian/postrm" + "${CMAKE_CURRENT_SOURCE_DIR}/cmake/debian/triggers") + +# Ship stripped binaries in the primary package. +set(CPACK_STRIP_FILES ON) diff --git a/cmake/debian/postinst b/cmake/debian/postinst new file mode 100755 index 0000000..8047726 --- /dev/null +++ b/cmake/debian/postinst @@ -0,0 +1,5 @@ +#!/bin/sh +set -e + +# ldconfig is handled via the package trigger. +exit 0 diff --git a/cmake/debian/postrm b/cmake/debian/postrm new file mode 100755 index 0000000..8047726 --- /dev/null +++ b/cmake/debian/postrm @@ -0,0 +1,5 @@ +#!/bin/sh +set -e + +# ldconfig is handled via the package trigger. +exit 0 diff --git a/cmake/debian/triggers b/cmake/debian/triggers new file mode 100644 index 0000000..dd86603 --- /dev/null +++ b/cmake/debian/triggers @@ -0,0 +1 @@ +activate-noawait ldconfig diff --git a/commonLibs/attachmentSupport/CMakeLists.txt b/commonLibs/attachmentSupport/CMakeLists.txt index 6244c5b..df4a7e0 100644 --- a/commonLibs/attachmentSupport/CMakeLists.txt +++ b/commonLibs/attachmentSupport/CMakeLists.txt @@ -4,6 +4,11 @@ add_library(attachmentSupport SHARED stagingBuffer.cpp ) +set_target_properties(attachmentSupport PROPERTIES + VERSION ${PROJECT_VERSION} + SOVERSION ${PROJECT_VERSION_MAJOR} +) + target_include_directories(attachmentSupport PUBLIC ${Boost_INCLUDE_DIRS} ${CMAKE_SOURCE_DIR}/include @@ -24,4 +29,6 @@ add_custom_command(TARGET attachmentSupport POST_BUILD ) # Install rules -install(TARGETS attachmentSupport DESTINATION lib) +install(TARGETS attachmentSupport + LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} NAMELINK_SKIP +) diff --git a/commonLibs/livoxProto1/CMakeLists.txt b/commonLibs/livoxProto1/CMakeLists.txt index f915240..ae42203 100644 --- a/commonLibs/livoxProto1/CMakeLists.txt +++ b/commonLibs/livoxProto1/CMakeLists.txt @@ -10,6 +10,11 @@ if(ENABLE_LIB_livoxProto1) udpCommandDemuxer.cpp ) + set_target_properties(livoxProto1 PROPERTIES + VERSION ${PROJECT_VERSION} + SOVERSION ${PROJECT_VERSION_MAJOR} + ) + # Set config define for header generation add_compile_definitions(CONFIG_LIB_LIVOXPROTO1_ENABLED) target_include_directories(livoxProto1 PUBLIC ${Boost_INCLUDE_DIRS}) @@ -25,5 +30,7 @@ if(ENABLE_LIB_livoxProto1) ) # Install rules - install(TARGETS livoxProto1 DESTINATION lib) + install(TARGETS livoxProto1 + LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} NAMELINK_SKIP + ) endif() diff --git a/commonLibs/xcbXorg/CMakeLists.txt b/commonLibs/xcbXorg/CMakeLists.txt index 7dfff32..7b5e3a9 100644 --- a/commonLibs/xcbXorg/CMakeLists.txt +++ b/commonLibs/xcbXorg/CMakeLists.txt @@ -10,11 +10,18 @@ if(ENABLE_LIB_xcbXorg) xcbXorg.cpp ) + set_target_properties(xcbXorg PROPERTIES + VERSION ${PROJECT_VERSION} + SOVERSION ${PROJECT_VERSION_MAJOR} + ) + # Set config define for header generation add_compile_definitions(CONFIG_LIB_XCBXORG_ENABLED) target_include_directories(xcbXorg PUBLIC ${XCB_INCLUDE_DIRS}) target_link_libraries(xcbXorg ${XCB_LIBRARIES} attachmentSupport) # Install rules - install(TARGETS xcbXorg DESTINATION lib) + install(TARGETS xcbXorg + LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} NAMELINK_SKIP + ) endif() diff --git a/libspinscale b/libspinscale index 596ad36..b6eb502 160000 --- a/libspinscale +++ b/libspinscale @@ -1 +1 @@ -Subproject commit 596ad367e2678092f52428185661e33b8f03867a +Subproject commit b6eb502e56747b6a16b1ee83587e90e88137e4ce diff --git a/stimBuffApis/livoxGen1/CMakeLists.txt b/stimBuffApis/livoxGen1/CMakeLists.txt index 26505af..166d9f8 100644 --- a/stimBuffApis/livoxGen1/CMakeLists.txt +++ b/stimBuffApis/livoxGen1/CMakeLists.txt @@ -20,6 +20,11 @@ if(ENABLE_STIMBUFFAPI_livoxGen1) openClKernels.cl.S ) + set_target_properties(livoxGen1 PROPERTIES + VERSION ${PROJECT_VERSION} + SOVERSION ${PROJECT_VERSION_MAJOR} + ) + # Set assembler working directory so .incbin can find the .cl file # Also declare dependency on collateDgrams.cl and slotCompactor.cl set_source_files_properties(openClKernels.cl.S PROPERTIES @@ -54,5 +59,7 @@ if(ENABLE_STIMBUFFAPI_livoxGen1) ) # Install rules - install(TARGETS livoxGen1 DESTINATION lib) + install(TARGETS livoxGen1 + LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} NAMELINK_SKIP + ) endif() diff --git a/stimBuffApis/xcbWindow/CMakeLists.txt b/stimBuffApis/xcbWindow/CMakeLists.txt index 1e0094b..f58f9e2 100644 --- a/stimBuffApis/xcbWindow/CMakeLists.txt +++ b/stimBuffApis/xcbWindow/CMakeLists.txt @@ -11,6 +11,11 @@ if(ENABLE_STIMBUFFAPI_xcbWindow) xcbWindow.cpp ) + set_target_properties(xcbWindow PROPERTIES + VERSION ${PROJECT_VERSION} + SOVERSION ${PROJECT_VERSION_MAJOR} + ) + target_include_directories(xcbWindow PUBLIC ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/../../include @@ -26,5 +31,7 @@ if(ENABLE_STIMBUFFAPI_xcbWindow) attachmentSupport) # Install rules - install(TARGETS xcbWindow DESTINATION lib) + install(TARGETS xcbWindow + LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} NAMELINK_SKIP + ) endif()