-
Notifications
You must be signed in to change notification settings - Fork 384
/
Copy pathupdate.ps1
66 lines (53 loc) · 2.67 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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
Import-Module Chocolatey-AU
$toolsDir = "$(Split-Path -parent $MyInvocation.MyCommand.Definition)\tools\"
. $toolsDir\helpers.ps1
function global:au_BeforeUpdate {
if ($Latest.Title -like '*Fresh*') {
Copy-Item "$PSScriptRoot\README.fresh.md" "$PSScriptRoot\README.md" -Force
}
else {
Copy-Item "$PSScriptRoot\README.still.md" "$PSScriptRoot\README.md" -Force
}
}
function global:au_SearchReplace {
$filesToPatchHashTable = @{
".\tools\chocolateyInstall.ps1" = @{
"(?i)(^\s*packageName\s*=\s*)('.*')" = "`$1'$($Latest.PackageName)'"
"(?i)(^\s*fileType\s*=\s*)('.*')" = "`$1'$($Latest.FileType)'"
"(?i)(^\s*url\s*=\s*)('.*')" = "`$1'$($Latest.URL32)'"
"(?i)(^\s*url64bit\s*=\s*)('.*')" = "`$1'$($Latest.URL64)'"
"(?i)(^\s*checksum\s*=\s*)('.*')" = "`$1'$($Latest.Checksum32)'"
"(?i)(^\s*checksum64\s*=\s*)('.*')" = "`$1'$($Latest.Checksum64)'"
"(?i)(^\s*version\s*=\s*)('.*')" = "`$1'$($Latest.Version)'"
}
".\libreoffice-streams.nuspec" = @{
"(?i)(^\s*\<title\>).*(\<\/title\>)" = "`${1}$($Latest.Title)`${2}"
}
}
$linesToPatch = $filesToPatchHashTable[".\tools\chocolateyInstall.ps1"]
if ($Latest.FileType -eq "exe") {
$linesToPatch["(?i)(^\s*silentArgs\s*=\s*)('.*')"] = "`$1'/S'"
} else {
$linesToPatch["(?i)(^\s*silentArgs\s*=\s*)(.*)"] = "`$1'/qn /passive /norestart /l*v `"{0}`"' -f `"`$(`$env:TEMP)\`$(`$env:ChocolateyPackageName).`$(`$env:ChocolateyPackageVersion).MsiInstall.log`""
}
$filesToPatchHashTable[".\tools\chocolateyInstall.ps1"] = $linesToPatch
return $filesToPatchHashTable
}
function global:au_AfterUpdate {
# Patch the json stream file
$global:chocolateyCoreteampackagesLibreofficeStreamJson | ConvertTo-Json | Set-Content .\libreoffice-streams.json
}
function global:au_GetLatest {
$global:chocolateyCoreteampackagesLibreofficeStreamJson = (Get-Content .\libreoffice-streams.json) | ConvertFrom-Json
$stillVersionFrom = $global:chocolateyCoreteampackagesLibreofficeStreamJson.still
$stillVersionTo = GetLatestStillVersionFromLibOUpdateChecker
$freshVersionFrom = $global:chocolateyCoreteampackagesLibreofficeStreamJson.fresh
$freshVersionTo = GetLatestFreshVersionFromLibOUpdateChecker
$global:chocolateyCoreteampackagesLibreofficeStreamJson.still = $stillVersionTo
$global:chocolateyCoreteampackagesLibreofficeStreamJson.fresh = $freshVersionTo
$streams = New-Object -TypeName System.Collections.Specialized.OrderedDictionary
AddLibOVersionsToStreams $streams "still" $stillVersionFrom $stillVersionTo
AddLibOVersionsToStreams $streams "fresh" $freshVersionFrom $freshVersionTo
return @{ Streams = $streams }
}
update -ChecksumFor none