Commit b7d15a15a418736cc36d809597dfa3ce53ac5467

Authored by Wiebe Cazemier
1 parent 51127c3d

Build deb file with cpack using CI

.travis.yml
@@ -14,9 +14,25 @@ jobs: @@ -14,9 +14,25 @@ jobs:
14 - name: "Ubuntu 20.04 | GCC" 14 - name: "Ubuntu 20.04 | GCC"
15 dist: focal 15 dist: focal
16 compiler: gcc 16 compiler: gcc
  17 + - name: "Debian 11 | GCC"
  18 + dist: bullseye
  19 + compiler: gcc
  20 + - name: "Debian 11 | Clang"
  21 + dist: bullseye
  22 + compiler: clang
  23 + - name: "Debian 10 | GCC"
  24 + dist: buster
  25 + compiler: gcc
  26 + - name: "Debian 10 | Clang"
  27 + dist: buster
  28 + compiler: clang
17 29
18 script: 30 script:
19 - set -e # If any step reports a problem consider the whole build a failure 31 - set -e # If any step reports a problem consider the whole build a failure
  32 +- sudo apt update
  33 +- sudo apt install -y shellcheck
  34 +- shellcheck debian/post* debian/pre*
20 - ./build.sh 35 - ./build.sh
21 - ./FlashMQBuildRelease/FlashMQ --version 36 - ./FlashMQBuildRelease/FlashMQ --version
  37 +- sudo dpkg -i ./FlashMQBuildRelease/*.deb
22 - set +e # Prevent Travis internals from breaking our build, see https://github.com/travis-ci/travis-ci/issues/891 38 - set +e # Prevent Travis internals from breaking our build, see https://github.com/travis-ci/travis-ci/issues/891
CMakeLists.txt
1 cmake_minimum_required(VERSION 3.5) 1 cmake_minimum_required(VERSION 3.5)
  2 +cmake_policy(SET CMP0048 NEW)
2 include(CheckCXXCompilerFlag) 3 include(CheckCXXCompilerFlag)
3 4
4 -project(FlashMQ LANGUAGES CXX) 5 +project(FlashMQ VERSION 0.9.2 LANGUAGES CXX)
5 6
6 add_definitions(-DOPENSSL_API_COMPAT=0x10100000L) 7 add_definitions(-DOPENSSL_API_COMPAT=0x10100000L)
  8 +add_definitions(-DFLASHMQ_VERSION=\"${PROJECT_VERSION}\")
7 9
8 set(CMAKE_CXX_STANDARD 11) 10 set(CMAKE_CXX_STANDARD 11)
9 set(CMAKE_CXX_STANDARD_REQUIRED ON) 11 set(CMAKE_CXX_STANDARD_REQUIRED ON)
@@ -95,3 +97,23 @@ add_executable(FlashMQ @@ -95,3 +97,23 @@ add_executable(FlashMQ
95 ) 97 )
96 98
97 target_link_libraries(FlashMQ pthread dl ssl crypto) 99 target_link_libraries(FlashMQ pthread dl ssl crypto)
  100 +
  101 +install(TARGETS FlashMQ
  102 + RUNTIME DESTINATION "/usr/bin/")
  103 +
  104 +install(DIRECTORY DESTINATION "/var/lib/flashmq")
  105 +install(DIRECTORY DESTINATION "/var/log/flashmq")
  106 +install(FILES flashmq.conf DESTINATION "/etc/flashmq")
  107 +install(FILES debian/flashmq.service DESTINATION "/lib/systemd/system")
  108 +
  109 +SET(CPACK_DEBIAN_PACKAGE_CONTROL_EXTRA "${CMAKE_CURRENT_SOURCE_DIR}/debian/conffiles;${CMAKE_CURRENT_SOURCE_DIR}/debian/preinst;${CMAKE_CURRENT_SOURCE_DIR}/debian/postinst;${CMAKE_CURRENT_SOURCE_DIR}/debian/postrm;${CMAKE_CURRENT_SOURCE_DIR}/debian/prerm")
  110 +
  111 +SET(CPACK_GENERATOR "DEB")
  112 +SET(CPACK_DEBIAN_PACKAGE_MAINTAINER "Wiebe Cazemier <wiebe@halfgaar.net>")
  113 +SET(CPACK_DEBIAN_PACKAGE_DESCRIPTION "Light-weight, high performance MQTT server capable of million+ messages per second.")
  114 +SET(CPACK_PACKAGE_HOMEPAGE_URL "https://www.flashmq.org/")
  115 +SET(CPACK_DEBIAN_PACKAGE_DEPENDS "libssl1.1 (>= 1.1.0)")
  116 +SET(CPACK_PACKAGE_VERSION_MAJOR ${PROJECT_VERSION_MAJOR})
  117 +SET(CPACK_PACKAGE_VERSION_MINOR ${PROJECT_VERSION_MINOR})
  118 +SET(CPACK_PACKAGE_VERSION_PATCH ${PROJECT_VERSION_PATCH})
  119 +INCLUDE(CPack)
build.sh
@@ -23,3 +23,4 @@ cd &quot;$BUILD_DIR&quot; @@ -23,3 +23,4 @@ cd &quot;$BUILD_DIR&quot;
23 23
24 cmake -DCMAKE_BUILD_TYPE="$BUILD_TYPE" "$thisdir" 24 cmake -DCMAKE_BUILD_TYPE="$BUILD_TYPE" "$thisdir"
25 make 25 make
  26 +cpack
debian/conffiles 0 → 100644
  1 +/etc/flashmq/flashmq.conf
debian/flashmq.service 0 → 100644
  1 +[Unit]
  2 +Description=FlashMQ MQTT server
  3 +After=network.target
  4 +
  5 +[Service]
  6 +Type=simple
  7 +User=root
  8 +Group=root
  9 +LimitNOFILE=1000000
  10 +ExecStart=/usr/bin/FlashMQ --config-file /etc/flashmq/flashmq.conf
  11 +ExecReload=/bin/kill -HUP $MAINPID
  12 +Restart=on-failure
  13 +RestartSec=5s
  14 +
  15 +[Install]
  16 +WantedBy=multi-user.target
debian/postinst 0 → 100755
  1 +#!/bin/bash -e
  2 +
  3 +if ! systemctl is-enabled --quiet flashmq.service; then
  4 + echo "Enabling FlashMQ systemd service."
  5 + systemctl enable flashmq.service
  6 +fi
  7 +
  8 +if ! systemctl is-active --quiet flashmq.service; then
  9 + echo "FlashMQ is not running, so we're starting it."
  10 + systemctl start flashmq.service
  11 +else
  12 + echo "FlashMQ is already running."
  13 +fi
debian/postrm 0 → 100755
  1 +#!/bin/bash -e
  2 +
  3 +if [[ "$1" != "upgrade" ]]; then
  4 + echo "Disabling FlashMQ systemd service"
  5 + systemctl disable flashmq.service
  6 +fi
debian/preinst 0 → 100755
  1 +#!/bin/bash -e
  2 +
  3 +if [[ ! -f /etc/lsb-release || ! -f /etc/debian_version ]]; then
  4 + echo "This is not a Debian or Ubuntu based system? Hmm"
  5 + exit 1
  6 +fi
  7 +
  8 +if ! command -v systemctl -v &> /dev/null; then
  9 + echo "This is not a systemd-based system. File a bug-report at https://github.com/halfgaar/FlashMQ/issues"
  10 + exit 1
  11 +fi
debian/prerm 0 → 100755
  1 +#!/bin/bash -e
  2 +
  3 +echo "Stopping FlashMQ systemd service"
  4 +
  5 +if systemctl is-active --quiet flashmq.service; then
  6 + systemctl stop flashmq.service
  7 +fi
  8 +
  9 +if systemctl is-active --quiet flashmq.service; then
  10 + echo "FlashMQ failed to stop, according to systemctl."
  11 + exit 1
  12 +fi
flashmq.conf 0 → 100644
  1 +# https://www.flashmq.org/documentation/config-file/
  2 +
  3 +log_file /var/log/flashmq.log
  4 +storage_dir /var/lib/flashmq
main.cpp
@@ -88,9 +88,9 @@ int main(int argc, char *argv[]) @@ -88,9 +88,9 @@ int main(int argc, char *argv[])
88 sse = "with SSE4.2 support"; 88 sse = "with SSE4.2 support";
89 #endif 89 #endif
90 #ifdef NDEBUG 90 #ifdef NDEBUG
91 - logger->logf(LOG_NOTICE, "Starting FlashMQ version %s, release build %s.", VERSION, sse.c_str()); 91 + logger->logf(LOG_NOTICE, "Starting FlashMQ version %s, release build %s.", FLASHMQ_VERSION, sse.c_str());
92 #else 92 #else
93 - logger->logf(LOG_NOTICE, "Starting FlashMQ version %s, debug build %s.", VERSION, sse.c_str()); 93 + logger->logf(LOG_NOTICE, "Starting FlashMQ version %s, debug build %s.", FLASHMQ_VERSION, sse.c_str());
94 #endif 94 #endif
95 mainApp->start(); 95 mainApp->start();
96 } 96 }
mainapp.cpp
@@ -242,7 +242,7 @@ void MainApp::doHelp(const char *arg) @@ -242,7 +242,7 @@ void MainApp::doHelp(const char *arg)
242 242
243 void MainApp::showLicense() 243 void MainApp::showLicense()
244 { 244 {
245 - printf("FlashMQ Version %s\n", VERSION); 245 + printf("FlashMQ Version %s\n", FLASHMQ_VERSION);
246 puts("Copyright (C) 2021 Wiebe Cazemier."); 246 puts("Copyright (C) 2021 Wiebe Cazemier.");
247 puts("License AGPLv3: GNU AGPL version 3. <https://www.gnu.org/licenses/agpl-3.0.html>."); 247 puts("License AGPLv3: GNU AGPL version 3. <https://www.gnu.org/licenses/agpl-3.0.html>.");
248 puts(""); 248 puts("");
mainapp.h
@@ -42,8 +42,6 @@ License along with FlashMQ. If not, see &lt;https://www.gnu.org/licenses/&gt;. @@ -42,8 +42,6 @@ License along with FlashMQ. If not, see &lt;https://www.gnu.org/licenses/&gt;.
42 #include "scopedsocket.h" 42 #include "scopedsocket.h"
43 #include "oneinstancelock.h" 43 #include "oneinstancelock.h"
44 44
45 -#define VERSION "0.9.2"  
46 -  
47 class MainApp 45 class MainApp
48 { 46 {
49 #ifdef TESTING 47 #ifdef TESTING