cmake – cpack组件安装deb为空

huangapple go评论60阅读模式
英文:

cmake - cpack component install deb is empty

问题

我想获取特定组件的deb软件包。当我使用特定的工具链文件IMX6IMX8时,会设置变量。在使用IMX6时的输出:

运行CPack打包工具...
CPack: 使用DEB创建软件包
CPack: 安装项目
CPack: - 为主项目运行preinstall目标
CPack: - 安装项目:主项目 []
CPack: -   安装组件:PRIMARY_DISPLAY
CPack: -   安装组件:SECONDARY_DISPLAY
CPack: 创建软件包
-- 未设置CPACK_DEBIAN_PACKAGE_DEPENDS,软件包将没有依赖项。
-- 未设置CPACK_DEBIAN_PACKAGE_DEPENDS,软件包将没有依赖项。
CPack: - 软件包:/home/anzipex/Downloads/add_target_package_secondary_47154/debs_47154/unca_23/cmake-build-release-imx6/unca-1.0.1-Linux-PRIMARY_DISPLAY.deb 已生成。
CPack: - 软件包:/home/anzipex/Downloads/add_target_package_secondary_47154/debs_47154/unca_23/cmake-build-release-imx6/unca-1.0.1-Linux-SECONDARY_DISPLAY.deb 已生成。

问题在于创建的deb软件包内部是空的。在目录_CPack_Packages中,deb软件包包含data.tar.gz,其中只包含空的usr目录。但是如果我设置这个变量:
set(CPACK_MONOLITHIC_INSTALL 1),主要的deb软件包中包含所有数据。出了什么问题?

我的主要CMakeLists.txt看起来像这样:

cmake_minimum_required(VERSION 3.0.0)

set(CPACK_GENERATOR "DEB")
set(CPACK_DEBIAN_PACKAGE_MAINTAINER "Company")
set(CPACK_PACKAGE_VERSION ${PROJECT_VERSION})
set(CPACK_DEB_COMPONENT_INSTALL ON)

if(NOT CMAKE_CROSSCOMPILING)
    set(CPACK_COMPONENTS_ALL DESKTOP)
    set(CPACK_DEBIAN_DESKTOP_PACKAGE_ARCHITECTURE "amd64")
    add_subdirectory(desktop)
elseif(IMX6)
    set(CPACK_COMPONENTS_ALL PRIMARY_DISPLAY SECONDARY_DISPLAY)
    set(CPACK_DEBIAN_PRIMARY_DISPLAY_PACKAGE_ARCHITECTURE "armhf")
    set(CPACK_DEBIAN_SECONDARY_DISPLAY_PACKAGE_ARCHITECTURE "armhf")
    add_subdirectory(primary_display)
    add_subdirectory(secondary_display)
elseif(IMX8)
    set(CPACK_COMPONENTS_ALL PRIMARY_DISPLAY SECONDARY_DISPLAY)
    set(CPACK_DEBIAN_PRIMARY_DISPLAY_PACKAGE_ARCHITECTURE "arm64")
    set(CPACK_DEBIAN_SECONDARY_DISPLAY_PACKAGE_ARCHITECTURE "arm64")
    add_subdirectory(primary_display)
    add_subdirectory(secondary_display)
endif()

include(CPack)

secondary_display/CMakeLists.txt的示例:

cmake_minimum_required(VERSION 3.0.0)

install(DIRECTORY ${PROJECT_SOURCE_DIR}/apps/secondary_display/resources DESTINATION /opt/unca COMPONENT secondary_display)

install(TARGETS secondary_display DESTINATION /opt/unca COMPONENT secondary_display)
install(TARGETS ahrs DESTINATION /opt/unca COMPONENT secondary_display)
install(TARGETS sns DESTINATION /opt/unca COMPONENT secondary_display)

install(DIRECTORY DESTINATION /var/opt/unca COMPONENT secondary_display
    DIRECTORY_PERMISSIONS
    OWNER_WRITE OWNER_READ OWNER_EXECUTE
    GROUP_WRITE GROUP_READ GROUP_EXECUTE
    WORLD_WRITE WORLD_READ WORLD_EXECUTE
)
install(FILES ${PROJECT_SOURCE_DIR}/resources/configs/net.xml DESTINATION /var/opt/unca COMPONENT secondary_display)

install(FILES services/unca-secondary-display.service DESTINATION /etc/systemd/system/ COMPONENT secondary_display)
install(FILES services/unca-ahrs.service DESTINATION /etc/systemd/system/ COMPONENT secondary_display)
install(FILES services/unca-sns.service DESTINATION /etc/systemd/system/ COMPONENT secondary_display)

set(CPACK_DEBIAN_SECONDARY_DISPLAY_PACKAGE_NAME "unca-secondary-display")
set(CPACK_DEBIAN_SECONDARY_DISPLAY_FILE_NAME "unca-secondary-display-${CPACK_PACKAGE_VERSION}-${CPACK_DEBIAN_DESKTOP_PACKAGE_ARCHITECTURE}.deb")
set(CPACK_DEBIAN_SECONDARY_DISPLAY_DESCRIPTION "UNCA SECONDARY DISPLAY")

string(CONCAT CPACK_DEBIAN_SECONDARY_DISPLAY_PACKAGE_CONTROL_EXTRA
    "${CMAKE_CURRENT_SOURCE_DIR}/debian/prerm;"
    "${CMAKE_CURRENT_SOURCE_DIR}/debian/preinst;"
    "${CMAKE_CURRENT_SOURCE_DIR}/debian/postinst"
)
英文:

I want to get deb packages of specific components. When I'm using specific toolchain file IMX6 or IMX8 variables are set. Output when using IMX6:

Run CPack packaging tool...
CPack: Create package using DEB
CPack: Install projects
CPack: - Run preinstall target for: main_project
CPack: - Install project: main_project []
CPack: -   Install component: PRIMARY_DISPLAY
CPack: -   Install component: SECONDARY_DISPLAY
CPack: Create package
-- CPACK_DEBIAN_PACKAGE_DEPENDS not set, the package will have no dependencies.
-- CPACK_DEBIAN_PACKAGE_DEPENDS not set, the package will have no dependencies.
CPack: - package: /home/anzipex/Downloads/add_target_package_secondary_47154/debs_47154/unca_23/cmake-build-release-imx6/unca-1.0.1-Linux-PRIMARY_DISPLAY.deb generated.
CPack: - package: /home/anzipex/Downloads/add_target_package_secondary_47154/debs_47154/unca_23/cmake-build-release-imx6/unca-1.0.1-Linux-SECONDARY_DISPLAY.deb generated.

The problem is that created deb packages are empty inside. In directory _CPack_Packages deb packages have data.tar.gz and contains only empty usr directory. However if i set this variable:
set(CPACK_MONOLITHIC_INSTALL 1) main deb package has all data. What's wrong with that?

My main CMakeLists.txt looks like this:

cmake_minimum_required(VERSION 3.0.0)

set(CPACK_GENERATOR "DEB")
set(CPACK_DEBIAN_PACKAGE_MAINTAINER "Company")
set(CPACK_PACKAGE_VERSION ${PROJECT_VERSION})
set(CPACK_DEB_COMPONENT_INSTALL ON)

if(NOT CMAKE_CROSSCOMPILING)
    set(CPACK_COMPONENTS_ALL DESKTOP)
    set(CPACK_DEBIAN_DESKTOP_PACKAGE_ARCHITECTURE "amd64")
    add_subdirectory(desktop)
elseif(IMX6)
    set(CPACK_COMPONENTS_ALL PRIMARY_DISPLAY SECONDARY_DISPLAY)
    set(CPACK_DEBIAN_PRIMARY_DISPLAY_PACKAGE_ARCHITECTURE "armhf")
    set(CPACK_DEBIAN_SECONDARY_DISPLAY_PACKAGE_ARCHITECTURE "armhf")
    add_subdirectory(primary_display)
    add_subdirectory(secondary_display)
elseif(IMX8)
    set(CPACK_COMPONENTS_ALL PRIMARY_DISPLAY SECONDARY_DISPLAY)
    set(CPACK_DEBIAN_PRIMARY_DISPLAY_PACKAGE_ARCHITECTURE "arm64")
    set(CPACK_DEBIAN_SECONDARY_DISPLAY_PACKAGE_ARCHITECTURE "arm64")
    add_subdirectory(primary_display)
    add_subdirectory(secondary_display)
endif()

include(CPack)

Example of secondary_display/CMakeLists.txt:

cmake_minimum_required(VERSION 3.0.0)

install(DIRECTORY ${PROJECT_SOURCE_DIR}/apps/secondary_display/resources DESTINATION /opt/unca COMPONENT secondary_display)

install(TARGETS secondary_display DESTINATION /opt/unca COMPONENT secondary_display)
install(TARGETS ahrs DESTINATION /opt/unca COMPONENT secondary_display)
install(TARGETS sns DESTINATION /opt/unca COMPONENT secondary_display)

install(DIRECTORY DESTINATION /var/opt/unca COMPONENT secondary_display
    DIRECTORY_PERMISSIONS
    OWNER_WRITE OWNER_READ OWNER_EXECUTE
    GROUP_WRITE GROUP_READ GROUP_EXECUTE
    WORLD_WRITE WORLD_READ WORLD_EXECUTE
)
install(FILES ${PROJECT_SOURCE_DIR}/resources/configs/net.xml DESTINATION /var/opt/unca COMPONENT secondary_display)

install(FILES services/unca-secondary-display.service DESTINATION /etc/systemd/system/ COMPONENT secondary_display)
install(FILES services/unca-ahrs.service DESTINATION /etc/systemd/system/ COMPONENT secondary_display)
install(FILES services/unca-sns.service DESTINATION /etc/systemd/system/ COMPONENT secondary_display)

set(CPACK_DEBIAN_SECONDARY_DISPLAY_PACKAGE_NAME "unca-secondary-display")
set(CPACK_DEBIAN_SECONDARY_DISPLAY_FILE_NAME "unca-secondary-display-${CPACK_PACKAGE_VERSION}-${CPACK_DEBIAN_DESKTOP_PACKAGE_ARCHITECTURE}.deb")
set(CPACK_DEBIAN_SECONDARY_DISPLAY_DESCRIPTION "UNCA SECONDARY DISPLAY")

string(CONCAT CPACK_DEBIAN_SECONDARY_DISPLAY_PACKAGE_CONTROL_EXTRA
    "${CMAKE_CURRENT_SOURCE_DIR}/debian/prerm;"
    "${CMAKE_CURRENT_SOURCE_DIR}/debian/preinst;"
    "${CMAKE_CURRENT_SOURCE_DIR}/debian/postinst"
)

答案1

得分: 0

Lines with CPACK_COMPONENTS_ALL should be deleted from if in main CMakeLists.txt.

英文:

Lines with CPACK_COMPONENTS_ALL should be deleted from if in main CMakeLists.txt

huangapple
  • 本文由 发表于 2023年6月30日 00:17:00
  • 转载请务必保留本文链接:https://go.coder-hub.com/76582876.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定