-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Beta1: Update to generic Update script
Summary: * Add `update.ini` file for updates * Replace the previous upload script with `Update.ps1`.
- Loading branch information
Showing
4 changed files
with
238 additions
and
65 deletions.
There are no files selected for viewing
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
[Version] | ||
Package = 1.8.3.0 | ||
Display = 1.8.3-beta1-uroesch | ||
|
||
[Archive] | ||
URL1 = https://netcologne.dl.sourceforge.net/project/ldapadmin/ldapadmin/1.8.3/LdapAdminExe-w64-1.8.3.zip | ||
Checksum1 = SHA256:E2E9A3603150D14E2F7AE2CD85878CE187D953FF8FA01FCAA5B73949E573A4DE | ||
TargetDir1 = LdapAdmin64.exe | ||
ExtractDir1 = LdapAdmin.exe | ||
URL2 = https://netcologne.dl.sourceforge.net/project/ldapadmin/ldapadmin/1.8.3/LdapAdminExe-w32-1.8.3.zip | ||
Checksum2 = SHA256:20343E6B2F85E51FFB9CEEB88804CF1E24DA1B1055A48A4AD0ECD170BDDA7BDC | ||
TargetDir2 = LdapAdmin.exe | ||
ExtractDir2 = LdapAdmin.exe |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,225 @@ | ||
# ----------------------------------------------------------------------------- | ||
# Description: Generic Update Script for PortableApps | ||
# Author: Urs Roesch <[email protected]> | ||
# ----------------------------------------------------------------------------- | ||
|
||
# ----------------------------------------------------------------------------- | ||
# Globals | ||
# ----------------------------------------------------------------------------- | ||
$AppRoot = "$PSScriptRoot\..\.." | ||
$AppInfoDir = "$AppRoot\App\AppInfo" | ||
$AppInfoIni = "$AppInfoDir\appinfo.ini" | ||
$UpdateIni = "$AppInfoDir\update.ini" | ||
$Debug = $True | ||
|
||
# ----------------------------------------------------------------------------- | ||
# Functions | ||
# ----------------------------------------------------------------------------- | ||
Function Debug () { | ||
param( [string] $Message ) | ||
If (-Not($Debug)) { return } | ||
Write-Host $Message | ||
} | ||
|
||
# ----------------------------------------------------------------------------- | ||
Function Parse-Ini { | ||
param ( | ||
$IniFile | ||
) | ||
|
||
$IniContent = Get-Content $IniFile | ||
|
||
$resulttable=@() | ||
foreach ($line in $IniContent) { | ||
Debug "Processing $line" | ||
if ($line[0] -eq ";") { | ||
Debug "Skip comment line" | ||
} | ||
|
||
elseif ($line[0] -eq "[") { | ||
$Section = $line.replace("[","").replace("]","") | ||
Debug "Found new section: $Section" | ||
} | ||
elseif ($line -like "*=*") { | ||
Debug "Found Keyline" | ||
$resulttable += @{ | ||
Section = $Section | ||
Key = $line.split("=")[0].Trim() | ||
Value = $line.split("=")[1].Trim() | ||
} | ||
} | ||
else { | ||
Debug "Skip line" | ||
} | ||
} | ||
return $resulttable | ||
} | ||
|
||
# ----------------------------------------------------------------------------- | ||
Function Fetch-Section() { | ||
param( [string] $Key ) | ||
$Section = @{} | ||
Foreach ($Item in $Config) { | ||
If ($Item["Section"] -eq $Key) { | ||
$Section += @{ $Item["Key"] = $Item["Value"] } | ||
} | ||
} | ||
return $Section | ||
} | ||
|
||
# ----------------------------------------------------------------------------- | ||
Function Url-Basename { | ||
param( | ||
[string] $URL | ||
) | ||
$Elements = $URL.split('/') | ||
$Basename = $Elements[$($Elements.Length-1)] | ||
return $Basename | ||
} | ||
|
||
# ----------------------------------------------------------------------------- | ||
Function Check-Sum { | ||
param( | ||
[string] $Checksum, | ||
[string] $File | ||
) | ||
($Algorithm, $Sum) = $Checksum.Split(':') | ||
$Result = (Get-FileHash -Path $File -Algorithm $Algorithm).Hash | ||
Debug "Checksum of INI ($Sum) and downloaded file ($Result)" | ||
return ($Sum -eq $Result) | ||
} | ||
|
||
# ----------------------------------------------------------------------------- | ||
Function Download-ZIP { | ||
param( | ||
[string] $URL, | ||
[string] $Checksum | ||
) | ||
$PathZip = "$PSScriptRoot\$(Url-Basename -URL $URL)" | ||
If (!(Test-Path $PathZip)) { | ||
Debug "Downloading file from '$URL'" | ||
Invoke-WebRequest -Uri $URL -OutFile $PathZip | ||
} | ||
If (!(Check-Sum -Checksum $Checksum -File $PathZip)) { | ||
Debug "Checksum of File $PathZip does not match with '$Checksum'" | ||
Exit 1 | ||
} | ||
Debug "Downloaded ZIP file '$PathZip'" | ||
return $PathZip | ||
} | ||
|
||
# ----------------------------------------------------------------------------- | ||
Function Update-Zip { | ||
param( | ||
[string] $URL, | ||
[string] $TargetDir, | ||
[string] $ExtractDir, | ||
[string] $Checksum | ||
) | ||
$ZipFile = $(Download-ZIP -URL $URL -Checksum $Checksum) | ||
$TargetPath = "$AppRoot\App\$TargetDir" | ||
Expand-Archive -LiteralPath $ZipFile -DestinationPath $PSScriptRoot -Force | ||
If (Test-Path $TargetPath) { | ||
Write-Output "Removing $TargetPath" | ||
Remove-Item -Path $TargetPath -Force -Recurse | ||
} | ||
Debug "Move $ExtractDir to $TargetPath" | ||
Move-Item -Path $PSScriptRoot\$ExtractDir -Destination $TargetPath -Force | ||
Debug "Cleanup $ZipFile" | ||
Remove-Item $ZipFile | ||
} | ||
|
||
# ----------------------------------------------------------------------------- | ||
Function Update-Appinfo-Item() { | ||
param( | ||
[string] $IniFile, | ||
[string] $Match, | ||
[string] $Replace | ||
) | ||
If (Test-Path $IniFile) { | ||
$Content = (Get-Content $IniFile) | ||
$Content -replace $Match, $Replace | Out-File -FilePath $IniFile | ||
} | ||
} | ||
|
||
# ----------------------------------------------------------------------------- | ||
Function Update-Appinfo() { | ||
$Version = (Fetch-Section "Version") | ||
Update-Appinfo-Item ` | ||
-IniFile $AppInfoIni ` | ||
-Match '^PackageVersion\s*=.*' ` | ||
-Replace "PackageVersion=$($Version['Package'])" | ||
Update-Appinfo-Item ` | ||
-IniFile $AppInfoIni ` | ||
-Match '^DisplayVersion\s*=.*' ` | ||
-Replace "DisplayVersion=$($Version['Display'])" | ||
} | ||
|
||
# ----------------------------------------------------------------------------- | ||
Function Update-Application() { | ||
$Archive = (Fetch-Section 'Archive') | ||
$Position = 1 | ||
While ($True) { | ||
If (-Not ($Archive.ContainsKey("URL$Position"))) { | ||
Break | ||
} | ||
Update-ZIP ` | ||
-URL $Archive["URL$Position"] ` | ||
-TargetDir $Archive["TargetDir$Position"] ` | ||
-ExtractDir $Archive["ExtractDir$Position"] ` | ||
-Checksum $Archive["Checksum$Position"] | ||
$Position += 1 | ||
} | ||
} | ||
|
||
# ----------------------------------------------------------------------------- | ||
Function Windows-Path() { | ||
param( [string] $Path ) | ||
$Path = $Path -replace ".*drive_(.)", '$1:' | ||
$Path = $Path.Replace("/", "\") | ||
return $Path | ||
} | ||
|
||
# ----------------------------------------------------------------------------- | ||
Function Create-Launcher() { | ||
Set-Location $AppRoot | ||
$AppPath = (Get-Location) | ||
$Launcher = "..\PortableApps.comLauncher\PortableApps.comLauncherGenerator.exe" | ||
If ($AppPath[0] -eq '/') { | ||
Debug "Running Launcher: wine $Launcher $(Windows-Path AppPath)" | ||
Invoke-Expression "wine $Launcher /s $(Windows-Path $AppPath)" | ||
} | ||
Else { | ||
Debug "Running Launcher: wine $Launcher AppPath" | ||
Invoke-Expression "$Launcher $AppPath" | ||
} | ||
Write-FileSystemCache $AppPath.Drive.Name | ||
} | ||
|
||
# ----------------------------------------------------------------------------- | ||
Function Create-Installer() { | ||
Set-Location $AppRoot | ||
$AppPath = (Get-Location) | ||
$Installer = "..\PortableApps.comInstaller\PortableApps.comInstaller.exe" | ||
If ($AppPath[0] -eq '/') { | ||
Debug "Running Installer: wine $Installer $(Windows-Path AppPath)" | ||
Invoke-Expression "wine $Installer $(Windows-Path $AppPath)" | ||
} | ||
Else { | ||
# Windows seems to need a bit of break before | ||
# writing the file completely to disk | ||
Debug "Sleeping ..." | ||
Sleep 5 | ||
Debug "Running Installer: $Installer $AppPath" | ||
Invoke-Expression "$Installer $AppPath" | ||
} | ||
} | ||
|
||
# ----------------------------------------------------------------------------- | ||
# Main | ||
# ----------------------------------------------------------------------------- | ||
$Config = (Parse-Ini $UpdateIni) | ||
Update-Application | ||
Update-Appinfo | ||
Create-Launcher | ||
Create-Installer |
This file was deleted.
Oops, something went wrong.