Copy pwsh to newly setup windows systems

This commit is contained in:
Manuel Thalmann 2024-07-31 14:47:42 +02:00
parent 3be5bd7535
commit 08a8ef4b96
3 changed files with 20 additions and 11 deletions

View file

@ -26,5 +26,4 @@ function Restore-Apps {
Write-Host "Starting Restoration of Windows"; Write-Host "Starting Restoration of Windows";
[Context]$context = [Context]::new(); [Context]$context = [Context]::new();
Invoke-WindowsInstallation $context; Start-WindowsInstallation;
Restart-Computer -Force;

View file

@ -59,8 +59,12 @@ function Start-Setup {
)')))" )')))"
} }
function Get-PathInjection($path) {
"(Join-Path `$env:SystemDrive $(Get-Injection $path))"
}
function Get-ScriptPathInjection($path) { function Get-ScriptPathInjection($path) {
"(Join-Path `$env:SystemDrive $(Get-Injection (Get-RemoteScriptPath $path)))" Get-PathInjection (Get-RemoteScriptPath $path)
} }
function Get-DiskConfig { function Get-DiskConfig {
@ -209,9 +213,10 @@ function Start-Setup {
$newCommand.SelectSingleNode("./ua:CommandLine", $namespace).InnerText = ` $newCommand.SelectSingleNode("./ua:CommandLine", $namespace).InnerText = `
"powershell -Command " + ` "powershell -Command " + `
"`$env:PWSH_PATH = $(Get-PathInjection $env:PWSH_PATH);" + `
"`$env:INSTALLER_SCRIPT = $(Get-ScriptPathInjection $env:SETUP_SCRIPT_NAME);" + ` "`$env:INSTALLER_SCRIPT = $(Get-ScriptPathInjection $env:SETUP_SCRIPT_NAME);" + `
"`$env:CONFIG_MODULE = $(Get-ScriptPathInjection $env:CONFIG_MODULE);" + ` "`$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 = $newCommand.SelectSingleNode("./ua:Order", $namespace);
$orderElement.InnerText = ([int]($orderElement.InnerText) + 1); $orderElement.InnerText = ([int]($orderElement.InnerText) + 1);

View file

@ -15,7 +15,9 @@ begin
set -l setupLabel "winiso-valhalla" set -l setupLabel "winiso-valhalla"
set -l projectPath "PortValhalla" 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 cacheDir ~/.cache/winiso-valhalla
set -l winpe "$cacheDir/winpe.iso" set -l winpe "$cacheDir/winpe.iso"
set -l winPath "/media/win" set -l winPath "/media/win"
@ -76,6 +78,7 @@ begin
"$file" \ "$file" \
"$dir" \ "$dir" \
"$name" \ "$name" \
"$target" \
"$winPath" "$winPath"
mkdir -p (dirname "$file") mkdir -p (dirname "$file")
@ -102,10 +105,10 @@ begin
end end
end end
set -l intel $files[1..4] set -l intel $files[1..5]
set -l marvell $files[5..8] set -l marvell $files[6..10]
set -l git $files[9..12] set -l git $files[11..15]
set -l pwsh $files[13..16] set -l pwsh $files[16..20]
cp -r "$dir/winpefs"/* "$winpeOverlay" cp -r "$dir/winpefs"/* "$winpeOverlay"
@ -117,7 +120,7 @@ begin
set -l path set -l path
for sw in git pwsh for sw in git pwsh
set -a path $$sw[1][4] set -a path $$sw[1][5]
end end
printf %s\n \ printf %s\n \
@ -125,9 +128,10 @@ begin
string join ";" \ string join ";" \
"set PATH=%PATH%" \ "set PATH=%PATH%" \
$path \ $path \
"$git[4]\\bin" "$git[5]\\bin"
) \ ) \
"set SETUP_LABEL=$setupLabel" \ "set SETUP_LABEL=$setupLabel" \
"set PWSH_PATH=$(echo "$pwshPath" | mkWinPath)" \
"set LOCAL_PROJECT_PATH=$(echo "$localProjectPath" | mkWinPath)" \ "set LOCAL_PROJECT_PATH=$(echo "$localProjectPath" | mkWinPath)" \
"set REMOTE_PROJECT_PATH=$(echo "$projectPath" | mkWinPath)" \ "set REMOTE_PROJECT_PATH=$(echo "$projectPath" | mkWinPath)" \
"echo Loading Drivers..." \ "echo Loading Drivers..." \
@ -175,6 +179,7 @@ begin
chmod u+w "$rootDir" chmod u+w "$rootDir"
mkdir -p "$projectPath" mkdir -p "$projectPath"
cp -r "$pwsh[4]" "$winOverlay/$systemDrivePath/$pwshPath"
source "$dir/../scripts/copy-repo.fish" "$projectPath" source "$dir/../scripts/copy-repo.fish" "$projectPath"
rm -rf "$projectPath/archiso" rm -rf "$projectPath/archiso"