Add WinSW automatic update manifest
This commit is contained in:
28
publish.ps1
28
publish.ps1
@@ -21,12 +21,6 @@ $daemonSource = Join-Path $PSScriptRoot "daemon"
|
||||
$winSwSource = Resolve-Path (Join-Path $daemonSource "smartb2bsync-enova.exe")
|
||||
$output = [System.IO.Path]::GetFullPath($OutputPath)
|
||||
$daemonOutput = Join-Path $output "daemon"
|
||||
$existingConfigurationPath = Join-Path $output "config\enova.json"
|
||||
$existingConfiguration = if (Test-Path -LiteralPath $existingConfigurationPath) {
|
||||
[System.IO.File]::ReadAllText($existingConfigurationPath)
|
||||
} else {
|
||||
$null
|
||||
}
|
||||
|
||||
if ($output -eq [System.IO.Path]::GetPathRoot($output) -or $output.Length -lt 10) {
|
||||
throw "Niebezpieczna ścieżka wyjściowa: $output"
|
||||
@@ -49,11 +43,23 @@ Copy-Item (Join-Path $daemonSource "smartb2bsync-enova.xml") $daemonOutput -Forc
|
||||
Copy-Item (Join-Path $daemonSource "install.cmd") $daemonOutput -Force
|
||||
Copy-Item (Join-Path $daemonSource "uninstall.cmd") $daemonOutput -Force
|
||||
|
||||
if ($null -ne $existingConfiguration) {
|
||||
[System.IO.File]::WriteAllText(
|
||||
(Join-Path $output "config\enova.json"),
|
||||
$existingConfiguration,
|
||||
[System.Text.UTF8Encoding]::new($false))
|
||||
$downloadBaseUrl = "https://demo.smartb2b.eu/files/smartb2b-sync-enova/"
|
||||
[xml]$manifest = Get-Content -Raw (Join-Path $daemonOutput "smartb2bsync-enova.xml")
|
||||
$downloadedFiles = @(
|
||||
$manifest.service.download |
|
||||
ForEach-Object { $_.from.Substring($downloadBaseUrl.Length).Replace('/', '\') } |
|
||||
Sort-Object
|
||||
)
|
||||
$packagedFiles = @(
|
||||
Get-ChildItem -Recurse -File $output |
|
||||
ForEach-Object { $_.FullName.Substring($output.Length).TrimStart('\') } |
|
||||
Where-Object { $_ -ne "daemon\smartb2bsync-enova.exe" } |
|
||||
Sort-Object
|
||||
)
|
||||
$manifestDifferences = @(Compare-Object $packagedFiles $downloadedFiles)
|
||||
if ($manifestDifferences.Count -ne 0) {
|
||||
$details = $manifestDifferences | ForEach-Object { "$($_.SideIndicator) $($_.InputObject)" }
|
||||
throw "Lista plików <download> nie odpowiada paczce:`n$($details -join "`n")"
|
||||
}
|
||||
|
||||
Write-Host "Gotowa usługa: $output"
|
||||
|
||||
Reference in New Issue
Block a user