Skip to content

Commit d5afe9e

Browse files
committed
🛠️ chore(package): Create deb package
1 parent 2753b2f commit d5afe9e

File tree

3 files changed

+65
-0
lines changed

3 files changed

+65
-0
lines changed

CMakeLists.txt

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -302,3 +302,24 @@ else()
302302
COMMAND ${CMAKE_COMMAND} -E echo "uncrustify not found; install it"
303303
)
304304
endif()
305+
306+
# Debian package configuration
307+
set(CPACK_GENERATOR "DEB")
308+
set(CPACK_PACKAGE_NAME "libserial")
309+
set(CPACK_PACKAGE_VERSION "${PROJECT_VERSION}")
310+
set(CPACK_PACKAGE_CONTACT "Nestor Pereira Neto <[email protected]>")
311+
set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "Modern C++ serial port communication library")
312+
set(CPACK_PACKAGE_DESCRIPTION "A modern C++ library for serial port communication on Linux systems using termios2 for arbitrary baud rates.")
313+
set(CPACK_DEBIAN_PACKAGE_MAINTAINER "Nestor Pereira Neto <[email protected]>")
314+
set(CPACK_DEBIAN_PACKAGE_SECTION "libs")
315+
set(CPACK_DEBIAN_PACKAGE_PRIORITY "optional")
316+
set(CPACK_DEBIAN_PACKAGE_HOMEPAGE "https://github.com/NestorDP/cppserial")
317+
318+
# Debian dependencies
319+
set(CPACK_DEBIAN_PACKAGE_DEPENDS "libc6 (>= 2.27)")
320+
321+
# Generate package files
322+
set(CPACK_DEBIAN_PACKAGE_CONTROL_EXTRA "${CMAKE_CURRENT_SOURCE_DIR}/debian/postinst;${CMAKE_CURRENT_SOURCE_DIR}/debian/postrm")
323+
324+
# Include CPack
325+
include(CPack)

debian/postinst

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
#!/bin/bash
2+
# postinst script for libserial
3+
# This script runs after the package is installed
4+
5+
set -e
6+
7+
case "$1" in
8+
configure)
9+
# Update the shared library cache
10+
ldconfig
11+
;;
12+
13+
abort-upgrade|abort-remove|abort-deconfigure)
14+
;;
15+
16+
*)
17+
echo "postinst called with unknown argument \`$1'" >&2
18+
exit 1
19+
;;
20+
esac
21+
22+
exit 0

debian/postrm

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
#!/bin/bash
2+
# postrm script for libserial
3+
# This script runs after the package is removed
4+
5+
set -e
6+
7+
case "$1" in
8+
remove|purge)
9+
# Update the shared library cache
10+
ldconfig
11+
;;
12+
13+
upgrade|failed-upgrade|abort-install|abort-upgrade|disappear)
14+
;;
15+
16+
*)
17+
echo "postrm called with unknown argument \`$1'" >&2
18+
exit 1
19+
;;
20+
esac
21+
22+
exit 0

0 commit comments

Comments
 (0)