Fix incorrect variable overrides

This commit is contained in:
Manuel Thalmann 2023-06-08 02:28:33 +02:00
parent 24ef21e8d4
commit e0fd6a6de7
11 changed files with 111 additions and 69 deletions

View file

@ -1,7 +1,19 @@
. "$PSScriptRoot/../../Scripts/Context.ps1";
$path = "$env:LOCALAPPDATA/LGHUB";
$softwareName = "LGHub";
function Invoke-BackupLGHub([Context] $context) {
$context.Backup($path, $context.SoftwareArchive($softwareName), @("-i!settings.db*", "-i!icon_cache"));
$null = New-Module {
$path = "$env:LOCALAPPDATA/LGHUB";
$softwareName = "LGHub";
function Invoke-BackupLGHub([Context] $context) {
$hubName = "lghub.exe";
$mainProcesses = Get-Process | Where-Object { [System.IO.Path]::GetFileName($_.Path) -eq "$hubName" };
$lghub = $mainProcesses[0].Path;
$hubProcesses = ($mainProcesses + (Get-Process | Where-Object { @("$hubName", "lghub_agent.exe", "lghub_system_tray.exe") -contains [System.IO.Path]::GetFileName($_.Path) }));
$hubProcesses | Foreach-Object { $_.Kill() };
$context.Backup($path, $context.SoftwareArchive($softwareName), @("-i!settings.db*", "-i!icon_cache"));
if ($lghub) {
& "$lghub";
}
}
}

View file

@ -1,7 +1,10 @@
. "$PSScriptRoot/../../Scripts/Context.ps1";
$path = "$HOME/Documents/ManiaPlanet";
$softwareName = "ManiaPlanet";
function Invoke-BackupManiaPlanet([Context] $context) {
$context.Backup($path, $context.SoftwareArchive($softwareName), @("-i@`"$PSScriptRoot/include.txt`""));
$null = New-Module {
$path = "$HOME/Documents/ManiaPlanet";
$softwareName = "ManiaPlanet";
function Invoke-BackupManiaPlanet([Context] $context) {
$context.Backup($path, $context.SoftwareArchive($softwareName), @("-i@`"$PSScriptRoot/include.txt`""));
}
}

View file

@ -1,16 +1,19 @@
. "$PSScriptRoot/../../Scripts/Context.ps1";
$softwareName = "PuTTY";
$configFile = "${softwareName}.reg";
function New-TempDirectory() {
$tempDir = Join-Path $([System.IO.Path]::GetTempPath()) $([System.IO.Path]::GetRandomFileName());
$null = New-Item -ItemType Directory $tempDir;
return $tempDir;
}
$null = New-Module {
$softwareName = "PuTTY";
$configFile = "$($softwareName).reg";
function Invoke-BackupPuTTY([Context] $context) {
$tempDir = New-TempDirectory;
$fileName = Join-Path "$tempDir" $configFile;
& reg export "HKCU\Software\SimonTatham" "$fileName" /y;
$context.Backup($tempDir, $context.SoftwareArchive($softwareName), @());
function New-TempDirectory() {
$tempDir = Join-Path $([System.IO.Path]::GetTempPath()) $([System.IO.Path]::GetRandomFileName());
$null = New-Item -ItemType Directory $tempDir;
return $tempDir;
}
function Invoke-BackupPuTTY([Context] $context) {
$tempDir = New-TempDirectory;
$fileName = Join-Path "$tempDir" $configFile;
& reg export "HKCU\Software\SimonTatham" "$fileName" /y;
$context.Backup($tempDir, $context.SoftwareArchive($softwareName), @());
}
}

View file

@ -1,7 +1,10 @@
. "$PSScriptRoot/../../Scripts/Context.ps1";
$path = "C:/tools/RetroArch-Win64";
$softwareName = "RetroArch";
function Invoke-BackupRetroArch([Context] $context) {
$context.Backup($path, $context.SoftwareArchive($softwareName), @("-i@`"$PSScriptRoot/include.txt`""));
$null = New-Module {
$path = "C:/tools/RetroArch-Win64";
$softwareName = "RetroArch";
function Invoke-BackupRetroArch([Context] $context) {
$context.Backup($path, $context.SoftwareArchive($softwareName), @("-i@`"$PSScriptRoot/include.txt`""));
}
}

View file

@ -1,7 +1,10 @@
. "$PSScriptRoot/../../Scripts/Context.ps1";
$path = "$HOME/Documents/TmForever";
$softwareName = "TmNationsForever";
function Invoke-BackupTmNations([Context] $context) {
$context.Backup($path, $context.SoftwareArchive($softwareName), @("-i@`"$PSScriptRoot/include.txt`""));
$null = New-Module {
$path = "$HOME/Documents/TmForever";
$softwareName = "TmNationsForever";
function Invoke-BackupTmNations([Context] $context) {
$context.Backup($path, $context.SoftwareArchive($softwareName), @("-i@`"$PSScriptRoot/include.txt`""));
}
}

View file

@ -1,7 +1,10 @@
. "$PSScriptRoot/../../Scripts/Context.ps1";
$path = "$HOME/Documents/TrackMania";
$softwareName = "TmUnitedForever";
function Invoke-BackupTmUnited([Context] $context) {
$context.Backup($path, $context.SoftwareArchive($softwareName), @("-i@`"$PSScriptRoot/include.txt`""));
$null = New-Module {
$path = "$HOME/Documents/TrackMania";
$softwareName = "TmUnitedForever";
function Invoke-BackupTmUnited([Context] $context) {
$context.Backup($path, $context.SoftwareArchive($softwareName), @("-i@`"$PSScriptRoot/include.txt`""));
}
}

View file

@ -1,27 +1,30 @@
Import-Module "KnownFolders";
. "$PSScriptRoot/../../Scripts/Context.ps1";
$programs32Path = $(Get-KnownFolder "ProgramFilesX86").Path;
$vsInstaller = "$programs32Path/Microsoft Visual Studio/Installer/vs_installer.exe";
[System.Tuple[string, string, string][]]$versions = @(
[System.Tuple]::Create("visualstudio2019enterprise", "VisualStudio.16.Release", "Microsoft.VisualStudio.Product.Enterprise"));
$null = New-Module {
$programs32Path = $(Get-KnownFolder "ProgramFilesX86").Path;
$vsInstaller = "$programs32Path/Microsoft Visual Studio/Installer/vs_installer.exe";
function Get-ConfigPath([Context] $context, [string] $packageName) {
return Join-Path $($context.BackupRoot()) $packageName ".vsconfig";
}
[System.Tuple[string, string, string][]]$versions = @(
[System.Tuple]::Create("visualstudio2019enterprise", "VisualStudio.16.Release", "Microsoft.VisualStudio.Product.Enterprise"));
function Invoke-BackupVisualStudio([Context] $context) {
foreach ($version in $versions) {
$configPath = Get-ConfigPath $context $version[0];
$null = New-Item -Force -ItemType Directory "$(Split-Path -Parent $configPath)";
function Get-ConfigPath([Context] $context, [string] $packageName) {
return Join-Path $($context.BackupRoot()) $packageName ".vsconfig";
}
Start-Process -FilePath "$vsInstaller" `
-Wait `
-ArgumentList @(
"export",
"--channelId", "$($version[1])",
"--productId", "$($version[2])",
"--config", "$configPath",
"--quiet");
function Invoke-BackupVisualStudio([Context] $context) {
foreach ($version in $versions) {
$configPath = Get-ConfigPath $context $version[0];
$null = New-Item -Force -ItemType Directory "$(Split-Path -Parent $configPath)";
Start-Process -FilePath "$vsInstaller" `
-Wait `
-ArgumentList @(
"export",
"--channelId", "$($version[1])",
"--productId", "$($version[2])",
"--config", "$configPath",
"--quiet");
}
}
}

View file

@ -1,5 +1,8 @@
. "$PSScriptRoot/../../Scripts/Context.ps1";
$configBaseName = ".gitconfig";
$configPath = Join-Path "$HOME" "$configBaseName";
function Invoke-BackupGit([Context] $context) {}
$null = New-Module {
$configBaseName = ".gitconfig";
$configPath = Join-Path "$HOME" "$configBaseName";
function Invoke-BackupGit([Context] $context) {}
}

View file

@ -1,10 +1,13 @@
. "$PSScriptRoot/../../Scripts/Context.ps1";
$path = "$env:LOCALAPPDATA/osu!";
$softwareName = "osu!";
$genericConfigName = "osu!.User.cfg";
function Invoke-BackupOsu([Context] $context) {
$archive = $context.SoftwareArchive($softwareName);
$context.Backup($path, $archive, @("-i@`"$PSScriptRoot/include.txt`""));
& 7z rn "$archive" "osu!.$env:USERNAME.cfg" $genericConfigName;
$null = New-Module {
$path = "$env:LOCALAPPDATA/osu!";
$softwareName = "osu!";
$genericConfigName = "osu!.User.cfg";
function Invoke-BackupOsu([Context] $context) {
$archive = $context.SoftwareArchive($softwareName);
$context.Backup($path, $archive, @("-i@`"$PSScriptRoot/include.txt`""));
& 7z rn "$archive" "osu!.$env:USERNAME.cfg" $genericConfigName;
}
}

View file

@ -1,7 +1,10 @@
. "$PSScriptRoot/../../Scripts/Context.ps1";
$path = "$env:APPDATA/osu";
$softwareName = "osu!lazer";
function Invoke-BackupOsuLazer([Context] $context) {
$context.Backup($path, $context.SoftwareArchive($softwareName), @("-i@`"$PSScriptRoot/include.txt`"", "-i!*.realm", "-i!*.db"));
$null = New-Module {
$path = "$env:APPDATA/osu";
$softwareName = "osu!lazer";
function Invoke-BackupOsuLazer([Context] $context) {
$context.Backup($path, $context.SoftwareArchive($softwareName), @("-i@`"$PSScriptRoot/include.txt`"", "-i!*.realm", "-i!*.db"));
}
}

View file

@ -1,7 +1,10 @@
. "$PSScriptRoot/../../Scripts/Context.ps1";
$path = "$env:PUBLIC/Documents/reWASD";
$softwareName = "reWASD";
function Invoke-BackupReWASD([Context] $context) {
$context.Backup($path, $context.SoftwareArchive($softwareName), @("-x@`"$PSScriptRoot/exclude.txt`""));
$null = New-Module {
$path = "$env:PUBLIC/Documents/reWASD";
$softwareName = "reWASD";
function Invoke-BackupReWASD([Context] $context) {
$context.Backup($path, $context.SoftwareArchive($softwareName), @("-x@`"$PSScriptRoot/exclude.txt`""));
}
}