mirror of
https://github.com/Zeal-Operating-System/ZealOS.git
synced 2024-12-26 07:20:32 +00:00
Create Windows build scripts.
This commit is contained in:
parent
6c44605a08
commit
b992dcebb2
3 changed files with 177 additions and 2 deletions
|
@ -30,13 +30,14 @@ Features in development include:
|
||||||
### Prerequisites
|
### Prerequisites
|
||||||
|
|
||||||
- For running in a VM: Intel VT-x/AMD-V acceleration enabled in your BIOS settings. (Required to virtualize any 64-bit operating system properly.)
|
- For running in a VM: Intel VT-x/AMD-V acceleration enabled in your BIOS settings. (Required to virtualize any 64-bit operating system properly.)
|
||||||
|
* If using Windows, [Hyper-V must be enabled.](https://docs.microsoft.com/en-us/virtualization/hyper-v-on-windows/quick-start/enable-hyper-v#enable-the-hyper-v-role-through-settings)
|
||||||
- Working knowledge of the C programming language.
|
- Working knowledge of the C programming language.
|
||||||
|
|
||||||
To create a Distro ISO, run `build-iso.sh` in the `build/` directory. Check the Wiki guide for details on [building an ISO](https://github.com/Zeal-Operating-System/ZealOS/wiki/Building-an-ISO). After creating an ISO, see the Wiki guides on installing in [VirtualBox](https://github.com/Zeal-Operating-System/ZealOS/wiki/Installing-(Virtualbox)), [VMWare](https://github.com/Zeal-Operating-System/ZealOS/wiki/Installing-(VMWare)), and [bare-metal](https://github.com/Zeal-Operating-System/ZealOS/wiki/Installing-(Bare%E2%80%90metal)).
|
To create a Distro ISO, run the `build-iso` script in the `build` directory. Check the Wiki guide for details on [building an ISO](https://github.com/Zeal-Operating-System/ZealOS/wiki/Building-an-ISO). After creating an ISO, see the Wiki guides on installing in [VirtualBox](https://github.com/Zeal-Operating-System/ZealOS/wiki/Installing-(Virtualbox)), [VMWare](https://github.com/Zeal-Operating-System/ZealOS/wiki/Installing-(VMWare)), and [bare-metal](https://github.com/Zeal-Operating-System/ZealOS/wiki/Installing-(Bare%E2%80%90metal)).
|
||||||
|
|
||||||
### Contributing
|
### Contributing
|
||||||
|
|
||||||
There are two ways to contribute. The first way involves everything happening inside the OS, as intended by Terry. After you've built the latest ISO, installed to a VM, made your changes, and powered off the VM, you can run the `sync.sh` script to merge your changes to the repo.
|
There are two ways to contribute. The first way involves everything happening inside the OS, as intended by Terry. After you've built the latest ISO, installed to a VM, made your changes, and powered off the VM, you can run the `sync` script to merge your changes to the repo.
|
||||||
|
|
||||||
Alternatively, you can edit repo files using an external editor, outside of the OS.
|
Alternatively, you can edit repo files using an external editor, outside of the OS.
|
||||||
|
|
||||||
|
|
66
build/build-iso.ps1
Executable file
66
build/build-iso.ps1
Executable file
|
@ -0,0 +1,66 @@
|
||||||
|
if (!((Split-Path -Path (Get-Location) -Leaf) -eq "build"))
|
||||||
|
{
|
||||||
|
Write-Output "This script must be run inside the build folder. Press ENTER to exit."; Read-Host; exit
|
||||||
|
}
|
||||||
|
|
||||||
|
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..."
|
||||||
|
|
||||||
|
qemu-img create -f vhdx $TMPDISK 512M
|
||||||
|
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
|
||||||
|
|
||||||
|
Remove-Item "..\src\Home\Registry.ZC" -errorAction SilentlyContinue
|
||||||
|
Remove-Item "..\src\Home\MakeHome.ZC" -errorAction SilentlyContinue
|
||||||
|
Mount-TempDisk
|
||||||
|
|
||||||
|
Copy-Item -Path "..\src\*" -Destination "${QEMULETTER}:\" -Recurse -Force
|
||||||
|
Unmount-TempDisk
|
||||||
|
|
||||||
|
Write-Output "Generating ISO..."
|
||||||
|
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
|
||||||
|
Write-Output "Extracting ISO from vdisk..."
|
||||||
|
Remove-Item "ZealOS-*.iso" -errorAction SilentlyContinue
|
||||||
|
Mount-TempDisk
|
||||||
|
|
||||||
|
$ZEALISO = "ZealOS-" + (Get-Date -Format "yyyy-MM-dd-HH_mm_ss").toString() + ".iso"
|
||||||
|
|
||||||
|
Copy-Item "${QEMULETTER}:\Tmp\MyDistro.ISO.C" -Destination $ZEALISO
|
||||||
|
Unmount-TempDisk
|
||||||
|
|
||||||
|
Remove-Item $TMPDISK
|
||||||
|
Write-Output "Finished."
|
||||||
|
Get-ChildItem "ZealOS*.iso"
|
108
build/sync.ps1
Executable file
108
build/sync.ps1
Executable file
|
@ -0,0 +1,108 @@
|
||||||
|
$choice = $args[0]
|
||||||
|
|
||||||
|
function print_usage()
|
||||||
|
{
|
||||||
|
Write-Output "Usage: sync.ps1 [ repo | vm ]"
|
||||||
|
Write-Output ""
|
||||||
|
Write-Output " repo - overwrites src/ with virtual disk contents."
|
||||||
|
Write-Output " vm - overwrites virtual disk with src/ contents."
|
||||||
|
Write-Output ""
|
||||||
|
exit
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($args.count -eq 0)
|
||||||
|
{
|
||||||
|
print_usage
|
||||||
|
}
|
||||||
|
if ($choice -ne 'repo' -and $choice -ne "vm")
|
||||||
|
{
|
||||||
|
print_usage
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!((Split-Path -Path (Get-Location) -Leaf) -eq "build"))
|
||||||
|
{
|
||||||
|
Write-Output "This script must be run inside the build folder. Press ENTER to exit."; Read-Host; exit
|
||||||
|
}
|
||||||
|
|
||||||
|
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."
|
||||||
|
|
||||||
|
# Set this
|
||||||
|
$ZEALDISK=""
|
||||||
|
# Examples:
|
||||||
|
#$ZEALDISK = "$HOME\VirtualBox VMs\ZEAL\ZEAL.vdi"
|
||||||
|
#$ZEALDISK="$HOME\vmware\ZealOS\ZealOS.vmdk"
|
||||||
|
#$ZEALDISK="ZealOS.qcow2"
|
||||||
|
|
||||||
|
if ($ZEALDISK -eq "")
|
||||||
|
{
|
||||||
|
Write-Output "Please edit this script with the full path to your ZealOS virtual disk. Press ENTER to exit."; Read-Host; exit
|
||||||
|
}
|
||||||
|
if (!(Test-Path -Path $ZEALDISK))
|
||||||
|
{
|
||||||
|
Write-Output "$ZEALDISK is not a path to a file. Press ENTER to exit."; Read-Host; exit
|
||||||
|
}
|
||||||
|
|
||||||
|
$TEMPZEALDISK = "$env:TEMP\TempZealDisk.vhd"
|
||||||
|
qemu-img convert -O vpc $ZEALDISK $TEMPZEALDISK
|
||||||
|
fsutil sparse setflag $TEMPZEALDISK 0
|
||||||
|
fsutil sparse queryflag $TEMPZEALDISK
|
||||||
|
|
||||||
|
function Mount-ZealDisk
|
||||||
|
{
|
||||||
|
$global:ZEALLETTER = ((Mount-DiskImage -ImagePath $TEMPZEALDISK -Access ReadWrite) | Get-Disk | Get-Partition -PartitionNumber 1).DriveLetter
|
||||||
|
}
|
||||||
|
|
||||||
|
function Unmount-ZealDisk
|
||||||
|
{
|
||||||
|
$be_quiet = Dismount-DiskImage -ImagePath $TEMPZEALDISK
|
||||||
|
}
|
||||||
|
|
||||||
|
switch ($choice)
|
||||||
|
{
|
||||||
|
"repo"
|
||||||
|
{
|
||||||
|
Write-Output "Emptying src..."
|
||||||
|
Remove-Item "..\src\*" -Recurse -Force
|
||||||
|
Mount-ZealDisk
|
||||||
|
Write-Output "Copying vdisk root to src..."
|
||||||
|
Copy-Item -Path "${ZEALLETTER}:\*" -Destination "..\src\" -Recurse -Force
|
||||||
|
Remove-Item "..\src\Boot\BootMHD2.BIN"
|
||||||
|
Remove-Item "..\src\Boot\KERNEL.ZXE"
|
||||||
|
Unmount-ZealDisk
|
||||||
|
Remove-Item $TEMPZEALDISK
|
||||||
|
Write-Output "Finished."
|
||||||
|
}
|
||||||
|
|
||||||
|
"vm"
|
||||||
|
{
|
||||||
|
Write-Output ""
|
||||||
|
Write-Output "TODO: Windows sync.ps1 vm"
|
||||||
|
Write-Output "since this is not implemented yet, you can instead use build-iso.ps1"
|
||||||
|
Write-Output "to make a Distro ISO, and use that to install changes over your existing VM."
|
||||||
|
Write-Output ""
|
||||||
|
<#
|
||||||
|
Mount-ZealDisk
|
||||||
|
Write-Output "Copying src to vdisk..."
|
||||||
|
Copy-Item -Path "..\src\*" -Destination "${ZEALLETTER}:\" -Recurse -Force
|
||||||
|
Unmount-ZealDisk
|
||||||
|
switch ([System.IO.Path]::GetExtension($ZEALDISK))
|
||||||
|
{
|
||||||
|
".vdi" {qemu-img convert -O vdi $TEMPZEALDISK $ZEALDISK} # Non-working... re-building a HDD changes file UUID, which confuses Virtualbox...
|
||||||
|
}
|
||||||
|
Write-Output "Finished."
|
||||||
|
#>
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in a new issue