<< lib/operating-system/SLInstallerGenerator.sleela SLeeLa Standard Library Definition. Definition: Defines SLInstallerGenerator — the stage that writes an installer for a built OS, in the idiom of the OS's shape. For a Linux shape it emits a POSIX shell installer (partition + format to the model's rootfs, mount, unpack the ISO's rootfs, install GRUB); for a Windows shape a PowerShell installer (format NTFS, apply the image, install BOOTMGR to the ESP); for a macOS shape a shell installer targeting an APFS container with boot.efi. Each installer also offers a VM path (QEMU) to boot the ISO read-only for verification before touching a real disk — the control-plane-not-duplication stance of the OS lineage's installer. The installer is the per-OS-type counterpart the request calls for: one is generated for each of the three main OS shapes, selected from the model. Family: operating-system. Consumes SLOSModel; produces an SLOSArtifact (KIND_SCRIPT). >> #sleela 2.5 material; class SLInstallerGenerator { < ---- Descriptive metadata (version 1.11 nested-friendly accessors) ---- > << Eleven catalogued attributes with getter/setter pairs, so a GUI, loader, or catalog can read and (where appropriate) override this record. Values are faithful to the subject's real origin where publicly known. >> String metaVersion = "1.0.0"; int metaId = 10899; String metaAuthor = "Kiro Agent"; String metaDate = "2026-10-16"; String metaCopyright = "SLeeLa project"; String metaTrademark = "none"; String metaCorporation = "none"; < metaOrigin: National | | International | Galactic > String metaOrigin = "International"; String metaBirthDate = "2026-10-10"; < metaScienceRating: maturity/robustness on a 1..10 scale > int metaScienceRating = 9; < metaNationalSchedule: a real, citable instrument or "none" > String metaNationalSchedule = "none"; String getMetaVersion() { return metaVersion; } void setMetaVersion(String v) { metaVersion = v; } int getMetaId() { return metaId; } void setMetaId(int v) { metaId = v; } String getAuthor() { return metaAuthor; } void setAuthor(String v) { metaAuthor = v; } String getDate() { return metaDate; } void setDate(String v) { metaDate = v; } String getCopyright() { return metaCopyright; } void setCopyright(String v) { metaCopyright = v; } String getTrademark() { return metaTrademark; } void setTrademark(String v) { metaTrademark = v; } String getCorporation() { return metaCorporation; } void setCorporation(String v) { metaCorporation = v; } String getOrigin() { return metaOrigin; } void setOrigin(String v) { metaOrigin = v; } String getBirthDate() { return metaBirthDate; } void setBirthDate(String v) { metaBirthDate = v; } int getScienceRating() { return metaScienceRating; } void setScienceRating(int v) { metaScienceRating = v; } String getNationalSchedule() { return metaNationalSchedule; } void setNationalSchedule(String v) { metaNationalSchedule = v; } int configured; void configure() { configured = 1; } < Generate the installer that matches the model's shape. > SLOSArtifact generate(SLOSModel m) { SLOSShape shape = m.osShape(); if (shape.isWindows()) { return windowsInstaller(m); } if (shape.isMac()) { return macInstaller(m); } return linuxInstaller(m); } < ---- Linux: POSIX shell installer -------------------------------------- > SLOSArtifact linuxInstaller(SLOSModel m) { String iso = isoFileName(m); String s = "#!/bin/sh\n"; s = s + "# install-linux.sh - generated by SLeeLa lib/os for " + m.identity() + "\n"; s = s + "set -eu\n"; s = s + "ISO=\"" + iso + "\"\n"; s = s + "TARGET=\"${1:-}\"\n\n"; s = s + "if [ -z \"$TARGET\" ]; then\n"; s = s + " echo \"usage: $0 /dev/DISK (or: $0 --vm to boot the ISO in QEMU)\"; exit 2\n"; s = s + "fi\n\n"; s = s + vmBranchPosix(m); s = s + "# --- Real-disk install (destructive; requires confirmation) ---\n"; s = s + "echo \"About to install " + m.name() + " to $TARGET (DATA LOSS). Type YES:\"\n"; s = s + "read ans; [ \"$ans\" = \"YES\" ] || exit 1\n"; s = s + "mkfs." + m.layout().fsFormat() + " \"${TARGET}1\"\n"; s = s + "mount \"${TARGET}1\" /mnt\n"; s = s + "unpack-rootfs \"$ISO\" /mnt\n"; s = s + "grub-install --efi-directory=/mnt/boot/efi --boot-directory=/mnt/boot \"$TARGET\"\n"; s = s + "umount /mnt\n"; s = s + "echo \"" + m.name() + " installed to $TARGET\"\n"; SLOSArtifact a = new SLOSArtifact(); a.configure("installer/install-linux.sh", a.KIND_SCRIPT, s); return a; } < ---- Windows: PowerShell installer ------------------------------------- > SLOSArtifact windowsInstaller(SLOSModel m) { String iso = isoFileName(m); String s = "#requires -RunAsAdministrator\n"; s = s + "# install-windows.ps1 - generated by SLeeLa lib/os for " + m.identity() + "\n"; s = s + "param([string]$Target, [switch]$Vm)\n\n"; s = s + "$Iso = \"" + iso + "\"\n"; s = s + "if ($Vm) {\n"; s = s + " qemu-system-x86_64 -m 4096 -cdrom $Iso -boot d -bios OVMF.fd\n"; s = s + " exit 0\n"; s = s + "}\n"; s = s + "if (-not $Target) { Write-Error 'usage: install-windows.ps1 -Target [-Vm]'; exit 2 }\n\n"; s = s + "Write-Host \"About to install " + m.name() + " to disk $Target (DATA LOSS).\"\n"; s = s + "if ((Read-Host 'Type YES to continue') -ne 'YES') { exit 1 }\n"; s = s + "Clear-Disk -Number $Target -RemoveData -Confirm:$false\n"; s = s + "$sys = New-Partition -DiskNumber $Target -Size 512MB -GptType '{c12a7328-f81f-11d2-ba4b-00a0c93ec93b}'\n"; s = s + "Format-Volume -Partition $sys -FileSystem FAT32 -NewFileSystemLabel 'ESP'\n"; s = s + "$os = New-Partition -DiskNumber $Target -UseMaximumSize\n"; s = s + "Format-Volume -Partition $os -FileSystem " + m.layout().fsFormat() + " -NewFileSystemLabel '" + m.name() + "'\n"; s = s + "Apply-Image -ImagePath $Iso -ApplyPath ($os.DriveLetter + ':\\')\n"; s = s + "bcdboot ($os.DriveLetter + ':\\Windows') /s ($sys.DriveLetter + ':') /f UEFI\n"; s = s + "Write-Host \"" + m.name() + " installed to disk $Target\"\n"; SLOSArtifact a = new SLOSArtifact(); a.configure("installer/install-windows.ps1", a.KIND_SCRIPT, s); return a; } < ---- macOS: APFS shell installer --------------------------------------- > SLOSArtifact macInstaller(SLOSModel m) { String iso = isoFileName(m); String s = "#!/bin/sh\n"; s = s + "# install-macos.sh - generated by SLeeLa lib/os for " + m.identity() + "\n"; s = s + "set -eu\n"; s = s + "ISO=\"" + iso + "\"\n"; s = s + "TARGET=\"${1:-}\"\n\n"; s = s + "if [ -z \"$TARGET\" ]; then\n"; s = s + " echo \"usage: $0 /dev/diskN (or: $0 --vm to boot the ISO in QEMU)\"; exit 2\n"; s = s + "fi\n\n"; s = s + vmBranchPosix(m); s = s + "echo \"About to install " + m.name() + " to $TARGET (DATA LOSS). Type YES:\"\n"; s = s + "read ans; [ \"$ans\" = \"YES\" ] || exit 1\n"; s = s + "diskutil eraseDisk APFS \"" + m.name() + "\" GPT \"$TARGET\"\n"; s = s + "unpack-rootfs \"$ISO\" \"/Volumes/" + m.name() + "\"\n"; s = s + "bless --folder \"/Volumes/" + m.name() + "/System/Library/CoreServices\" --bootefi\n"; s = s + "echo \"" + m.name() + " installed to $TARGET\"\n"; SLOSArtifact a = new SLOSArtifact(); a.configure("installer/install-macos.sh", a.KIND_SCRIPT, s); return a; } < The shared --vm (QEMU) branch for POSIX installers: boot the ISO read-only. > String vmBranchPosix(SLOSModel m) { String arch = m.architectures().primaryArch().arch(); String bin = "qemu-system-x86_64"; if (arch == "arm64") { bin = "qemu-system-aarch64"; } String s = "if [ \"$TARGET\" = \"--vm\" ]; then\n"; s = s + " " + bin + " -m 4096 -cdrom \"$ISO\" -boot d -bios OVMF.fd\n"; s = s + " exit 0\n"; s = s + "fi\n\n"; return s; } String isoFileName(SLOSModel m) { return m.name() + "-" + m.osVersion() + "-" + m.architectures().primaryArch().arch() + ".iso"; } }