mirror of
https://github.com/prometheus-community/windows_exporter
synced 2025-02-17 12:37:30 +00:00
installer/build.ps1: autoformat
This commit is contained in:
parent
191debeed6
commit
cede267565
@ -1,12 +1,12 @@
|
|||||||
[CmdletBinding()]
|
[CmdletBinding()]
|
||||||
Param (
|
Param (
|
||||||
[Parameter(Mandatory=$true)]
|
[Parameter(Mandatory = $true)]
|
||||||
[String] $PathToExecutable,
|
[String] $PathToExecutable,
|
||||||
[Parameter(Mandatory=$true)]
|
[Parameter(Mandatory = $true)]
|
||||||
[String] $Version,
|
[String] $Version,
|
||||||
[Parameter(Mandatory=$false)]
|
[Parameter(Mandatory = $false)]
|
||||||
[ValidateSet("amd64","386")]
|
[ValidateSet("amd64", "386")]
|
||||||
[String] $Arch = "amd64"
|
[String] $Arch = "amd64"
|
||||||
)
|
)
|
||||||
$ErrorActionPreference = "Stop"
|
$ErrorActionPreference = "Stop"
|
||||||
|
|
||||||
@ -15,32 +15,32 @@ $PathToExecutable = Resolve-Path $PathToExecutable
|
|||||||
# Set working dir to this directory, reset previous on exit
|
# Set working dir to this directory, reset previous on exit
|
||||||
Push-Location $PSScriptRoot
|
Push-Location $PSScriptRoot
|
||||||
Trap {
|
Trap {
|
||||||
# Reset working dir on error
|
# Reset working dir on error
|
||||||
Pop-Location
|
Pop-Location
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($PSVersionTable.PSVersion.Major -lt 5) {
|
if ($PSVersionTable.PSVersion.Major -lt 5) {
|
||||||
Write-Error "Powershell version 5 required"
|
Write-Error "Powershell version 5 required"
|
||||||
exit 1
|
exit 1
|
||||||
}
|
}
|
||||||
|
|
||||||
$wc = New-Object System.Net.WebClient
|
$wc = New-Object System.Net.WebClient
|
||||||
function Get-FileIfNotExists {
|
function Get-FileIfNotExists {
|
||||||
Param (
|
Param (
|
||||||
$Url,
|
$Url,
|
||||||
$Destination
|
$Destination
|
||||||
)
|
)
|
||||||
if(-not (Test-Path $Destination)) {
|
if (-not (Test-Path $Destination)) {
|
||||||
Write-Verbose "Downloading $Url"
|
Write-Verbose "Downloading $Url"
|
||||||
$wc.DownloadFile($Url, $Destination)
|
$wc.DownloadFile($Url, $Destination)
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
Write-Verbose "${Destination} already exists. Skipping."
|
Write-Verbose "${Destination} already exists. Skipping."
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$sourceDir = mkdir -Force Source
|
$sourceDir = mkdir -Force Source
|
||||||
mkdir -Force Work,Output | Out-Null
|
mkdir -Force Work, Output | Out-Null
|
||||||
|
|
||||||
Write-Verbose "Downloading WiX..."
|
Write-Verbose "Downloading WiX..."
|
||||||
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
|
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
|
||||||
@ -51,7 +51,7 @@ Expand-Archive -Path "${sourceDir}\wix-binaries.zip" -DestinationPath WiX -Force
|
|||||||
Copy-Item -Force $PathToExecutable Work/wmi_exporter.exe
|
Copy-Item -Force $PathToExecutable Work/wmi_exporter.exe
|
||||||
|
|
||||||
Write-Verbose "Creating wmi_exporter-${Version}-${Arch}.msi"
|
Write-Verbose "Creating wmi_exporter-${Version}-${Arch}.msi"
|
||||||
$wixArch = @{"amd64"="x64"; "386"="x86"}[$Arch]
|
$wixArch = @{"amd64" = "x64"; "386" = "x86"}[$Arch]
|
||||||
$wixOpts = "-ext WixFirewallExtension"
|
$wixOpts = "-ext WixFirewallExtension"
|
||||||
Invoke-Expression "WiX\candle.exe -nologo -arch $wixArch $wixOpts -out Work\wmi_exporter.wixobj -dVersion=`"$Version`" wmi_exporter.wxs"
|
Invoke-Expression "WiX\candle.exe -nologo -arch $wixArch $wixOpts -out Work\wmi_exporter.wixobj -dVersion=`"$Version`" wmi_exporter.wxs"
|
||||||
Invoke-Expression "WiX\light.exe -nologo -spdb $wixOpts -out `"Output\wmi_exporter-${Version}-${Arch}.msi`" Work\wmi_exporter.wixobj"
|
Invoke-Expression "WiX\light.exe -nologo -spdb $wixOpts -out `"Output\wmi_exporter-${Version}-${Arch}.msi`" Work\wmi_exporter.wixobj"
|
||||||
|
Loading…
Reference in New Issue
Block a user