From 10127051602ff67f2767c8aa60ba893b54b9d341 Mon Sep 17 00:00:00 2001 From: Manuel Thalmann Date: Wed, 31 Jul 2024 14:47:42 +0200 Subject: [PATCH] Copy `pwsh` to newly setup windows systems --- profiles/DerGeret/Windows/Restore.ps1 | 3 +-- scripts/Windows/OS/Setup.ps1 | 9 +++++++-- winiso/deploy.fish | 19 ++++++++++++------- 3 files changed, 20 insertions(+), 11 deletions(-) diff --git a/profiles/DerGeret/Windows/Restore.ps1 b/profiles/DerGeret/Windows/Restore.ps1 index 0bae5218..7e707e4e 100644 --- a/profiles/DerGeret/Windows/Restore.ps1 +++ b/profiles/DerGeret/Windows/Restore.ps1 @@ -26,5 +26,4 @@ function Restore-Apps { Write-Host "Starting Restoration of Windows"; [Context]$context = [Context]::new(); -Invoke-WindowsInstallation $context; -Restart-Computer -Force; +Start-WindowsInstallation; diff --git a/scripts/Windows/OS/Setup.ps1 b/scripts/Windows/OS/Setup.ps1 index 71d64cfa..f7dbb2c7 100644 --- a/scripts/Windows/OS/Setup.ps1 +++ b/scripts/Windows/OS/Setup.ps1 @@ -59,8 +59,12 @@ function Start-Setup { )')))" } + function Get-PathInjection($path) { + "(Join-Path `$env:SystemDrive $(Get-Injection $path))" + } + function Get-ScriptPathInjection($path) { - "(Join-Path `$env:SystemDrive $(Get-Injection (Get-RemoteScriptPath $path)))" + Get-PathInjection (Get-RemoteScriptPath $path) } function Get-DiskConfig { @@ -209,9 +213,10 @@ function Start-Setup { $newCommand.SelectSingleNode("./ua:CommandLine", $namespace).InnerText = ` "powershell -Command " + ` + "`$env:PWSH_PATH = $(Get-PathInjection $env:PWSH_PATH);" + ` "`$env:INSTALLER_SCRIPT = $(Get-ScriptPathInjection $env:SETUP_SCRIPT_NAME);" + ` "`$env:CONFIG_MODULE = $(Get-ScriptPathInjection $env:CONFIG_MODULE);" + ` - "Invoke-Expression $(Get-ScriptPathInjection "$PSScriptRoot/InitialBoot.ps1");"; + "& (Join-Path `$env:PWSH_PATH pwsh) `$env:INSTALLER_SCRIPT;"; $orderElement = $newCommand.SelectSingleNode("./ua:Order", $namespace); $orderElement.InnerText = ([int]($orderElement.InnerText) + 1); diff --git a/winiso/deploy.fish b/winiso/deploy.fish index d3791eb2..4fb3bdfa 100755 --- a/winiso/deploy.fish +++ b/winiso/deploy.fish @@ -15,7 +15,9 @@ begin set -l setupLabel "winiso-valhalla" set -l projectPath "PortValhalla" - set -l localProjectPath "sources/\$OEM\$/\$1/$projectPath" + set -l systemDrivePath "sources/\$OEM\$/\$1" + set -l pwshPath "pwsh" + set -l localProjectPath "$systemDrivePath/$projectPath" set -l cacheDir ~/.cache/winiso-valhalla set -l winpe "$cacheDir/winpe.iso" set -l winPath "/media/win" @@ -76,6 +78,7 @@ begin "$file" \ "$dir" \ "$name" \ + "$target" \ "$winPath" mkdir -p (dirname "$file") @@ -102,10 +105,10 @@ begin end end - set -l intel $files[1..4] - set -l marvell $files[5..8] - set -l git $files[9..12] - set -l pwsh $files[13..16] + set -l intel $files[1..5] + set -l marvell $files[6..10] + set -l git $files[11..15] + set -l pwsh $files[16..20] cp -r "$dir/winpefs"/* "$winpeOverlay" @@ -117,7 +120,7 @@ begin set -l path for sw in git pwsh - set -a path $$sw[1][4] + set -a path $$sw[1][5] end printf %s\n \ @@ -125,9 +128,10 @@ begin string join ";" \ "set PATH=%PATH%" \ $path \ - "$git[4]\\bin" + "$git[5]\\bin" ) \ "set SETUP_LABEL=$setupLabel" \ + "set PWSH_PATH=$(echo "$pwshPath" | mkWinPath)" \ "set LOCAL_PROJECT_PATH=$(echo "$localProjectPath" | mkWinPath)" \ "set REMOTE_PROJECT_PATH=$(echo "$projectPath" | mkWinPath)" \ "echo Loading Drivers..." \ @@ -175,6 +179,7 @@ begin chmod u+w "$rootDir" mkdir -p "$projectPath" + cp -r "$pwsh[4]" "$winOverlay/$systemDrivePath/$pwshPath" source "$dir/../scripts/copy-repo.fish" "$projectPath" rm -rf "$projectPath/archiso"