From fb3d6d64897a903f43968e6787baf9562fa95ccc Mon Sep 17 00:00:00 2001 From: NickMa Date: Mon, 5 Mar 2018 15:19:52 +0100 Subject: [PATCH] Cmake gitlabci (#25) * gitlabci: hardcoded the debian systemd path * cmake: no failure on forced SYSTEMD_SERVICES_INSTALL_DIR * gitlabci: added fedora target * gitlabci: added fedora package * gitlabci: added another fedora package * gitlabci: fedora changed rpmbuilder * fedora... * fedora package name try4 * rpmdevtools detection * gitlabci: changed rpm detection * gitlabci: rpmbuilder detection * rpmbuilder added references * gitlabci: changed the expiration timespan to 6months * removed always false comparison (dbglvl is unsigned) --- .gitlab-ci.yml | 18 +++++++++++++++--- CMakeLists.txt | 8 +++++--- cmake/extern_GPL/FindSystemd.cmake | 2 +- src/main.c | 2 +- 4 files changed, 22 insertions(+), 8 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index fe7eb35..70c6f30 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -8,7 +8,7 @@ stages: artifacts: # create an archive with a name of the current stage and branch name name: "${CI_BUILD_STAGE}_${CI_BUILD_REF_NAME}" - expire_in: 1 day + expire_in: 6 months paths: - output.dir/mbusd - output.dir/mbusd.8 @@ -17,6 +17,18 @@ stages: - output.dir/mbusd*.deb - output.dir/mbusd*.rpm +build:fedora_x86: + <<: *mbusd_job_template + image: fedora:latest + stage: build + before_script: + - yum -y install cmake pkgconfig gcc-c++ rpmdevtools + script: + - mkdir output.dir/ + - cd output.dir + - cmake -D CMAKE_BUILD_TYPE=Debug -DSYSTEMD_SERVICES_INSTALL_DIR=/usr/lib/systemd/system ../ + - make package + build:deb_armhf: <<: *mbusd_job_template stage: build @@ -26,7 +38,7 @@ build:deb_armhf: script: - mkdir output.dir/ - cd output.dir - - cmake -DCMAKE_BUILD_TYPE=Debug -DCMAKE_TOOLCHAIN_FILE=../cmake/arm_linux_gnueabihf.cmake ../ + - cmake -DCMAKE_BUILD_TYPE=Release -DSYSTEMD_SERVICES_INSTALL_DIR=/lib/systemd/system -DCMAKE_TOOLCHAIN_FILE=../cmake/arm_linux_gnueabihf.cmake ../ - make package build:deb_x86: @@ -38,7 +50,7 @@ build:deb_x86: script: - mkdir output.dir/ - cd output.dir - - cmake -D CMAKE_BUILD_TYPE=Debug ../ + - cmake -DCMAKE_BUILD_TYPE=Release -DSYSTEMD_SERVICES_INSTALL_DIR=/lib/systemd/system ../ - make package diff --git a/CMakeLists.txt b/CMakeLists.txt index 4dbd28f..bb6b1f4 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -82,7 +82,7 @@ install( DESTINATION ${CMAKE_INSTALL_FULL_SYSCONFDIR}/${CMAKE_PROJECT_NAME} ) -if(SYSTEMD_FOUND) +if(SYSTEMD_SERVICES_INSTALL_DIR) message(STATUS "Systemd service file will be installed to ${SYSTEMD_SERVICES_INSTALL_DIR}") # aggregate mbusd@.service from its template configure_file(${CMAKE_CURRENT_SOURCE_DIR}/systemd-units/mbusd@.service.in mbusd@.service) @@ -124,8 +124,10 @@ execute_process( ## issue the package creation with $make package # which infrastructure do we want set(CPACK_GENERATOR "DEB") -pkg_check_modules(rpmBuilder "librpmbuild3") -if(rpmBuilder_FOUND) +find_program(rpmBuilder rpmbuild) +if(rpmBuilder) + # @see https://schneide.wordpress.com/2013/02/11/build-a-rpm-package-using-cmake/ + # @see http://www.g-loaded.eu/2006/04/05/how-to-build-rpm-packages-on-fedora/ set(CPACK_GENERATOR "RPM") endif() diff --git a/cmake/extern_GPL/FindSystemd.cmake b/cmake/extern_GPL/FindSystemd.cmake index 73ebf36..c5506fa 100644 --- a/cmake/extern_GPL/FindSystemd.cmake +++ b/cmake/extern_GPL/FindSystemd.cmake @@ -17,7 +17,7 @@ if (SYSTEMD_FOUND AND "${SYSTEMD_SERVICES_INSTALL_DIR}" STREQUAL "") string(REGEX REPLACE "[ \t\n]+" "" SYSTEMD_SERVICES_INSTALL_DIR "${SYSTEMD_SERVICES_INSTALL_DIR}") elseif (NOT SYSTEMD_FOUND AND SYSTEMD_SERVICES_INSTALL_DIR) - message (FATAL_ERROR "Variable SYSTEMD_SERVICES_INSTALL_DIR is\ + message (INFO "Variable SYSTEMD_SERVICES_INSTALL_DIR is\ defined, but we can't find systemd using pkg-config") endif() diff --git a/src/main.c b/src/main.c index 1aab122..3d023dc 100644 --- a/src/main.c +++ b/src/main.c @@ -218,7 +218,7 @@ main(int argc, char *argv[]) case 'v': cfg.dbglvl = (char)strtol(optarg, NULL, 0); # ifdef DEBUG - if (cfg.dbglvl < 0 || cfg.dbglvl > 9) + if (cfg.dbglvl > 9) { /* report about invalid log level */ printf("%s: -v: invalid loglevel value" " (%d, must be 0-9)\n", exename, cfg.dbglvl);