From 9f82faa439a9360b951081f5f9de611ce62170af Mon Sep 17 00:00:00 2001 From: Markus Frosch Date: Thu, 4 Apr 2019 12:55:52 +0200 Subject: [PATCH] cmake: Use the actual GIT_VERSION for ICINGA2_VERSION And use a safe version with dots only for Windows. --- CMakeLists.txt | 12 ++++++++---- choco/CMakeLists.txt | 2 +- choco/chocolateyInstall.ps1.cmake | 4 ++-- choco/icinga2.nuspec.cmake | 2 +- 4 files changed, 12 insertions(+), 8 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 4ddfa2649..7ad1c95b3 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -27,9 +27,6 @@ option (USE_SYSTEMD set(HAVE_SYSTEMD ${USE_SYSTEMD}) -file(STRINGS VERSION VERSION_LINE REGEX "^Version: ") -string(REPLACE "Version: " "" ICINGA2_VERSION ${VERSION_LINE}) - include(GNUInstallDirs) include(InstallConfig) include(SetFullDir) @@ -104,10 +101,17 @@ else() string(SUBSTRING ${SPEC_REVISION} 10 ${SPEC_REVISION_LENGTH} SPEC_REVISION) set(GIT_VERSION "r${SPEC_VERSION}-${SPEC_REVISION}") + set(ICINGA2_VERSION "${SPEC_VERSION}") + else() + # use GIT version as ICINGA2_VERSION + string(REGEX REPLACE "^[rv]" "" ICINGA2_VERSION "${GIT_VERSION}") endif() configure_file(icinga-version.h.cmake icinga-version.h) endif() +# NuGet on Windows requires a semantic versioning, example: 2.10.4.123 (only 4 element, only numeric) +string(REGEX REPLACE "-([0-9]+).*$" ".\\1" ICINGA2_VERSION_SAFE "${ICINGA2_VERSION}") + if(WIN32) set(Boost_USE_STATIC_LIBS ON) # Disabled for linking issues for newer Boost versions, they link against Windows SDKs @@ -391,7 +395,7 @@ endif() set(CPACK_PACKAGE_NAME "Icinga 2") set(CPACK_PACKAGE_VENDOR "Icinga GmbH") -set(CPACK_PACKAGE_VERSION ${ICINGA2_VERSION}) +set(CPACK_PACKAGE_VERSION ${ICINGA2_VERSION_SAFE}) set(CPACK_PACKAGE_INSTALL_DIRECTORY "ICINGA2") set(CPACK_PACKAGE_ICON "${CMAKE_CURRENT_SOURCE_DIR}/icinga-app\\\\icinga.ico") set(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_CURRENT_BINARY_DIR}/LICENSE.txt") diff --git a/choco/CMakeLists.txt b/choco/CMakeLists.txt index 650c41cf1..d7b90bb47 100644 --- a/choco/CMakeLists.txt +++ b/choco/CMakeLists.txt @@ -8,7 +8,7 @@ if(WIN32) add_custom_target(choco-pkg ALL COMMAND choco pack - COMMAND ${CMAKE_COMMAND} -E rename ${CMAKE_CURRENT_BINARY_DIR}/icinga2.${SPEC_VERSION}.nupkg ${CMAKE_CURRENT_BINARY_DIR}/icinga2.nupkg + COMMAND ${CMAKE_COMMAND} -E rename ${CMAKE_CURRENT_BINARY_DIR}/icinga2.${ICINGA2_VERSION_SAFE}.nupkg ${CMAKE_CURRENT_BINARY_DIR}/icinga2.nupkg DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/icinga2.nuspec ${CMAKE_CURRENT_BINARY_DIR}/chocolateyInstall.ps1 chocolateyUninstall.ps1 ) endif() diff --git a/choco/chocolateyInstall.ps1.cmake b/choco/chocolateyInstall.ps1.cmake index cbf4ca0d9..ab1660324 100755 --- a/choco/chocolateyInstall.ps1.cmake +++ b/choco/chocolateyInstall.ps1.cmake @@ -1,7 +1,7 @@ $packageName = 'icinga2' $installerType = 'msi' -$url32 = 'https://packages.icinga.com/windows/Icinga2-v${SPEC_VERSION}-x86.msi' -$url64 = 'https://packages.icinga.com/windows/Icinga2-v${SPEC_VERSION}-x86_64.msi' +$url32 = 'https://packages.icinga.com/windows/Icinga2-v${ICINGA2_VERSION_SAFE}-x86.msi' +$url64 = 'https://packages.icinga.com/windows/Icinga2-v${ICINGA2_VERSION_SAFE}-x86_64.msi' $silentArgs = '/qn /norestart' $validExitCodes = @(0) diff --git a/choco/icinga2.nuspec.cmake b/choco/icinga2.nuspec.cmake index 1b1465df6..46225b556 100755 --- a/choco/icinga2.nuspec.cmake +++ b/choco/icinga2.nuspec.cmake @@ -6,7 +6,7 @@ icinga2 Icinga 2 - ${SPEC_VERSION} + ${ICINGA2_VERSION_SAFE} Icinga GmbH Icinga GmbH icinga2 - Monitoring Agent for Windows