Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cmake/Cpack Debian packaging - producing correct package name

Tags:

debian

cpack

I'm attempting to build a properly named Debian package using Cpack. I have the following in my CMakeLists.txt:

set(CPACK_PACKAGE_NAME "something")
set(CPACK_DEBIAN_PACKAGE_ARCHITECTURE "amd64")
set(CPACK_PACKAGE_ARCHITECTURE "amd64")
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}")

but I get file named:

 something-0.9.0-Linux.deb

Instead of:

something-0.9.0_amd64.deb

I've looked at the various documentation pages but haven't found the answer.

like image 710
Craig S. Anderson Avatar asked May 05 '18 03:05

Craig S. Anderson


2 Answers

Cpack does not have CPACK_DEBIAN_PACKAGE_FILE_NAME, may be this should be reported as bug, not all GNU/Linux-BSD systems have same package naming convention.

For now, You can set CPACK_PACKAGE_FILE_NAME which is set by default to:

${CPACK_PACKAGE_NAME}-${CPACK_PACKAGE_VERSION}-${CPACK_SYSTEM_NAME}.

Follow the link to read the full documentation page.

CPACK_DEBIAN_PACKAGE_ARCHITECTURE

The Debian package architecture

Mandatory : YES
Default : Output of `dpkg --print-architecture` (or 'i386' if dpkg is not found)

You may set the file name as:

set(CPACK_PACKAGE_FILE_NAME "${CPACK_DEBIAN_PACKAGE_NAME}-${CPACK_DEBIAN_PACKAGE_VERSION}-${CPACK_DEBIAN_PACKAGE_ARCHITECTURE}.")

By the way, no need to override defaults if they are good.

  • CPACK_DEBIAN_PACKAGE_ARCHITECTURE defaults to dpkg --print-architecture
  • CPACK_DEBIAN_PACKAGE_VERSION defaults to CPACK_PACKAGE_VERSION which by itself is built from major.minor.patch.
like image 167
user.dz Avatar answered Sep 18 '22 07:09

user.dz


Update for cmake >=3.6: Use

set(CPACK_DEBIAN_FILE_NAME DEB-DEFAULT)

Please note that explicitly setting the default is necessary here. Quoting the docs:

Preferred setting of this variable is DEB-DEFAULT but for backward compatibility with CPackDeb in CMake prior to version 3.6 this feature is disabled by default.

like image 20
spawn Avatar answered Sep 20 '22 07:09

spawn