Skip to content

Commit

Permalink
Add windows packaging
Browse files Browse the repository at this point in the history
NR-52409: Windows packaging refactor

Co-authored-by: Guillermo Sanchez Gavier <[email protected]>
  • Loading branch information
marcsanmi and gsanchezgavier authored Dec 16, 2022
2 parents 58eb77b + 23ccbf9 commit 04efd4b
Show file tree
Hide file tree
Showing 8 changed files with 155 additions and 213 deletions.
2 changes: 0 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,6 @@
**/obj/Release/**
**/bin/Release/**

**/Product.wxs

**/versioninfo.json

.DS_Store
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ build-%:
EXPORTER_PATH=exporters/$*/exporter.yml; \
loadVariables; \
bash exporters/$*/build-${GOOS}.sh $(PWD) && \
bash scripts/build_generator.sh $(PWD) $*;
bash scripts/build_generator.sh $(PWD) $* ${GOOS};

fetch-resources-%:
@echo "[ fetch-resources-$* ]: Fetching external resources..."
Expand Down
14 changes: 7 additions & 7 deletions exporters/powerdns/exporter.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# name of the exporter, should match with the folder name
name: powerdns
# version of the package created
version: 0.0.7
version: 0.0.8
# Relative path to the License path from the repository root
exporter_license_path: LICENSE
# URL to the git project hosting the exporter
Expand All @@ -15,18 +15,18 @@ exporter_changelog: https://github.com/lotusnoir/prometheus-powerdns_exporter/ta
# Enable packages for Linux
package_linux: true
# Enable packages for Windows
package_windows: false
package_windows: true
# Upgrade GUID used in the msi package. Required if package_windows is set to true
# This GUID should be generated and be unique across all exporters in the repository
upgrade_guid: 278db4a4-60a9-493b-b878-dc7b445a2db0
upgrade_guid: e854d6c0-e0ce-4f9a-b405-d855a3864307
# Integration GUID used in the msi package. Required if package_windows is set to true
# This GUID should be generated and be unique across all exporters in the repository
nri_guid: 44ac2940-4aff-46fc-a46b-b1b8cd9a3505
nri_guid: 25b3fb82-58e0-41a2-b0d6-f87b16eaa50c
# Exporter GUID used in the msi package. Required if package_windows is set to true
# This GUID should be generated and be unique across all exporters in the repository
exporter_guid: b246fde4-0083-4e16-beb0-09139fb5ca9f
exporter_guid: c5a084d2-941a-49ae-836a-255b018cfb17
# License GUID used in the msi package. Required if package_windows is set to true
# This GUID should be generated and be unique across all exporters in the repository
license_guid: a63afbd8-5ea3-4bac-85cc-1da438b8c8f4
license_guid: 5d2225c3-6b87-45fb-8756-6bf7c0f164fc
# This GUID should be generated and be unique across all exporters in the repository
config_guid: 86733900-4e10-478c-9633-61595d0e7acb
config_guid: 1ed3fde6-1b0c-485e-85e5-7a88d6001be5
8 changes: 7 additions & 1 deletion scripts/build_generator.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ set -eo pipefail

root_dir=$1
integration=$2
goos=$3
integration_dir="${root_dir}/exporters/${integration}"
destination_dir="${root_dir}/nri-config-generator/templates"

Expand Down Expand Up @@ -39,8 +40,13 @@ do
fi
done

integrationName="nri-${integration}"
if [ "$goos" == "windows" ]; then
integrationName="nri-${integration}.exe"
fi

cd nri-config-generator && \
BIN_PATH=${binary_dir}/nri-${integration} \
BIN_PATH=${binary_dir}/${integrationName} \
make compile

echo "executable file was created ${binary_dir}/nri-${integration}"
195 changes: 97 additions & 98 deletions .../nri-amd64-installer/Product.wxs.template → ...g/windows/nri-amd64-installer/Product.wxs
100755 → 100644
Original file line number Diff line number Diff line change
@@ -1,98 +1,97 @@
<?xml version="1.0" encoding="UTF-8"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
<?define Version = "{IntegrationVersion}" ?>
<?define ProductId = "*" ?>
<?define UpgradeCode = "{upgradeGUID}" ?>

<Product Id="$(var.ProductId)"
Name="New Relic Prometheus Exporter Integration, {IntegrationName}"
Language="1033"
Version="$(var.Version)"
Manufacturer="New Relic, Inc."
UpgradeCode="$(var.UpgradeCode)">
<Package Id="*"
InstallerVersion="200"
Compressed="yes"
InstallScope="perMachine"
Platform="x64"
Manufacturer="New Relic, Inc."
Comments="(c) {Year} New Relic, Inc."
Keywords="infrastructure,MSI,on-host,{IntegrationName}"/>

<MajorUpgrade DowngradeErrorMessage="A newer version of [ProductName] is already installed."/>
<MediaTemplate EmbedCab="yes"/>

<Feature Id="ProductFeature" Title="New Relic Prometheus Exporter Integration, {IntegrationName}" Level="1">
<ComponentRef Id="CMP_V1_CUSTOM_PLUGINS_BIN"/>
<ComponentRef Id="CMP_V1_PLUGIN_CONFIGS"/>
<ComponentGroupRef Id="PrometheusPluginsBinComponent"/>
<ComponentGroupRef Id="PluginConfigsComponent"/>
</Feature>
</Product>

<Fragment>
<Directory Id="TARGETDIR" Name="SourceDir">
<Directory Id="ProgramFiles64Folder">
<Directory Id="PrometheusFolder" Name="Prometheus-exporters">
<Directory Id="CustomPluginsBinFolder" Name="bin"/>
</Directory>
<Directory Id="CompanyFolder" Name="New Relic">
<Directory Id="AgentBinaryFolder" Name="newrelic-infra">
<Directory Id="PluginConfigsFolder" Name="integrations.d"/>
<Directory Id="CustomPluginsFolder" Name="newrelic-integrations">
<Directory Id="CustomPluginsBinFolderIntegration" Name="bin"/>
</Directory>
</Directory>
</Directory>
</Directory>
</Directory>
</Fragment>

<Fragment>
<DirectoryRef Id="CustomPluginsBinFolder">
<Component Id="CMP_V1_CUSTOM_PLUGINS_BIN" Guid="2244c368-dd8b-404a-bdc0-67c525d7422f" KeyPath="yes">
<CreateFolder/>
</Component>
</DirectoryRef>
<DirectoryRef Id="CustomPluginsBinFolderIntegration">
<Component Id="CMP_V1_CUSTOM_PLUGINS_BIN_INTEGRATION" Guid="6eac0d38-fcc1-450b-8072-9573092bbfe1" KeyPath="yes">
<CreateFolder/>
</Component>
</DirectoryRef>
<DirectoryRef Id="PluginConfigsFolder">
<Component Id="CMP_V1_PLUGIN_CONFIGS" Guid="803C978C-B2A1-47C7-BB17-A2DE9E6D3145" KeyPath="yes">
<CreateFolder/>
</Component>
</DirectoryRef>
</Fragment>

<Fragment>
<ComponentGroup Id="PrometheusPluginsBinComponent" Directory="CustomPluginsBinFolder">
<Component Id="CMP_NRI_EXPORTER_EXE" Guid="{exporterBinGUID}" Win64="yes">
<File Id="FILE_NRI_EXPORTER_EXE"
Source="$(var.BinariesPath){IntegrationExe}"
KeyPath="yes"/>
</Component>
<Component Id="CMP_NRI_LICENSE" Guid="{licenseGUID}" Win64="yes">
<File Id="FILE_NRI_LICENSE"
Source="$(var.BinariesPath){IntegrationName}-LICENSE"
KeyPath="yes"/>
</Component>
</ComponentGroup>
<ComponentGroup Id="CustomPluginsBinComponent" Directory="CustomPluginsBinFolderIntegration">
<Component Id="CMP_NRI_$(IntegrationName)_EXE" Guid="{nriGUID}" Win64="yes">
<File Id="FILE_NRI_$(IntegrationName)_EXE"
Source="$(var.BinariesPath)nri-$(IntegrationName).exe"
KeyPath="yes"/>
</Component>
<ComponentGroup Id="PluginConfigsComponent" Directory="PluginConfigsFolder">
<Component Id="CMP_NRI_EXPORTER_CONFIG" Guid="{configGUID}" Win64="yes">
<File Id="CMP_NRI_EXPORTER_CONFIG"
Name="{IntegrationName}-config.yml.sample"
Source="$(var.BinariesPath){IntegrationName}-config.yml.sample"
KeyPath="yes"/>
</Component>
</ComponentGroup>
</Fragment>

</Wix>
<?xml version="1.0" encoding="UTF-8"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
<Product Id="*"
Name="New Relic Prometheus Exporter Integration, $(var.IntegrationName)"
Language="1033"
Version="$(var.IntegrationVersion)"
Manufacturer="New Relic, Inc."
UpgradeCode="$(var.UpgradeCode)">
<Package Id="*"
InstallerVersion="200"
Compressed="yes"
InstallScope="perMachine"
Platform="x64"
Manufacturer="New Relic, Inc."
Comments="(c) New Relic, Inc."
Keywords="infrastructure,MSI,on-host,$(var.IntegrationName)"/>

<MajorUpgrade DowngradeErrorMessage="A newer version of [ProductName] is already installed."/>
<MediaTemplate EmbedCab="yes"/>

<Feature Id="ProductFeature" Title="New Relic Prometheus Exporter Integration, $(var.IntegrationName)" Level="1">
<ComponentRef Id="CMP_V1_CUSTOM_PLUGINS_BIN"/>
<ComponentRef Id="CMP_V1_CUSTOM_PLUGINS_BIN_INTEGRATION"/>
<ComponentRef Id="CMP_V1_PLUGIN_CONFIGS"/>
<ComponentGroupRef Id="PrometheusPluginsBinComponent"/>
<ComponentGroupRef Id="CustomPluginsBinComponent"/>
<ComponentGroupRef Id="PluginConfigsComponent"/>
</Feature>
</Product>

<Fragment>
<Directory Id="TARGETDIR" Name="SourceDir">
<Directory Id="$(var.ProgramFilesArch)">
<Directory Id="PrometheusFolder" Name="Prometheus-exporters">
<Directory Id="CustomPluginsBinFolder" Name="bin"/>
</Directory>
<Directory Id="CompanyFolder" Name="New Relic">
<Directory Id="AgentBinaryFolder" Name="newrelic-infra">
<Directory Id="PluginConfigsFolder" Name="integrations.d"/>
<Directory Id="CustomPluginsFolder" Name="newrelic-integrations">
<Directory Id="CustomPluginsBinFolderIntegration" Name="bin"/>
</Directory>
</Directory>
</Directory>
</Directory>
</Directory>
</Fragment>

<Fragment>
<DirectoryRef Id="CustomPluginsBinFolder">
<Component Id="CMP_V1_CUSTOM_PLUGINS_BIN" Guid="DB8403D7-2F59-4008-B87F-4A22EE41D8D9" KeyPath="yes">
<CreateFolder/>
</Component>
</DirectoryRef>
<DirectoryRef Id="CustomPluginsBinFolderIntegration">
<Component Id="CMP_V1_CUSTOM_PLUGINS_BIN_INTEGRATION" Guid="8FC720E9-55F5-490E-955F-1531E1FA79A5" KeyPath="yes">
<CreateFolder/>
</Component>
</DirectoryRef>
<DirectoryRef Id="PluginConfigsFolder">
<Component Id="CMP_V1_PLUGIN_CONFIGS" Guid="ACD1A480-0C62-4165-8A17-2C124C6B1CB1" KeyPath="yes">
<CreateFolder/>
</Component>
</DirectoryRef>
</Fragment>

<Fragment>
<ComponentGroup Id="PrometheusPluginsBinComponent" Directory="CustomPluginsBinFolder">
<Component Id="CMP_NRI_EXPORTER_EXE" Win64="$(var.Win64)">
<File Id="FILE_NRI_EXPORTER_EXE"
Source="$(var.BinariesPath)$(var.IntegrationName)-exporter.exe"
KeyPath="yes"/>
</Component>
<Component Id="CMP_NRI_LICENSE" Win64="$(var.Win64)">
<File Id="FILE_NRI_LICENSE"
Source="..\..\..\..\exporters\$(var.IntegrationName)\target\source\usr\local\share\doc\prometheus-exporters\$(var.IntegrationName)-LICENSE"
KeyPath="yes"/>
</Component>
</ComponentGroup>
<ComponentGroup Id="CustomPluginsBinComponent" Directory="CustomPluginsBinFolderIntegration">
<Component Id="CMP_NRI_EXE" Win64="$(var.Win64)">
<File Id="FILE_NRI_EXE"
Source="$(var.BinariesPath)nri-$(var.IntegrationName).exe"
KeyPath="yes"/>
</Component>
</ComponentGroup>
<ComponentGroup Id="PluginConfigsComponent" Directory="PluginConfigsFolder">
<Component Id="CMP_NRI_EXPORTER_CONFIG" Win64="$(var.Win64)">
<File Id="CMP_NRI_EXPORTER_CONFIG"
Name="$(var.IntegrationName)-config.yml.sample"
Source="..\..\..\..\exporters\$(var.IntegrationName)\$(var.IntegrationName)-config.yml.sample"
KeyPath="yes"/>
</Component>
</ComponentGroup>
</Fragment>

</Wix>
81 changes: 40 additions & 41 deletions scripts/pkg/windows/nri-amd64-installer/nri-installer.wixproj
100755 → 100644
Original file line number Diff line number Diff line change
@@ -1,41 +1,40 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Release</Configuration>
<Platform Condition=" '$(Platform)' == '' ">x86</Platform>
<ProductVersion>3.10</ProductVersion>
<ProjectGuid>aa111bbb-b027-4591-8adf-d19585de0594</ProjectGuid>
<SchemaVersion>2.0</SchemaVersion>
<OutputName>nri-$(exporterName)-amd64</OutputName>
<OutputType>Package</OutputType>
<SignToolPath>C:\Program Files (x86)\Windows Kits\10\bin\x64\</SignToolPath>
<WixTargetsPath Condition=" '$(WixTargetsPath)' == '' AND '$(MSBuildExtensionsPath32)' != '' ">$(MSBuildExtensionsPath32)\Microsoft\WiX\v3.x\Wix.targets</WixTargetsPath>
<WixTargetsPath Condition=" '$(WixTargetsPath)' == '' ">$(MSBuildExtensionsPath)\Microsoft\WiX\v3.x\Wix.targets</WixTargetsPath>
<Name>nri-$(exporterName)-installer</Name>
<DefineSolutionProperties>false</DefineSolutionProperties>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x86' ">
<OutputPath>bin\$(Configuration)\</OutputPath>
<IntermediateOutputPath>obj\$(Configuration)\</IntermediateOutputPath>
<DefineConstants>Debug;ProjectRootPath=..\..\..\..\;BinariesPath=..\..\..\..\exporters\$(exporterName)\target\bin\windows_amd64\</DefineConstants>
<SuppressAllWarnings>True</SuppressAllWarnings>
<Pedantic>False</Pedantic>
<CompilerAdditionalOptions>-arch x64</CompilerAdditionalOptions>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x86' ">
<OutputPath>bin\$(Configuration)\</OutputPath>
<IntermediateOutputPath>obj\$(Configuration)\</IntermediateOutputPath>
<DefineConstants>Debug;ProjectRootPath=..\..\..\..\;BinariesPath=..\..\..\..\exporters\$(exporterName)\target\bin\windows_amd64\</DefineConstants>
<CompilerAdditionalOptions>-arch x64</CompilerAdditionalOptions>
</PropertyGroup>
<ItemGroup>
<Compile Include="Product.wxs"/>
</ItemGroup>
<Import Project="$(WixTargetsPath)"/>
<Target Name="SignInstaller">
<Exec Command="&quot;$(SignToolPath)signtool.exe&quot; sign /d &quot;New Relic Infrastructure Agent, $(exporterName)&quot; /a &quot;$(OutputPath)$(OutputName).msi&quot;"/>
<Copy SourceFiles="$(OutputPath)$(OutputName).msi" DestinationFiles="$(OutputPath)$(OutputName).x.y.z.msi"/>
<!-- <Delete Files="$(OutputPath)$(OutputName).msi" /> -->
</Target>
<Target Name="AfterBuild" DependsOnTargets="SignInstaller"/>
</Project>
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Release</Configuration>
<Platform Condition=" '$(Platform)' == '' ">x64</Platform>
<ProductVersion>3.10</ProductVersion>
<ProjectGuid>DA18FD42-B622-452B-9045-DDF7752F4D35</ProjectGuid>
<SchemaVersion>2.0</SchemaVersion>
<OutputName>nri-$(exporterName)-amd64</OutputName>
<OutputType>Package</OutputType>
<SignToolPath>C:\Program Files (x86)\Microsoft SDKs\ClickOnce\SignTool\</SignToolPath>
<WixTargetsPath Condition=" '$(WixTargetsPath)' == '' AND '$(MSBuildExtensionsPath32)' != '' ">$(MSBuildExtensionsPath32)\Microsoft\WiX\v3.x\Wix.targets</WixTargetsPath>
<WixTargetsPath Condition=" '$(WixTargetsPath)' == '' ">$(MSBuildExtensionsPath)\Microsoft\WiX\v3.x\Wix.targets</WixTargetsPath>
<Name>nri-$(exporterName)-installer</Name>
<DefineSolutionProperties>false</DefineSolutionProperties>
</PropertyGroup>

<PropertyGroup Condition=" '$(Platform)' == 'x64' ">
<OutputPath>bin\$(Configuration)\</OutputPath>
<IntermediateOutputPath>obj\$(Configuration)\</IntermediateOutputPath>
<DefineConstants>ProgramFilesArch=ProgramFiles64Folder;Win64=yes;BinariesPath=..\..\..\..\exporters\$(exporterName)\target\bin\;IntegrationName=$(exporterName);IntegrationVersion=$(IntegrationVersion);UpgradeCode=$(UpgradeCode)</DefineConstants>
<SuppressAllWarnings>True</SuppressAllWarnings>
<Pedantic>False</Pedantic>
<CompilerAdditionalOptions>-arch x64</CompilerAdditionalOptions>
</PropertyGroup>

<ItemGroup>
<Compile Include="Product.wxs"/>
</ItemGroup>

<Import Project="$(WixTargetsPath)"/>

<Target Name="SignInstaller">
<Exec Command="&quot;$(SignToolPath)signtool.exe&quot; sign /d &quot;New Relic Infrastructure Agent, $(exporterName)&quot; /a &quot;$(OutputPath)$(OutputName).msi&quot;"/>
<Copy SourceFiles="$(OutputPath)$(OutputName).msi" DestinationFiles="$(OutputPath)$(OutputName).x.y.z.msi"/>
<!-- <Delete Files="$(OutputPath)$(OutputName).msi" /> -->
</Target>

<Target Name="AfterBuild" DependsOnTargets="SignInstaller"/>
</Project>
6 changes: 3 additions & 3 deletions scripts/win_msi_build.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ param (
[string]$exporterName="",
[string]$exporterGUID="",
[string]$upgradeGUID="",
[string]$licenseGUID="",
[string]$licenseGUID="",
[string]$configGUID="",
[string]$version=""
)
Expand Down Expand Up @@ -40,8 +40,6 @@ Get-ChildItem -Path cert:\CurrentUser\My\
echo "===> Configuring version $version for artifacts in $exporterName"

$projectRootPath = pwd
$windows_set_version = Join-Path -Path $projectRootPath -ChildPath "\scripts\windows_set_version.ps1"
& $windows_set_version -major $v[0] -minor $v[1] -patch $v[2] -exporterName $exporterName -exporterGUID $exporterGUID -upgradeGUID $upgradeGUID -licenseGUID $licenseGUID -configGUID $configGUID

echo "===> Checking MSBuild.exe..."
$msBuild = (Get-ItemProperty hklm:\software\Microsoft\MSBuild\ToolsVersions\4.0).MSBuildToolsPath
Expand All @@ -58,6 +56,8 @@ echo "===> Building Installer"
Push-Location -Path "scripts\pkg\windows\nri-$arch-installer"

$env:exporterName = $exporterName
$env:IntegrationVersion = $version
$env:UpgradeCode = $upgradeGUID
. $msBuild/MSBuild.exe nri-installer.wixproj

if (-not $?)
Expand Down
Loading

0 comments on commit 04efd4b

Please sign in to comment.