2022-04-29 08:33:51 +01:00
|
|
|
|
# make sure we are in the correct directory
|
|
|
|
|
$currentDir=Get-Location
|
|
|
|
|
if ("$currentDir" -ne "$PSScriptRoot")
|
2022-03-11 08:22:01 +00:00
|
|
|
|
{
|
2022-04-29 08:33:51 +01:00
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
pushd "$PSScriptRoot"
|
2022-05-02 10:10:49 +01:00
|
|
|
|
. $PSCommandPath $args
|
2022-04-29 08:33:51 +01:00
|
|
|
|
}
|
|
|
|
|
finally
|
|
|
|
|
{
|
|
|
|
|
popd
|
|
|
|
|
}
|
|
|
|
|
exit
|
2022-03-11 08:22:01 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!([Security.Principal.WindowsPrincipal][Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole]::Administrator))
|
|
|
|
|
{
|
|
|
|
|
Write-Output "This script must be run as Adminstrator. Press ENTER to exit."; Read-Host; exit
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!(Get-Command qemu-system-x86_64.exe -errorAction SilentlyContinue))
|
|
|
|
|
{
|
|
|
|
|
$env:Path += ";C:\Program Files\qemu;"
|
|
|
|
|
if (!(Get-Command qemu-system-x86_64.exe -errorAction SilentlyContinue))
|
|
|
|
|
{
|
|
|
|
|
Write-Output "QEMU is not installed, or not set in \$PATH. Press ENTER to exit."; Read-Host; exit
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
Write-Output "QEMU installation found."
|
|
|
|
|
|
|
|
|
|
$hyperv = Get-WindowsOptionalFeature -FeatureName Microsoft-Hyper-V-All -Online
|
|
|
|
|
if (!($hyperv.State -eq "Enabled"))
|
|
|
|
|
{
|
|
|
|
|
Write-Host "Hyper-V is disabled. Enable Hyper-V and reboot before running this script. Press ENTER to exit."; Read-Host; exit
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$TMPDISK = "$env:TEMP\ZealOS.vhdx"
|
|
|
|
|
|
|
|
|
|
function Mount-TempDisk
|
|
|
|
|
{
|
|
|
|
|
$global:QEMULETTER = ((Mount-DiskImage -ImagePath $TMPDISK -Access ReadWrite) | Get-Disk | Get-Partition).DriveLetter
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function Unmount-TempDisk
|
|
|
|
|
{
|
|
|
|
|
$be_quiet = Dismount-DiskImage -ImagePath $TMPDISK
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Write-Output "Making temp vdisk, running auto-install..."
|
|
|
|
|
|
2022-10-31 08:30:57 +00:00
|
|
|
|
qemu-img create -f vhdx $TMPDISK 1024M
|
2022-03-11 08:22:01 +00:00
|
|
|
|
fsutil sparse setflag $TMPDISK 0
|
|
|
|
|
fsutil sparse queryflag $TMPDISK
|
|
|
|
|
qemu-system-x86_64 -machine q35,accel=whpx,kernel-irqchip=off -drive format=vhdx,file=$TMPDISK -m 2G -rtc base=localtime -cdrom AUTO.ISO -device isa-debug-exit
|
|
|
|
|
|
2022-10-31 08:30:57 +00:00
|
|
|
|
Write-Output "Copying all src/ code into vdisk Tmp/OSBuild/ ..."
|
2022-10-26 22:52:24 +01:00
|
|
|
|
|
|
|
|
|
Remove-Item "..\src\Home\Registry.ZC" -errorAction SilentlyContinue
|
|
|
|
|
Remove-Item "..\src\Home\MakeHome.ZC" -errorAction SilentlyContinue
|
|
|
|
|
Remove-Item "..\src\Boot\Kernel.ZXE" -errorAction SilentlyContinue
|
|
|
|
|
Mount-TempDisk
|
2022-10-31 08:30:57 +00:00
|
|
|
|
New-Item -Path "${QEMULETTER}:\Tmp\" -Name "OSBuild" -ItemType "directory"
|
|
|
|
|
Copy-Item -Path "..\src\*" -Destination "${QEMULETTER}:\Tmp\OSBuild\" -Recurse -Force
|
2022-03-11 08:22:01 +00:00
|
|
|
|
Unmount-TempDisk
|
|
|
|
|
|
2022-10-31 08:30:57 +00:00
|
|
|
|
Write-Output "Rebuilding kernel headers, kernel, OS, and building Distro ISO ..."
|
2022-10-26 22:52:24 +01:00
|
|
|
|
|
2022-03-11 08:22:01 +00:00
|
|
|
|
qemu-system-x86_64 -machine q35,accel=whpx,kernel-irqchip=off -drive format=vhdx,file=$TMPDISK -m 2G -rtc base=localtime -device isa-debug-exit
|
2022-10-26 22:52:24 +01:00
|
|
|
|
|
2022-03-11 08:22:01 +00:00
|
|
|
|
Write-Output "Extracting ISO from vdisk..."
|
2022-10-26 22:52:24 +01:00
|
|
|
|
|
2022-03-11 08:22:01 +00:00
|
|
|
|
Remove-Item "ZealOS-*.iso" -errorAction SilentlyContinue
|
|
|
|
|
Mount-TempDisk
|
2022-10-26 22:52:24 +01:00
|
|
|
|
$ZEALISO = "ZealOS-PublicDomain-BIOS-" + (Get-Date -Format "yyyy-MM-dd-HH_mm_ss").toString() + ".iso"
|
|
|
|
|
Copy-Item "${QEMULETTER}:\Tmp\MyDistro.ISO.C" -Destination $ZEALISO
|
2022-03-11 08:22:01 +00:00
|
|
|
|
Unmount-TempDisk
|
|
|
|
|
|
|
|
|
|
Remove-Item $TMPDISK
|
|
|
|
|
Write-Output "Finished."
|
2022-10-26 22:52:24 +01:00
|
|
|
|
Get-ChildItem "ZealOS*.iso"
|