diff --git a/.gitignore b/.gitignore index e506c96..a152d2b 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,5 @@ *.exe Data/ +App/AppInfo/pac_installer_log.ini App/Git Download diff --git a/App/AppInfo/update.ini b/App/AppInfo/update.ini index d1f7905..b49fa20 100644 --- a/App/AppInfo/update.ini +++ b/App/AppInfo/update.ini @@ -4,6 +4,6 @@ Display = 2.27.0-beta4-uroesch [Archive] URL1 = https://github.com/git-for-windows/git/releases/download/v2.27.0.windows.1/PortableGit-2.27.0-32-bit.7z.exe -Checksum1 = SHA256:8cbe1e3b57eb9d02e92cff12089454f2cf090c02958080d62e199ef8764542d3 +Checksum1 = SHA256::8cbe1e3b57eb9d02e92cff12089454f2cf090c02958080d62e199ef8764542d3 TargetName1 = Git ExtractName1 = diff --git a/Other/Update/PA-Upgrade.ps1 b/Other/Update/PA-Upgrade.ps1 index 3c54732..61cfa08 100644 --- a/Other/Update/PA-Upgrade.ps1 +++ b/Other/Update/PA-Upgrade.ps1 @@ -11,7 +11,7 @@ Using module ".\PortableAppsCommon.psm1" # ----------------------------------------------------------------------------- # Globals # ----------------------------------------------------------------------------- -$Version = "0.0.2-alpha" +$Version = "0.0.3-alpha" $Debug = $True $SiteUrl = "https://github.com" $ReleaseUrl = "$SiteUrl/uroesch/$AppName/releases/" @@ -79,24 +79,21 @@ Function Invoke-Installer() { param( [string] $Command ) + Set-Location "$AppRoot\.." + $PARoot = (Get-Location) + $Arguments = "/AUTOCLOSE=true " + + "/DESTINATION=""$(ConvertTo-WindowsPath $PARoot)\\""" # Addtional Switches for paf.exe # /HIDEINSTALLER=true # /SILENT=true Switch (Test-Unix) { $True { - Set-Location "$AppRoot\.." - $PARoot = (Get-Location) - $Arguments = "/SILENT=true /AUTOCLOSE=true /DESTINATION=""$(ConvertTo-WindowsPath $PARoot)\\""" $Arguments = "$Command $Arguments" $Command = "wine" break } - default { - Set-Location "$AppRoot" - $AppRoot = (Get-Location) - $Arguments = "/AUTOCLOSE=true /DESTINATION=""$(ConvertTo-WindowsPath $AppRoot)""" - } + default { } } Debug info "Run PA $Command $Arguments" diff --git a/Other/Update/PortableAppsCommon.psm1 b/Other/Update/PortableAppsCommon.psm1 index d3e4a5b..1197af5 100644 --- a/Other/Update/PortableAppsCommon.psm1 +++ b/Other/Update/PortableAppsCommon.psm1 @@ -10,6 +10,7 @@ $AppRoot = $(Convert-Path "$PSScriptRoot\..\..") $AppName = (Get-Item $AppRoot).Basename $AppDir = "$AppRoot\App" +$DownloadDir = "$AppRoot\Download" $AppInfoDir = "$AppDir\AppInfo" $AppInfoIni = "$AppInfoDir\appinfo.ini" $UpdateIni = "$AppInfoDir\update.ini" @@ -191,6 +192,25 @@ Function Debug() { Write-Host $Message.Replace($(Switch-Path "$AppRoot\"), '') } +# ----------------------------------------------------------------------------- +Function Download-Checksum() { + Param( + [String] $Uri + ) + Try { + $OutFile = $DownloadDir + "\" + ($Uri.split('/'))[-1] + Invoke-WebRequest ` + -Uri $Uri ` + -OutFile $OutFile + $Sum = (Get-Content -Path $OutFile) + Return $Sum + } + Catch { + Debug error "Unable to download checksum from URL '$Uri'" + Exit 124 + } +} + # ----------------------------------------------------------------------------- Function Compare-Checksum { param( @@ -198,7 +218,11 @@ Function Compare-Checksum { [string] $Checksum ) - ($Algorithm, $Sum) = $Checksum.Split(':') + ($Algorithm, $Sum) = $Checksum.Split('::') + If ($Sum -like 'http*') { + $Sum = Download-Checksum -Uri $Sum + $Checksum = $Algorithm + "::" + $Sum + } $Result = Get-Checksum -Path $Path -Algorithm $Algorithm Debug info "Checksum of INI ($($Checksum.ToUpper())) and download ($Result)" return ($Checksum.ToUpper() -eq $Result) @@ -206,12 +230,12 @@ Function Compare-Checksum { # ----------------------------------------------------------------------------- Function Get-Checksum { - param( + Param( [string] $Path, [string] $Algorithm ) $Hash = (Get-FileHash -Path $Path -Algorithm $Algorithm).Hash - Return ($Algorithm + ":" + $Hash).ToUpper() + Return ($Algorithm + "::" + $Hash).ToUpper() } # -----------------------------------------------------------------------------