This repository has been archived by the owner on Mar 28, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
/
update.ps1
48 lines (40 loc) · 2.01 KB
/
update.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
import-module au
$releases = "https://build.openvpn.net/downloads/releases/"
$openvpnInstallerUrl = 'https://build.openvpn.net/downloads/releases/latest/openvpn-install-latest-stable.exe'
$openvpnInstallerPgpSignatureUrl = 'https://build.openvpn.net/downloads/releases/latest/openvpn-install-latest-stable.exe.asc'
function global:au_SearchReplace {
@{
".\tools\chocolateyInstall.ps1" = @{
"(^[$]openvpnInstallerHash\s*=\s*)('.*')" = "`$1'$($Latest.openvpnInstallerHash)'"
"(^[$]openvpnInstallerPgpSignatureHash\s*=\s*)('.*')" = "`$1'$($Latest.openvpnInstallerPgpSignatureHash)'"
}
}
}
function au_BeforeUpdate {
# We can't rely on Get-RemoteChecksum as we want to have the files locally
# as well and this function will download a local copy of the file, just to
# compute its hashes, then drop it. We can't rely completely on
# Get-RemoteFiles either as that function is only taking Latest URLs (x64
# and x32) into account. The signatures are not supported.
# src.: https://github.com/majkinetor/au/tree/master/AU/Public
$client = New-Object System.Net.WebClient
$toolsPath = Resolve-Path tools
$filePath = "$toolsPath/openvpn_installer.exe"
Write-Host "Downloading installer to '$filePath'..."
$client.DownloadFile($openvpnInstallerUrl, $filePath)
$Latest.openvpnInstallerHash = Get-FileHash $filePath -Algorithm sha512 | % Hash
$filePath = "$toolsPath/openvpn_installer.exe.asc"
Write-Host "Downloading installer signature to '$filePath'..."
$client.DownloadFile($openvpnInstallerPgpSignatureUrl, $filePath)
$Latest.openvpnInstallerPgpSignatureHash = Get-FileHash $filePath -Algorithm sha512 | % Hash
}
function global:au_GetLatest {
$versionPage = $releases + "latest/LATEST.txt"
$versionPage = Invoke-WebRequest -UseBasicParsing -Uri $versionPage
$version = $versionPage.Content -match "(?<=OpenVPN stable version: )[0-9.]+"
$version = $matches[0]
@{
version = $version
}
}
update -ChecksumFor none