Chocolatey: Add build script for package

This commit is contained in:
Michael Insel 2019-10-11 18:42:48 +02:00
parent d051d71b75
commit feed379229
3 changed files with 62 additions and 28 deletions

View File

@ -1,14 +1,6 @@
# Icinga 2 | (c) 2012 Icinga GmbH | GPLv2+ # Icinga 2 | (c) 2012 Icinga GmbH | GPLv2+
if(WIN32) if(WIN32)
find_program(CHOCO_BINARY choco)
configure_file(icinga2.nuspec.cmake icinga2.nuspec) configure_file(icinga2.nuspec.cmake icinga2.nuspec)
configure_file(chocolateyInstall.ps1.cmake chocolateyInstall.ps1) configure_file(chocolateyInstall.ps1.template.cmake chocolateyInstall.ps1.template)
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
)
endif() endif()

View File

@ -11,9 +11,9 @@ $packageArgs = @{
silentArgs = "/qn /norestart" silentArgs = "/qn /norestart"
validExitCodes= @(0) validExitCodes= @(0)
softwareName = 'Icinga 2*' softwareName = 'Icinga 2*'
checksum = '' # TODO: Add checksum checksum = '%CHOCO_32BIT_CHECKSUM%'
checksumType = 'sha256' checksumType = 'sha256'
checksum64 = '' # TODO: Add checksum checksum64 = '%CHOCO_64BIT_CHECKSUM%'
checksumType64= 'sha256' checksumType64= 'sha256'
} }

View File

@ -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)"