You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

使用CMake/CPack制作Debian包:生成正确的包名称

Fixing Debian Package Naming with CPack

To generate a Debian package that follows the official naming convention (package_name_version_architecture.deb), you need to adjust your CPack configuration to prioritize Debian-specific filename formatting. Here's how to fix your setup:

Updated CMakeLists.txt Snippet

# Core package metadata
set(CPACK_PACKAGE_NAME "something")
set(CPACK_PACKAGE_VERSION_MAJOR "0")
set(CPACK_PACKAGE_VERSION_MINOR "9")
set(CPACK_PACKAGE_VERSION_PATCH "0")
set(CPACK_PACKAGE_VERSION "${CPACK_PACKAGE_VERSION_MAJOR}.${CPACK_PACKAGE_VERSION_MINOR}.${CPACK_PACKAGE_VERSION_PATCH}")

# Architecture configuration (generic + Debian-specific)
set(CPACK_PACKAGE_ARCHITECTURE "amd64")
set(CPACK_DEBIAN_PACKAGE_ARCHITECTURE "${CPACK_PACKAGE_ARCHITECTURE}")

# Critical: Enable Debian-standard filename structure
set(CPACK_DEBIAN_FILE_NAME "DEB-DEFAULT")

What's Fixed & Why

The main issue with your original config was missing the CPACK_DEBIAN_FILE_NAME variable. By setting it to "DEB-DEFAULT", you tell CPack to use Debian's required naming schema (using underscores instead of hyphens) instead of the generic CPack format that produces hyphen-separated filenames like something-0.9.0-amd64.deb.

We retained your existing version and architecture settings, but linked the Debian-specific architecture variable to the generic one for consistency – this avoids redundant configuration and reduces the chance of mismatches.

Extra Tips

  • If you need a custom filename (instead of strict Debian defaults), you can define CPACK_DEBIAN_FILE_NAME explicitly, e.g.:
    set(CPACK_DEBIAN_FILE_NAME "${CPACK_PACKAGE_NAME}_${CPACK_PACKAGE_VERSION}_${CPACK_DEBIAN_PACKAGE_ARCHITECTURE}.deb")
    
    But sticking to DEB-DEFAULT is recommended to ensure compatibility with Debian package tools and repositories.
  • Debian package names typically use lowercase letters – your current "something" is already compliant here, but keep this in mind for future packages.

内容的提问来源于stack exchange,提问作者Craig S. Anderson

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.27 03:22:47