Set up recipe for Debian package generation.

This commit is contained in:
tastytea 2021-05-26 10:18:45 +02:00
parent ab3b98c1b7
commit 8114d1a200
Signed by: tastytea
GPG Key ID: CFC39497F1B26E07
3 changed files with 39 additions and 1 deletions

View File

@ -47,3 +47,5 @@ endif()
add_subdirectory(translations)
add_subdirectory(man)
include(cmake/packages.cmake)

View File

@ -123,7 +123,13 @@ cmake ..
cmake --build . -- --jobs=$(nproc --ignore=1)
--------------------------------------------------------------------------------
To install, run `sudo make install`. To run the tests, run `cd tests && ctest`.
To install, run `sudo make install`. To run the tests, run `cd tests &&
ctest`.
[TIP]
If you are using Debian or Ubuntu, or a distribution that is derived from these,
you can run `cpack -G DEB` in the build directory to generate a .deb-file. You
can then install it with `apt install ./epubgrep-*.deb`.
.CMake options:
* `-DCMAKE_BUILD_TYPE=Debug` for a debug build.

30
cmake/packages.cmake Normal file
View File

@ -0,0 +1,30 @@
include(GNUInstallDirs)
set(CPACK_PACKAGE_CHECKSUM "SHA512")
set(CPACK_RESOURCE_FILE_LICENSE "${PROJECT_SOURCE_DIR}/LICENSE")
set(CPACK_PACKAGE_CONTACT "tastytea <tastytea@tastytea.de>")
# Should be set automatically, but they are not.
set(CPACK_PACKAGE_NAME "${PROJECT_NAME}")
set(CPACK_PACKAGE_VERSION "${PROJECT_VERSION}")
# Figure out dependencies automatically.
set(CPACK_DEBIAN_PACKAGE_SHLIBDEPS ON)
# Should be set automatically, but it is not.
execute_process(COMMAND dpkg --print-architecture
OUTPUT_VARIABLE CPACK_DEBIAN_PACKAGE_ARCHITECTURE
OUTPUT_STRIP_TRAILING_WHITESPACE)
execute_process(COMMAND lsb_release --codename --short
OUTPUT_VARIABLE DEBIAN_CODENAME
OUTPUT_STRIP_TRAILING_WHITESPACE)
if ("${DEBIAN_CODENAME}" STREQUAL "n/a")
set(DEBIAN_CODENAME "unknown")
endif()
# The default does not produce valid Debian package names.
set(CPACK_DEBIAN_FILE_NAME
"${CPACK_PACKAGE_NAME}_${CPACK_PACKAGE_VERSION}-0_${CPACK_DEBIAN_PACKAGE_ARCHITECTURE}_${DEBIAN_CODENAME}.deb")
include(CPack)