From 85d757b2c273995e20372c48e15f96fda9f45591 Mon Sep 17 00:00:00 2001 From: Michael Friedrich Date: Wed, 25 Sep 2019 12:50:47 +0200 Subject: [PATCH 1/6] Chocolatey: Update package metadata to fix dependencies --- choco/icinga2.nuspec.cmake | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/choco/icinga2.nuspec.cmake b/choco/icinga2.nuspec.cmake index 46225b556..1e3586799 100755 --- a/choco/icinga2.nuspec.cmake +++ b/choco/icinga2.nuspec.cmake @@ -10,17 +10,20 @@ Icinga GmbH Icinga GmbH icinga2 - Monitoring Agent for Windows - Icinga 2 is an open source monitoring platform which notifies users about host and service outages. + Icinga is an open source monitoring platform which notifies users about host and service outages. https://icinga.com/ - icinga2 agent monitoring admin - https://icinga.com/resources/faq/ + icinga2 icinga agent monitoring admin + https://github.com/Icinga/icinga2/blob/master/COPYING https://github.com/Icinga/icinga2/blob/master/ChangeLog - https://docs.icinga.com/icinga2/ + https://icinga.com/docs/icinga2/latest/ https://github.com/Icinga/icinga2/issues https://github.com/Icinga/icinga2 https://github.com/Icinga/icinga2 false - https://icinga.com/wp-content/uploads/2015/05/icinga_icon_128x128.png + https://raw.githubusercontent.com/Icinga/icinga2/master/icinga-app/icinga.ico + + + From 44d1cefbf7534abd66e51659696a36514d2af85f Mon Sep 17 00:00:00 2001 From: Michael Friedrich Date: Thu, 26 Sep 2019 13:37:09 +0200 Subject: [PATCH 2/6] ChocoInstall: Prefer short release version download, not long x.y.z.a --- CMakeLists.txt | 4 +++- choco/chocolateyInstall.ps1.cmake | 4 ++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 1eefc9938..5ab01f550 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -119,7 +119,9 @@ 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}") string(REGEX REPLACE "-[^\\.]*(.*)$" "\\1" ICINGA2_VERSION_SAFE "${ICINGA2_VERSION_SAFE}") -message(STATUS "ICINGA2_VERSION_SAFE=${ICINGA2_VERSION_SAFE}") +string(REGEX REPLACE "^([0-9]+\\.[0-9]+\\.[0-9]+)[\\.]?[0-9]*" "\\1" CHOCO_VERSION_SHORT "${ICINGA2_VERSION_SAFE}") + +message(STATUS "ICINGA2_VERSION_SAFE=${ICINGA2_VERSION_SAFE} CHOCO_VERSION_SHORT=${CHOCO_VERSION_SHORT}") if(WIN32) set(Boost_USE_STATIC_LIBS ON) diff --git a/choco/chocolateyInstall.ps1.cmake b/choco/chocolateyInstall.ps1.cmake index ab1660324..8a524419f 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${ICINGA2_VERSION_SAFE}-x86.msi' -$url64 = 'https://packages.icinga.com/windows/Icinga2-v${ICINGA2_VERSION_SAFE}-x86_64.msi' +$url32 = 'https://packages.icinga.com/windows/Icinga2-v${CHOCO_VERSION_SHORT}-x86.msi' +$url64 = 'https://packages.icinga.com/windows/Icinga2-v${CHOCO_VERSION_SHORT}-x86_64.msi' $silentArgs = '/qn /norestart' $validExitCodes = @(0) From d6048f6fe0a4590df4b07eba11674ee77439b13d Mon Sep 17 00:00:00 2001 From: Michael Insel Date: Mon, 7 Oct 2019 19:36:44 +0200 Subject: [PATCH 3/6] Chocolatey: Update package metadata to correct dependencies --- choco/icinga2.nuspec.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/choco/icinga2.nuspec.cmake b/choco/icinga2.nuspec.cmake index 1e3586799..d0699f24b 100755 --- a/choco/icinga2.nuspec.cmake +++ b/choco/icinga2.nuspec.cmake @@ -22,7 +22,7 @@ false https://raw.githubusercontent.com/Icinga/icinga2/master/icinga-app/icinga.ico - + From d051d71b75490ac54c149eb6d8fd9bb5d6d9fbab Mon Sep 17 00:00:00 2001 From: Michael Insel Date: Thu, 10 Oct 2019 18:39:33 +0200 Subject: [PATCH 4/6] ChocoInstall: Update script to use checksum verification --- CMakeLists.txt | 2 +- choco/chocolateyInstall.ps1.cmake | 24 ++++++++++++++++++------ 2 files changed, 19 insertions(+), 7 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 5ab01f550..046f23cf2 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -520,4 +520,4 @@ if(WIN32) ) endif() -include(CPack) +include(CPack) \ No newline at end of file diff --git a/choco/chocolateyInstall.ps1.cmake b/choco/chocolateyInstall.ps1.cmake index 8a524419f..26fe2396a 100755 --- a/choco/chocolateyInstall.ps1.cmake +++ b/choco/chocolateyInstall.ps1.cmake @@ -1,8 +1,20 @@ -$packageName = 'icinga2' -$installerType = 'msi' -$url32 = 'https://packages.icinga.com/windows/Icinga2-v${CHOCO_VERSION_SHORT}-x86.msi' +$packageName= 'icinga2' +$toolsDir = "$(Split-Path -Parent $MyInvocation.MyCommand.Definition)" +$url = 'https://packages.icinga.com/windows/Icinga2-v${CHOCO_VERSION_SHORT}-x86.msi' $url64 = 'https://packages.icinga.com/windows/Icinga2-v${CHOCO_VERSION_SHORT}-x86_64.msi' -$silentArgs = '/qn /norestart' -$validExitCodes = @(0) -Install-ChocolateyPackage "$packageName" "$installerType" "$silentArgs" "$url32" "$url64" -validExitCodes $validExitCodes +$packageArgs = @{ + packageName = $packageName + fileType = 'msi' + url = $url + url64bit = $url64 + silentArgs = "/qn /norestart" + validExitCodes= @(0) + softwareName = 'Icinga 2*' + checksum = '' # TODO: Add checksum + checksumType = 'sha256' + checksum64 = '' # TODO: Add checksum + checksumType64= 'sha256' +} + +Install-ChocolateyPackage @packageArgs \ No newline at end of file From feed379229a5ba7cb5bd4b4d9808cfe59683abb7 Mon Sep 17 00:00:00 2001 From: Michael Insel Date: Fri, 11 Oct 2019 18:42:48 +0200 Subject: [PATCH 5/6] Chocolatey: Add build script for package --- choco/CMakeLists.txt | 10 +---- ...e => chocolateyInstall.ps1.template.cmake} | 38 ++++++++--------- tools/win32/build-choco.ps1 | 42 +++++++++++++++++++ 3 files changed, 62 insertions(+), 28 deletions(-) rename choco/{chocolateyInstall.ps1.cmake => chocolateyInstall.ps1.template.cmake} (84%) mode change 100755 => 100644 create mode 100644 tools/win32/build-choco.ps1 diff --git a/choco/CMakeLists.txt b/choco/CMakeLists.txt index d7b90bb47..fb147a15c 100644 --- a/choco/CMakeLists.txt +++ b/choco/CMakeLists.txt @@ -1,14 +1,6 @@ # Icinga 2 | (c) 2012 Icinga GmbH | GPLv2+ if(WIN32) - find_program(CHOCO_BINARY choco) - configure_file(icinga2.nuspec.cmake icinga2.nuspec) - configure_file(chocolateyInstall.ps1.cmake chocolateyInstall.ps1) - - add_custom_target(choco-pkg ALL - COMMAND choco pack - 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 - ) + configure_file(chocolateyInstall.ps1.template.cmake chocolateyInstall.ps1.template) endif() diff --git a/choco/chocolateyInstall.ps1.cmake b/choco/chocolateyInstall.ps1.template.cmake old mode 100755 new mode 100644 similarity index 84% rename from choco/chocolateyInstall.ps1.cmake rename to choco/chocolateyInstall.ps1.template.cmake index 26fe2396a..424a73778 --- a/choco/chocolateyInstall.ps1.cmake +++ b/choco/chocolateyInstall.ps1.template.cmake @@ -1,20 +1,20 @@ -$packageName= 'icinga2' -$toolsDir = "$(Split-Path -Parent $MyInvocation.MyCommand.Definition)" -$url = 'https://packages.icinga.com/windows/Icinga2-v${CHOCO_VERSION_SHORT}-x86.msi' -$url64 = 'https://packages.icinga.com/windows/Icinga2-v${CHOCO_VERSION_SHORT}-x86_64.msi' - -$packageArgs = @{ - packageName = $packageName - fileType = 'msi' - url = $url - url64bit = $url64 - silentArgs = "/qn /norestart" - validExitCodes= @(0) - softwareName = 'Icinga 2*' - checksum = '' # TODO: Add checksum - checksumType = 'sha256' - checksum64 = '' # TODO: Add checksum - checksumType64= 'sha256' -} - +$packageName= 'icinga2' +$toolsDir = "$(Split-Path -Parent $MyInvocation.MyCommand.Definition)" +$url = 'https://packages.icinga.com/windows/Icinga2-v${CHOCO_VERSION_SHORT}-x86.msi' +$url64 = 'https://packages.icinga.com/windows/Icinga2-v${CHOCO_VERSION_SHORT}-x86_64.msi' + +$packageArgs = @{ + packageName = $packageName + fileType = 'msi' + url = $url + url64bit = $url64 + silentArgs = "/qn /norestart" + validExitCodes= @(0) + softwareName = 'Icinga 2*' + checksum = '%CHOCO_32BIT_CHECKSUM%' + checksumType = 'sha256' + checksum64 = '%CHOCO_64BIT_CHECKSUM%' + checksumType64= 'sha256' +} + Install-ChocolateyPackage @packageArgs \ No newline at end of file diff --git a/tools/win32/build-choco.ps1 b/tools/win32/build-choco.ps1 new file mode 100644 index 000000000..24fa5f498 --- /dev/null +++ b/tools/win32/build-choco.ps1 @@ -0,0 +1,42 @@ +Set-PsDebug -Trace 1 + +if(-not (Test-Path "$($env:ProgramData)\chocolatey\choco.exe")) { + throw "Could not find Choco executable. Abort." +} + +if (-not (Test-Path env:ICINGA2_BUILDPATH)) { + $env:ICINGA2_BUILDPATH = '.\debug' +} + +if(-not (Test-Path "$($env:ICINGA2_BUILDPATH)\choco\chocolateyInstall.ps1.template")) { + throw "Could not find Chocolatey install script template. Abort." +} + +$chocoInstallScriptTemplatePath = "$($env:ICINGA2_BUILDPATH)\choco\chocolateyInstall.ps1.template" +$chocoInstallScript = Get-Content $chocoInstallScriptTemplatePath + +if(-not (Test-Path "$($env:ICINGA2_BUILDPATH)\*-x86.msi")) { + throw "Could not find Icinga 2 32 bit MSI package. Abort." +} + +$hashMSIpackage32 = Get-FileHash "$($env:ICINGA2_BUILDPATH)\*-x86.msi" +Write-Output "File Hash for 32 bit MSI package: $($hashMSIpackage32.Hash)." + +if(-not (Test-Path "$($env:ICINGA2_BUILDPATH)\*-x86_64.msi")) { + throw "Could not find Icinga 2 64 bit MSI package. Abort." +} + +$hashMSIpackage64 = Get-FileHash "$($env:ICINGA2_BUILDPATH)\*-x86_64.msi" +Write-Output "File Hash for 32 bit MSI package: $($hashMSIpackage64.Hash)" + +$chocoInstallScript = $chocoInstallScript.Replace("%CHOCO_32BIT_CHECKSUM%", "$($hashMSIpackage32.Hash)") +$chocoInstallScript = $chocoInstallScript.Replace("%CHOCO_64BIT_CHECKSUM%", "$($hashMSIpackage64.Hash)") +Write-Output $chocoInstallScript + +Set-Content -Path "$($env:ICINGA2_BUILDPATH)\choco\chocolateyInstall.ps1" -Value $chocoInstallScript + +cd "$($env:ICINGA2_BUILDPATH)\choco" +& "$($env:ProgramData)\chocolatey\choco.exe" "pack" +cd "..\.." + +Move-Item -Path "$($env:ICINGA2_BUILDPATH)\choco\*.nupkg" -Destination "$($env:ICINGA2_BUILDPATH)" \ No newline at end of file From d38f4e78c99454d21bc9f10c34c5af6b96ba1027 Mon Sep 17 00:00:00 2001 From: Noah Hilverling Date: Fri, 5 Jun 2020 09:57:34 +0200 Subject: [PATCH 6/6] Chocolatey: Use '.\build' as default build directory --- tools/win32/build-choco.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/win32/build-choco.ps1 b/tools/win32/build-choco.ps1 index 24fa5f498..32138bdf2 100644 --- a/tools/win32/build-choco.ps1 +++ b/tools/win32/build-choco.ps1 @@ -5,7 +5,7 @@ if(-not (Test-Path "$($env:ProgramData)\chocolatey\choco.exe")) { } if (-not (Test-Path env:ICINGA2_BUILDPATH)) { - $env:ICINGA2_BUILDPATH = '.\debug' + $env:ICINGA2_BUILDPATH = '.\build' } if(-not (Test-Path "$($env:ICINGA2_BUILDPATH)\choco\chocolateyInstall.ps1.template")) {