@reallroboto/qbbox 0.0.0-stage → 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (69) hide show
  1. package/bundle/bin/qemu-img +0 -0
  2. package/bundle/bin/qemu-system-aarch64 +4 -0
  3. package/bundle/bin/wimlib-imagex +0 -0
  4. package/bundle/lib/libcharset.1.dylib +0 -0
  5. package/bundle/lib/libfdt.1.dylib +0 -0
  6. package/bundle/lib/libglib-2.0.0.dylib +0 -0
  7. package/bundle/lib/libgmp.10.dylib +0 -0
  8. package/bundle/lib/libhogweed.6.dylib +0 -0
  9. package/bundle/lib/libiconv.2.dylib +0 -0
  10. package/bundle/lib/libintl.8.dylib +0 -0
  11. package/bundle/lib/libnettle.8.dylib +0 -0
  12. package/bundle/lib/libntfs-3g.91.dylib +0 -0
  13. package/bundle/lib/libpcre2-8.0.dylib +0 -0
  14. package/bundle/lib/libpixman-1.0.dylib +0 -0
  15. package/bundle/lib/libresolv.9.dylib +0 -0
  16. package/bundle/lib/libslirp.0.dylib +0 -0
  17. package/bundle/lib/libwim.15.dylib +0 -0
  18. package/bundle/sbom.cdx.json +225 -0
  19. package/bundle/share/qbbox/firmware.fd +4 -0
  20. package/bundle/share/qemu/edk2-arm-vars.fd +4 -0
  21. package/bundle/share/qemu/efi-virtio.rom +0 -0
  22. package/bundle/share/qemu/keymaps/ar +1034 -0
  23. package/bundle/share/qemu/keymaps/bepo +1025 -0
  24. package/bundle/share/qemu/keymaps/cz +1081 -0
  25. package/bundle/share/qemu/keymaps/da +1080 -0
  26. package/bundle/share/qemu/keymaps/de +1078 -0
  27. package/bundle/share/qemu/keymaps/de-ch +1080 -0
  28. package/bundle/share/qemu/keymaps/en-gb +1079 -0
  29. package/bundle/share/qemu/keymaps/en-us +991 -0
  30. package/bundle/share/qemu/keymaps/es +1079 -0
  31. package/bundle/share/qemu/keymaps/et +989 -0
  32. package/bundle/share/qemu/keymaps/fi +1054 -0
  33. package/bundle/share/qemu/keymaps/fo +1081 -0
  34. package/bundle/share/qemu/keymaps/fr +1081 -0
  35. package/bundle/share/qemu/keymaps/fr-be +1080 -0
  36. package/bundle/share/qemu/keymaps/fr-ca +1012 -0
  37. package/bundle/share/qemu/keymaps/fr-ch +1080 -0
  38. package/bundle/share/qemu/keymaps/hr +1081 -0
  39. package/bundle/share/qemu/keymaps/hu +1080 -0
  40. package/bundle/share/qemu/keymaps/is +1081 -0
  41. package/bundle/share/qemu/keymaps/it +1084 -0
  42. package/bundle/share/qemu/keymaps/ja +995 -0
  43. package/bundle/share/qemu/keymaps/lt +1079 -0
  44. package/bundle/share/qemu/keymaps/lv +1054 -0
  45. package/bundle/share/qemu/keymaps/mk +991 -0
  46. package/bundle/share/qemu/keymaps/nl +1081 -0
  47. package/bundle/share/qemu/keymaps/no +1095 -0
  48. package/bundle/share/qemu/keymaps/pl +1085 -0
  49. package/bundle/share/qemu/keymaps/pt +1078 -0
  50. package/bundle/share/qemu/keymaps/pt-br +1078 -0
  51. package/bundle/share/qemu/keymaps/ru +992 -0
  52. package/bundle/share/qemu/keymaps/sl +285 -0
  53. package/bundle/share/qemu/keymaps/sv +255 -0
  54. package/bundle/share/qemu/keymaps/th +991 -0
  55. package/bundle/share/qemu/keymaps/tr +1074 -0
  56. package/firmware/LICENSE +51 -0
  57. package/firmware/QemuRamfb.c +564 -0
  58. package/firmware/QemuRamfbDxe.inf +51 -0
  59. package/firmware/edk2.config +37 -0
  60. package/golden/SetupComplete.cmd +10 -0
  61. package/golden/autounattend.xml +97 -0
  62. package/golden/setup.ps1 +59 -0
  63. package/guest/install-qbd.ps1 +34 -0
  64. package/guest/unpack-sdk.ps1 +14 -0
  65. package/guest/windows-update.ps1 +38 -0
  66. package/package.json +30 -4
  67. package/qbbox +437 -0
  68. package/qemu/0001-ui-60fps-display-refresh.patch +35 -0
  69. package/README.md +0 -3
package/qbbox ADDED
@@ -0,0 +1,437 @@
1
+ #!/bin/bash
2
+ # qbbox: one disposable QBD Box on the operator Mac. QEMU+HVF, Windows 11 Arm, online, Mac + private ranges blocked.
3
+ # qbbox golden build the Golden from the media cache + Windows Update, unattended
4
+ # qbbox up boot the Box; first boot creates its overlay on the Golden
5
+ # qbbox qbd install the QBD trial in the running Box, QBD updater blocked
6
+ # qbbox sdk unpack qbxmlops170.xml from the SDK installer in the running Box, SDK not installed
7
+ # qbbox push-qb copy the qb installed on the Mac (or --from <tarball>) into the running Box
8
+ # qbbox destroy power off the Box and delete its overlay
9
+ # qbbox --version print the qbbox version, the packaged QEMU version, and the firmware SHA-256
10
+ set -euo pipefail
11
+
12
+ # Package dir, also when started through the npm bin symlink.
13
+ repo=$(dirname "$(/bin/realpath "$0")")
14
+ home=$HOME/.qbbox
15
+ media=$home/media
16
+ # Packaged QEMU + qemu-img (scripts/build), its -L data, and the UEFI firmware, all from the same build and QEMU
17
+ # tarball; wimlib-imagex from the same build lock.
18
+ qemu=$repo/bundle/bin/qemu-system-aarch64
19
+ qemu_img=$repo/bundle/bin/qemu-img
20
+ wimlib=$repo/bundle/bin/wimlib-imagex
21
+ share=$repo/bundle/share/qemu
22
+ firmware=$repo/bundle/share/qbbox/firmware.fd
23
+ # Machine type of a Golden without golden.machine: QEMU 11.1.2 `virt` = DEFINE_VIRT_MACHINE_AS_LATEST(11, 1).
24
+ legacy_machine=virt-11.1
25
+ # Display mode, seen over VNC: firmware and Windows (viogpudo) take it from virtio-gpu. Golden runs at 200 %, so
26
+ # 1512×945 logical, as an RDP session on a Retina Mac.
27
+ xres=3024 yres=1890
28
+ key=$home/id_ed25519
29
+ # Only the qbbox key: -F none reads no SSH config, whose IdentityFile (Host *) IdentitiesOnly would still offer.
30
+ ssh_opts=(-F none -i "$key" -o IdentitiesOnly=yes -o BatchMode=yes -o ConnectTimeout=5
31
+ -o "UserKnownHostsFile=$home/known_hosts" -o StrictHostKeyChecking=accept-new)
32
+
33
+ die() { echo "qbbox: $*" >&2; exit 1; }
34
+
35
+ mkdir -p "$media"
36
+ chmod 700 "$home"
37
+
38
+ # sha_ok <sha256> <file>: the file has that SHA-256.
39
+ sha_ok() { echo "$1 $2" | /usr/bin/shasum -a 256 -c --status -; }
40
+
41
+ # need <file> <url> <sha256>: fetch into the media cache if missing, then check the hash.
42
+ need() {
43
+ local file=$media/$1
44
+ if [ ! -e "$file" ]; then
45
+ [ -n "$2" ] || die "missing $file"
46
+ curl -fL --retry 3 -o "$file.part" "$2"
47
+ mv "$file.part" "$file"
48
+ fi
49
+ [ -z "$3" ] || sha_ok "$3" "$file" || die "SHA-256 mismatch: $file; delete it to fetch again"
50
+ }
51
+
52
+ # prereqs: runtime tools neither macOS nor the package ships.
53
+ prereqs() {
54
+ [ "$(uname -sm)" = "Darwin arm64" ] || die "missing macOS arm64"
55
+ node -e 'process.exit(+process.versions.node.split(".")[0] < 26 ? 1 : 0)' 2>/dev/null || die "missing node >= 26"
56
+ command -v npm >/dev/null || die "missing npm"
57
+ # macOS /usr/bin/python3 without Xcode Command Line Tools is a stub that only offers their install: run it.
58
+ python3 -c '' 2>/dev/null || die "missing python3"
59
+ }
60
+
61
+ # box_key: the qbbox Box SSH key, created if missing; its public key in authorized_keys (operator keys optional).
62
+ box_key() {
63
+ local keys=$home/authorized_keys
64
+ [ -e "$key" ] || ssh-keygen -q -t ed25519 -N '' -C qbbox -f "$key"
65
+ [ -e "$key.pub" ] || ssh-keygen -y -f "$key" >"$key.pub"
66
+ touch "$keys"
67
+ chmod 600 "$key" "$key.pub" "$keys"
68
+ # A last line without newline would join the appended key.
69
+ [ ! -s "$keys" ] || [ -z "$(tail -c 1 "$keys")" ] || echo >>"$keys"
70
+ grep -qxF "$(cat "$key.pub")" "$keys" || cat "$key.pub" >>"$keys"
71
+ }
72
+
73
+ # win11_iso: Windows 11 Arm64 ISO, en-US, fetched through the API the Microsoft download page calls, as Rufus'
74
+ # Fido (pbatard/Fido) does; edition and SHA-256 from that page. The hash file beside the ISO: checked on every use.
75
+ win11_iso() {
76
+ local iso=$media/win11arm.iso page=https://www.microsoft.com/en-us/software-download/windows11arm64
77
+ # ISO deleted (mismatch, new release) or hash file not one SHA-256: the hash file goes, the ISO is checked or fetched again.
78
+ if [ ! -e "$iso" ] || ! grep -qxE '[0-9a-f]{64}' "$iso.sha256" 2>/dev/null; then rm -f "$iso.sha256"; fi
79
+ if [ ! -e "$iso.sha256" ]; then
80
+ # Fido's constants: download session check (vlscppe, ov-df) and the page's API profile.
81
+ local api=https://www.microsoft.com/software-download-connector/api profile=606624d44113
82
+ local instance=560dc9f3-1aa5-4a2f-b63c-9e18f8d0e175 sid html edition hash js w rticks sku url
83
+ local blocked="cannot reach vlscppe.microsoft.com (CNAME h-microsoft.online-metrix.net) or ov-df.microsoft.com: offline, or a DNS block list stops them"
84
+ html=$(curl -fsSL "$page") || die "cannot read $page"
85
+ # No match leaves the value empty (pipefail): checked right after.
86
+ edition=$(grep -oE '<option value="[0-9]+">Windows 11 \(multi-edition ISO for Arm64\)' <<<"$html" | grep -oE '[0-9]+' | head -1) || true
87
+ hash=$(grep -oE '<td>English 64-bit</td><td>[A-Fa-f0-9]{64}' <<<"$html" | grep -oE '[A-Fa-f0-9]{64}' | tr '[:upper:]' '[:lower:]') || true
88
+ [ -n "$hash" ] || die "$page changed: no English SHA-256 found"
89
+ if [ -e "$iso" ]; then
90
+ # ISO from before the hash file: kept when it is the release the page publishes.
91
+ sha_ok "$hash" "$iso" ||
92
+ die "$iso is not the release $page publishes: delete it, qbbox then fetches the current one"
93
+ else
94
+ [ -n "$edition" ] || die "$page changed: no Arm64 edition found"
95
+ sid=$(uuidgen | tr '[:upper:]' '[:lower:]')
96
+ curl -fsS -o /dev/null "https://vlscppe.microsoft.com/tags?org_id=y6jn8c31&session_id=$sid" || die "$blocked"
97
+ # mdt.js carries the w and rticks values the ov-df reply must echo back.
98
+ js=$(curl -fsS "https://ov-df.microsoft.com/mdt.js?instanceId=$instance&PageId=si&session_id=$sid") || die "$blocked"
99
+ w=$(grep -oE '[?&]w=[A-F0-9]+' <<<"$js" | head -1 | cut -d= -f2) || true
100
+ rticks=$(grep -oE 'rticks="\+?[0-9]+' <<<"$js" | head -1 | grep -oE '[0-9]+') || true
101
+ [ -n "$w" ] && [ -n "$rticks" ] || die "ov-df.microsoft.com changed its reply: update from Fido"
102
+ curl -fsS -o /dev/null "https://ov-df.microsoft.com/?session_id=$sid&CustomerId=$instance&PageId=si&w=$w&mdt=$(($(date +%s) * 1000))&rticks=$rticks" || die "$blocked"
103
+ sku=$(curl -fsS "$api/getskuinformationbyproductedition?profile=$profile&productEditionId=$edition&SKU=undefined&friendlyFileName=undefined&Locale=en-US&sessionID=$sid" |
104
+ python3 -c 'import json, sys; r = json.load(sys.stdin); i = [s["Id"] for s in r.get("Skus") or [] if s["Language"] == "English"]; print(i[0]) if i else sys.exit("Microsoft: " + json.dumps(r.get("Errors")))') ||
105
+ die "SKU request for edition $edition failed"
106
+ # Microsoft may refuse a download request (error 715-123130): try again later, or from another network.
107
+ url=$(curl -fsS -H "Referer: $page" "$api/GetProductDownloadLinksBySku?profile=$profile&productEditionId=undefined&SKU=$sku&friendlyFileName=undefined&Locale=en-US&sessionID=$sid" |
108
+ python3 -c 'import json, sys; r = json.load(sys.stdin); u = [o["Uri"] for o in r.get("ProductDownloadOptions") or [] if o["DownloadType"] == 2]; print(u[0]) if u else sys.exit("Microsoft: " + json.dumps(r.get("Errors")))') ||
109
+ die "Microsoft refused the ISO link: try again later or from another network, or download it from $page"
110
+ curl -fL --retry 3 -o "$iso.part" "$url" || die "ISO download failed: ${url%%\?*}"
111
+ sha_ok "$hash" "$iso.part" || die "SHA-256 mismatch: $iso.part, not the hash $page publishes"
112
+ mv "$iso.part" "$iso"
113
+ fi
114
+ echo "$hash" >"$iso.sha256"
115
+ fi
116
+ need win11arm.iso "" "$(cat "$iso.sha256")"
117
+ }
118
+
119
+ # bundled: the packaged QEMU, qemu-img, wimlib-imagex, their dylibs, the -L data, and the firmware are present and
120
+ # signed; else stop before QEMU crashes.
121
+ bundled() {
122
+ local f
123
+ for f in "$qemu" "$qemu_img" "$wimlib" "$repo"/bundle/lib/*.dylib "$share/edk2-arm-vars.fd" "$share/efi-virtio.rom" "$firmware"; do
124
+ # Data files under share/ carry no signature.
125
+ if [ ! -f "$f" ] || { [[ $f != "$repo"/bundle/share/* ]] && ! /usr/bin/codesign --verify --strict "$f" 2>/dev/null; }; then
126
+ die "broken package: $f; reinstall @reallroboto/qbbox"
127
+ fi
128
+ done
129
+ # A missing dylib: dyld aborts QEMU. Subshell with exit, not exec: bash reports the abort into /dev/null.
130
+ ("$qemu" --version; exit) >/dev/null 2>&1 || die "broken package: $qemu; reinstall @reallroboto/qbbox"
131
+ }
132
+
133
+ version() {
134
+ bundled
135
+ node -p '"qbbox " + require(process.argv[1]).version' "$repo/package.json"
136
+ # From the binary, not package.json: the QEMU a job runs on.
137
+ "$qemu" --version | sed -n '1s/^QEMU emulator version \([^ ]*\).*/qemu \1/p'
138
+ echo "firmware $(/usr/bin/shasum -a 256 "$firmware" | cut -d" " -f1)"
139
+ }
140
+
141
+ qmp() { printf '{"execute":"qmp_capabilities"}\n%s\n' "$1" | nc -U -w 2 "$home/qmp.sock" | tail -1; }
142
+ running() { [ -e "$home/qemu.pid" ] && kill -0 "$(cat "$home/qemu.pid")" 2>/dev/null; }
143
+ # QEMU deletes its pidfile on exit: callers read the pid first.
144
+ exited() { ! kill -0 "$1" 2>/dev/null; }
145
+ guest() { ssh "${ssh_opts[@]}" -p 2222 qb@127.0.0.1 "$@"; }
146
+ # OOBE runs its own explorer as defaultuser0: setup is done once qb has a desktop.
147
+ qb_desktop() { [[ $(guest '(Get-Process explorer -IncludeUserName -ErrorAction SilentlyContinue).UserName') == *'\qb'* ]]; }
148
+ boot_ticks() { guest '(Get-CimInstance Win32_OperatingSystem).LastBootUpTime.Ticks'; }
149
+ # rebooted <boot ticks>: the guest booted again since <boot ticks>, and qb has its desktop.
150
+ rebooted() { [[ $(boot_ticks) != "$1" ]] && qb_desktop; }
151
+ # windows-update.ps1 renames its result into place: the file exists = round done.
152
+ wu_done() { [[ $(guest 'Test-Path C:\Windows\Temp\qbbox-wu.json') == True* ]]; }
153
+
154
+ # wait_for <seconds> <command...>: retry every 10 s until the command succeeds.
155
+ wait_for() {
156
+ local deadline=$((SECONDS + $1)); shift
157
+ until "$@" >/dev/null 2>&1; do
158
+ [ $SECONDS -lt $deadline ] || die "timed out: $*"
159
+ sleep 10
160
+ done
161
+ }
162
+
163
+ # boot <disk> <machine> [QEMU args]: start <disk>.qcow2 with <disk>.vars.fd on machine type <machine>, in the background.
164
+ boot() {
165
+ local disk=$1 machine=$2; shift 2
166
+ ! running || die "a Box is already running (pid $(cat "$home/qemu.pid"))"
167
+ rm -f "$home/qmp.sock"
168
+ # -L: keymaps (VNC), virtio-net-pci option ROM from the packaged QEMU build.
169
+ # Online: the guest block list (golden/setup.ps1) keeps the guest off the Mac (10.0.2.2) and private ranges.
170
+ # ipv6=off: the block list covers IPv4 only; the slirp IPv6 host alias fec0::2 would need its own rules.
171
+ "$qemu" -L "$share" -nodefaults -name "qbbox-$disk" \
172
+ -machine "$machine",highmem=on,gic-version=3 -accel hvf -cpu host -smp 6,sockets=1,cores=6,threads=1 -m 8192 \
173
+ -drive if=pflash,format=raw,unit=0,readonly=on,file="$firmware" \
174
+ -drive if=pflash,format=raw,unit=1,file="$home/$disk.vars.fd" \
175
+ -device virtio-gpu-pci,xres=$xres,yres=$yres \
176
+ -device qemu-xhci,id=xhci,p2=8,p3=8 -device usb-kbd,bus=xhci.0 -device usb-tablet,bus=xhci.0 \
177
+ -drive if=none,id=disk0,file="$home/$disk.qcow2",format=qcow2,discard=unmap,detect-zeroes=unmap,cache=writeback \
178
+ -device nvme,serial=qbbox,drive=disk0,bootindex=1 \
179
+ -netdev user,id=net0,ipv6=off,hostfwd=tcp:127.0.0.1:2222-:22,hostfwd=tcp:127.0.0.1:3389-:3389 -device virtio-net-pci,netdev=net0 \
180
+ -device virtio-rng-pci -rtc base=utc \
181
+ -display none -vnc 127.0.0.1:0,password=on \
182
+ -qmp unix:"$home/qmp.sock",server=on,wait=off \
183
+ -daemonize -pidfile "$home/qemu.pid" \
184
+ "$@"
185
+ # VNC auth uses the first 8 characters only.
186
+ qmp "{\"execute\":\"change-vnc-password\",\"arguments\":{\"password\":\"$(head -c 8 "$home/password")\"}}" >/dev/null
187
+ }
188
+
189
+ golden() {
190
+ bundled
191
+ # The machine type `virt` stands for in the packaged QEMU: recorded, so a later QEMU boots this Golden on the same
192
+ # hardware (QBD trial hardware ID).
193
+ local machine
194
+ machine=$("$qemu" -machine help | sed -n 's/^virt .*(alias of \(virt-[0-9.]*\))$/\1/p')
195
+ [ -n "$machine" ] || die "broken package: $qemu names no virt machine; reinstall @reallroboto/qbbox"
196
+ [ ! -e "$home/golden.qcow2" ] || die "golden.qcow2 exists; delete it to rebuild"
197
+ [ ! -e "$home/box.qcow2" ] || die "the Box overlay depends on the Golden: run qbbox destroy first"
198
+ box_key
199
+ win11_iso
200
+ # virtio-win publishes no hash: pin from the first download, 2026-10-18.
201
+ need virtio-win-0.1.302.iso https://fedorapeople.org/groups/virt/virtio-win/direct-downloads/archive-virtio/virtio-win-0.1.302-1/virtio-win-0.1.302.iso 303f7ae40dad495d6ae474fdc571df58958a4dbc5c37a522d80f9a203867949d
202
+ need OpenSSH-ARM64-v10.0.0.0.msi https://github.com/PowerShell/Win32-OpenSSH/releases/download/10.0.0.0p2-Preview/OpenSSH-ARM64-v10.0.0.0.msi 7a17d0e22d004fb47ca4bfd8fef926fa305de4ebf70a6f3c7a29c39aabef0023
203
+ need node-v26.13.0-win-arm64.zip https://nodejs.org/dist/v26.13.0/node-v26.13.0-win-arm64.zip a9427139595156ef484e1fb08957676e09d4232368dd1743a2a9f93f3d241b14
204
+ need PowerShell-7.6.7-win-x64.zip https://github.com/PowerShell/PowerShell/releases/download/v7.6.7/PowerShell-7.6.7-win-x64.zip d2f952ebdbf24386cb8923553aa58e41a846db35a6155ea04c58142a4b16dbb7
205
+ # Hex: safe inside sed and XML.
206
+ [ -e "$home/password" ] || (umask 077 && openssl rand -hex 12 >"$home/password")
207
+
208
+ # Staged inside the state dir: it holds the plaintext password.
209
+ local cfg=$home/cfg
210
+ rm -rf "$cfg"
211
+ mkdir -p "$cfg/qbbox" "$cfg/\$WinPEDriver\$"
212
+ sed "s/__PASSWORD__/$(cat "$home/password")/" "$repo/golden/autounattend.xml" >"$cfg/autounattend.xml"
213
+ cp "$repo/golden/SetupComplete.cmd" "$repo/golden/setup.ps1" "$home/authorized_keys" "$cfg/qbbox/"
214
+ cp "$media/OpenSSH-ARM64-v10.0.0.0.msi" "$cfg/qbbox/OpenSSH-ARM64.msi"
215
+ cp "$media/node-v26.13.0-win-arm64.zip" "$cfg/qbbox/node.zip"
216
+ cp "$media/PowerShell-7.6.7-win-x64.zip" "$cfg/qbbox/pwsh.zip"
217
+ # Mounted, not extracted: the ISO stores w11 files as hard links to other folders.
218
+ local virtio driver
219
+ virtio=$(diskutil image attach --nobrowse --readOnly "$media/virtio-win-0.1.302.iso" | tail -1 | cut -f3)
220
+ for driver in NetKVM viorng viogpudo; do
221
+ mkdir "$cfg/\$WinPEDriver\$/$driver"
222
+ cp "$virtio/$driver/w11/ARM64/"* "$cfg/\$WinPEDriver\$/$driver/"
223
+ done
224
+ hdiutil detach -quiet "$virtio"
225
+ rm -f "$home/cfg.iso"
226
+ hdiutil makehybrid -quiet -iso -joliet -default-volume-name QBCFG -joliet-volume-name QBCFG -o "$home/cfg.iso" "$cfg"
227
+ rm -rf "$cfg"
228
+
229
+ # Windows reads a USB CD at ~1 MB/s under QEMU, an NVMe disk at full speed: the ISO's files go on a
230
+ # FAT32 disk, install.wim split under the 4 GB file limit (Setup reads install.swm).
231
+ local img=$home/installer.img dev iso vol
232
+ rm -f "$img"
233
+ mkfile -n 10g "$img"
234
+ dev=$(diskutil image attach --noMount "$img" | cut -f1)
235
+ diskutil quiet eraseDisk FAT32 WININST MBRFormat "$dev"
236
+ vol=$(diskutil info "${dev}s1" | sed -n 's/^ *Mount Point: *//p')
237
+ iso=$(diskutil image attach --nobrowse --readOnly "$media/win11arm.iso" | tail -1 | cut -f3)
238
+ (cd "$iso" && /usr/bin/bsdtar -c -f - --exclude ./sources/install.wim --no-xattrs --no-mac-metadata .) |
239
+ /usr/bin/bsdtar -x -f - -C "$vol" --no-xattrs --no-mac-metadata --no-same-owner --no-same-permissions
240
+ "$wimlib" split "$iso/sources/install.wim" "$vol/sources/install.swm" 3800
241
+ hdiutil detach -quiet "$iso"
242
+ hdiutil detach -quiet "$dev"
243
+ # diskutil writes MBR disk signature 0; WinPE then sees the disk with no partitions.
244
+ printf '\x51\x42\x42\x58' | dd of="$img" bs=1 seek=440 conv=notrunc 2>/dev/null
245
+
246
+ "$qemu_img" create -q -f qcow2 "$home/golden.qcow2" 64G
247
+ cp "$share/edk2-arm-vars.fd" "$home/golden.vars.fd"
248
+ # A new Golden has new SSH host keys.
249
+ rm -f "$home/known_hosts"
250
+ # Empty target first: firmware falls through to the installer; after Setup's reboot, Windows boots.
251
+ boot golden "$machine" \
252
+ -drive if=none,id=installer,format=raw,readonly=on,file="$img" \
253
+ -device nvme,serial=qbinst,drive=installer,bootindex=2 \
254
+ -drive if=none,id=cfg,media=cdrom,readonly=on,file="$home/cfg.iso" \
255
+ -device usb-storage,bus=xhci.0,drive=cfg,removable=on
256
+
257
+ echo "golden: Windows Setup running, unattended; VNC 127.0.0.1:5900 stays dark until the first sign-in"
258
+ wait_for 1800 qb_desktop
259
+ # 200 %: every autologon session then starts at the DPI of an RDP session from a Retina Mac. QBW.EXE is
260
+ # system-DPI-aware: reads the DPI once per session, blurs on a later change. Set after the first sign-in,
261
+ # which resets the default profile's DPI.
262
+ guest "Set-ItemProperty 'HKCU:\\Control Panel\\Desktop' LogPixels 192 -Type DWord; Set-ItemProperty 'HKCU:\\Control Panel\\Desktop' Win8DpiScaling 1 -Type DWord"
263
+
264
+ # Every applicable Windows update, in rounds of task qbbox-wu (SYSTEM); a round that needs it reboots the guest.
265
+ # Only download outside the media cache: Golden build only (owner, 2026-10-21, qbcli#203).
266
+ scp "${ssh_opts[@]}" -P 2222 -q "$repo/guest/windows-update.ps1" qb@127.0.0.1:C:/Windows/Temp/
267
+ guest 'powershell -NoProfile -ExecutionPolicy Bypass -File C:\Windows\Temp\windows-update.ps1 -Register'
268
+ local round wu found code reboot ticks
269
+ for round in {1..10}; do
270
+ guest 'Remove-Item C:\Windows\Temp\qbbox-wu.json -ErrorAction SilentlyContinue; Start-ScheduledTask -TaskName qbbox-wu'
271
+ wait_for 7200 wu_done
272
+ wu=$(guest 'Get-Content C:\Windows\Temp\qbbox-wu.json' |
273
+ python3 -c 'import json, sys; r = json.load(sys.stdin); print(r["found"], r["resultCode"], r["rebootRequired"])')
274
+ read -r found code reboot <<<"$wu"
275
+ echo "golden: Windows Update round $round: $found found, resultCode $code, reboot $reboot"
276
+ # OperationResultCode 2 = Succeeded, 3 = SucceededWithErrors.
277
+ [[ $code == [23] ]] || die "Windows Update round $round failed: resultCode $code; error in guest C:\\Windows\\Temp\\qbbox-wu.json"
278
+ [ "$found" -ne 0 ] || break
279
+ if [ "$reboot" = True ]; then
280
+ ticks=$(boot_ticks)
281
+ guest 'Restart-Computer -Force' || true
282
+ wait_for 1800 rebooted "$ticks"
283
+ fi
284
+ done
285
+ [ "$found" -eq 0 ] || die "Windows Update: no round found 0 updates in 10 rounds"
286
+ # schtasks: Unregister-ScheduledTask asks to confirm.
287
+ guest 'schtasks.exe /Delete /TN qbbox-wu /F' >/dev/null
288
+ guest 'Remove-Item C:\Windows\Temp\windows-update.ps1, C:\Windows\Temp\qbbox-wu.json'
289
+ # Windows Update off in every job: no download or reboot mid-job. Patches come with the monthly Golden rebuild.
290
+ guest 'reg.exe add HKLM\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate\AU /v NoAutoUpdate /t REG_DWORD /d 1 /f' >/dev/null
291
+ guest 'Get-NetFirewallRule -Name qbbox-block-private, qbbox-block-mac-tcp, qbbox-block-mac-udp -ErrorAction Stop' >/dev/null ||
292
+ die "Golden check failed: guest block list missing"
293
+ [[ $(guest '(Get-ItemProperty HKLM:\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate\AU).NoAutoUpdate') == 1* ]] ||
294
+ die "Golden check failed: Windows Update policy missing"
295
+
296
+ local pid
297
+ pid=$(cat "$home/qemu.pid")
298
+ guest 'Stop-Computer -Force' || true
299
+ wait_for 300 exited "$pid"
300
+ rm -f "$img" "$home/cfg.iso"
301
+ chmod 444 "$home/golden.qcow2" "$home/golden.vars.fd"
302
+ # Golden built online with the guest block list + Windows Update policy, both checked above: up needs it.
303
+ touch "$home/golden.online"
304
+ rm -f "$home/golden.machine"
305
+ echo "$machine" >"$home/golden.machine"
306
+ chmod 444 "$home/golden.machine"
307
+ # Written last: up takes it as the mark of a finished Golden.
308
+ (cd "$home" && /usr/bin/shasum -a 256 golden.qcow2 golden.vars.fd >golden.sha256)
309
+ echo "golden: $home/golden.qcow2"
310
+ }
311
+
312
+ up() {
313
+ bundled
314
+ [ -e "$home/golden.sha256" ] || die "no finished Golden: run qbbox golden"
315
+ # A Golden built before the online Box has no guest block list.
316
+ [ -e "$home/golden.online" ] || die "Golden predates the online Box: rebuild it (docs/golden.md#rebuild)"
317
+ local machine=$legacy_machine machines
318
+ [ ! -e "$home/golden.machine" ] || machine=$(cat "$home/golden.machine")
319
+ # Captured first: grep -q would end the pipe early (pipefail).
320
+ machines=$("$qemu" -machine help | awk '{print $1}')
321
+ grep -qxF "$machine" <<<"$machines" || die "Golden needs machine $machine; rebuild Golden"
322
+ if [ ! -e "$home/box.qcow2" ]; then
323
+ "$qemu_img" create -q -f qcow2 -b "$home/golden.qcow2" -F qcow2 "$home/box.qcow2"
324
+ cp "$home/golden.vars.fd" "$home/box.vars.fd"
325
+ chmod 644 "$home/box.vars.fd"
326
+ fi
327
+ boot box "$machine"
328
+ wait_for 600 guest exit
329
+ echo "Box up: ssh ${ssh_opts[*]} -p 2222 qb@127.0.0.1 · RDP 127.0.0.1:3389 · VNC 127.0.0.1:5900"
330
+ }
331
+
332
+ qbd() {
333
+ running || die "no Box running: run qbbox up"
334
+ # Intuit publishes no hash and replaces "Latest": re-pinned 2026-11-22 (Authenticode Intuit, Inc. valid; 34.0.4022.3401).
335
+ need QuickBooksEnterprise24Trial.exe https://dlm2.download.intuit.com/akdlm/SBD/QuickBooks/2024/Latest/QuickBooksEnterprise24Trial.exe fea365d0728557d575fa09f5e8c5e0fa345090472d414f31140b60a69ecb2753
336
+ local qbd=$media/qbd
337
+ if [ ! -d "$qbd" ]; then
338
+ # The trial is a 7-Zip SFX: stub, config, then the 7z archive. bsdtar reads the archive once cut out.
339
+ local offset tmp=$media/qbd.part
340
+ offset=$(python3 -c 'import sys; d = open(sys.argv[1], "rb").read(4 << 20); print(d.index(b"7z\xbc\xaf\x27\x1c", d.index(b";!@InstallEnd@!")))' "$media/QuickBooksEnterprise24Trial.exe")
341
+ rm -rf "$tmp"
342
+ mkdir -p "$tmp/qbd"
343
+ tail -c +$((offset + 1)) "$media/QuickBooksEnterprise24Trial.exe" >"$tmp/qbd.7z"
344
+ /usr/bin/bsdtar -xf "$tmp/qbd.7z" -C "$tmp/qbd" QBooks ThirdParty/CRT9 ThirdParty/CRT12 ThirdParty/CRT14_1
345
+ mv "$tmp/qbd" "$qbd"
346
+ rm -rf "$tmp"
347
+ fi
348
+ # Copied into the parent: a second run overwrites C:/Users/qb/qbd, never nests it.
349
+ scp "${ssh_opts[@]}" -P 2222 -q -r "$qbd" qb@127.0.0.1:C:/Users/qb/
350
+ scp "${ssh_opts[@]}" -P 2222 -q "$repo/guest/install-qbd.ps1" qb@127.0.0.1:C:/Users/qb/qbd/
351
+ guest 'powershell -NoProfile -ExecutionPolicy Bypass -File C:\Users\qb\qbd\install-qbd.ps1'
352
+ }
353
+
354
+ sdk() {
355
+ # Intuit publishes no hash: pin from the first download, 2026-10-18.
356
+ need QBSDK170.exe https://static.developer.intuit.com/resources/QBSDK170.exe c86f31152e048826426ea8c1df0745556b6422f3be113acaa9bf2d46f5860896
357
+ # 64-bit SDK: nothing unpacks it yet; pinned so the cache holds no unchecked download (owner, 2026-10-18).
358
+ need QBSDK170_x64.exe https://static.developer.intuit.com/resources/QBSDK170_x64.exe 3921156d7ceed068b9292fba5a6b817f8631c3687d248588c0c374d8ca5e80f4
359
+ if [ ! -e "$media/qbxmlops170.xml" ]; then
360
+ # macOS cannot open the InstallShield wrapper: Windows unpacks it, the SDK is never installed.
361
+ running || die "no Box running: run qbbox up"
362
+ # Emptied first: a failed run leaves its files here.
363
+ guest 'Remove-Item -Recurse -Force C:\Users\qb\sdk -ErrorAction SilentlyContinue; New-Item -ItemType Directory C:\Users\qb\sdk | Out-Null'
364
+ scp "${ssh_opts[@]}" -P 2222 -q "$media/QBSDK170.exe" "$repo/guest/unpack-sdk.ps1" qb@127.0.0.1:C:/Users/qb/sdk/
365
+ guest 'powershell -NoProfile -ExecutionPolicy Bypass -File C:\Users\qb\sdk\unpack-sdk.ps1'
366
+ scp "${ssh_opts[@]}" -P 2222 -q qb@127.0.0.1:C:/Users/qb/sdk/qbxmlops170.xml "$media/qbxmlops170.xml.part"
367
+ guest 'Remove-Item -Recurse -Force C:\Users\qb\sdk'
368
+ mv "$media/qbxmlops170.xml.part" "$media/qbxmlops170.xml"
369
+ fi
370
+ # Pinned from the first unpack, 2026-10-18.
371
+ need qbxmlops170.xml "" 3cfc19e4ac3f1b9e9793000dd9d9446628be68548249e006411bd4be97fc3e0d
372
+ echo "sdk: $media/qbxmlops170.xml"
373
+ }
374
+
375
+ # push_qb [--from <tarball>]: the npm tarball, else the globally installed @reallroboto/qb → guest C:\Users\qb\qb.
376
+ # Refused unless its package.json version (= its `qb --help` version) starts with the qbbox.qb key of package.json + ".".
377
+ # Staged in qb.new; refused unless guest `qb --help` exits 0.
378
+ push_qb() {
379
+ local from=""
380
+ case ${1-} in
381
+ "") ;;
382
+ --from) [ -n "${2-}" ] || die "--from needs a tarball"; from=$2 ;;
383
+ *) die "push-qb: unknown argument $1" ;;
384
+ esac
385
+ running || die "no Box running: run qbbox up"
386
+ local want src version
387
+ want=$(python3 -c 'import json, sys; print(json.load(open(sys.argv[1]))["qbbox"]["qb"])' "$repo/package.json")
388
+ if [ -n "$from" ]; then
389
+ [ -f "$from" ] || die "no tarball: $from"
390
+ tmp=$(mktemp -d)
391
+ trap 'rm -rf "$tmp"' EXIT
392
+ # npm pack puts every file under package/.
393
+ /usr/bin/tar -xzf "$from" -C "$tmp" || die "not an npm tarball: $from"
394
+ src=$tmp/package
395
+ else
396
+ src="$(npm root -g)/@reallroboto/qb"
397
+ fi
398
+ [ -e "$src/bin/qb.js" ] || die "no qb package: npm install -g @reallroboto/qb, or pass --from <tarball>"
399
+ # npm install -g <folder> links it: copy the files, not the link.
400
+ src=$(/bin/realpath "$src")
401
+ # A missing path fails Remove-Item, even silenced: the exit code comes from Test-Path.
402
+ guest 'Remove-Item -Recurse -Force C:\Users\qb\qb.new -ErrorAction SilentlyContinue; exit [int](Test-Path C:\Users\qb\qb.new)' ||
403
+ die "push-qb: cannot clear C:\\Users\\qb\\qb.new in the Box"
404
+ version=$(python3 -c 'import json, sys; print(json.load(open(sys.argv[1]))["version"])' "$src/package.json") || version=""
405
+ [[ $version == "$want".* ]] || die "push-qb: qb ${version:-with no version} refused, qbbox accepts $want.x; guest qb unchanged"
406
+ # scp -r names the copy after the target, not the source folder.
407
+ scp "${ssh_opts[@]}" -P 2222 -q -r "$src" qb@127.0.0.1:C:/Users/qb/qb.new
408
+ # Smoke check: qb starts on the guest Node; output not parsed (text or JSON help).
409
+ if ! guest 'node C:\Users\qb\qb.new\bin\qb.js --help' >/dev/null; then
410
+ guest 'Remove-Item -Recurse -Force C:\Users\qb\qb.new' || true
411
+ die "push-qb: qb $version refused, its qb --help fails in the Box; guest qb unchanged"
412
+ fi
413
+ # Rename fails while qb still exists: a partly removed qb stops here, qb.new kept.
414
+ guest 'Remove-Item -Recurse -Force C:\Users\qb\qb -ErrorAction SilentlyContinue; Rename-Item C:\Users\qb\qb.new qb' ||
415
+ die "push-qb: cannot replace C:\\Users\\qb\\qb (a qb run holds a file?); C:\\Users\\qb\\qb.new kept, run push-qb again"
416
+ printf 'push-qb: qb %s in the Box; run: node C:\\Users\\qb\\qb\\bin\\qb.js\n' "$version"
417
+ }
418
+
419
+ destroy() {
420
+ if running; then
421
+ local pid
422
+ pid=$(cat "$home/qemu.pid")
423
+ qmp '{"execute":"quit"}' >/dev/null
424
+ wait_for 60 exited "$pid"
425
+ fi
426
+ rm -f "$home/box.qcow2" "$home/box.vars.fd"
427
+ echo "Box destroyed"
428
+ }
429
+
430
+ case ${1-} in
431
+ golden | up | qbd | sdk) prereqs; "$1" ;;
432
+ # No prerequisite: a Box must always stop.
433
+ destroy) destroy ;;
434
+ --version) prereqs; version ;;
435
+ push-qb) prereqs; shift; push_qb "$@" ;;
436
+ *) sed -n '2,9s/^# \{0,1\}//p' "$0" >&2; exit 2 ;;
437
+ esac
@@ -0,0 +1,35 @@
1
+ SiliconWin: refresh the display at 60 fps
2
+
3
+ QEMU refreshes graphical consoles every 30 ms (about 33 fps), and the VNC
4
+ server backs off to one update every 3 s while the screen is idle, which makes
5
+ the pointer feel sluggish after a pause. Refresh every 16 ms instead, and never
6
+ back off beyond 100 ms. SiliconWin talks to the VNC server over a local Unix
7
+ socket, so the extra updates cost very little.
8
+
9
+ License: same as the files it modifies (include/ui/console.h: GPL-2.0-or-later,
10
+ ui/vnc.c: MIT).
11
+
12
+ --- a/include/ui/console.h 2026-10-03 04:51:59
13
+ +++ b/include/ui/console.h 2026-10-03 04:51:59
14
+ @@ -36,7 +36,7 @@
15
+ #define QEMU_CAPS_LOCK_LED (1 << 2)
16
+
17
+ /* in ms */
18
+ -#define GUI_REFRESH_INTERVAL_DEFAULT 30
19
+ +#define GUI_REFRESH_INTERVAL_DEFAULT 16 /* SiliconWin: 60 fps instead of ~33 */
20
+ #define GUI_REFRESH_INTERVAL_IDLE 3000
21
+
22
+ /* Color number is match to standard vga palette */
23
+ --- a/ui/vnc.c 2026-10-03 04:51:59
24
+ +++ b/ui/vnc.c 2026-10-03 04:51:59
25
+ @@ -59,8 +59,8 @@
26
+ #include "monitor/monitor.h"
27
+
28
+ #define VNC_REFRESH_INTERVAL_BASE GUI_REFRESH_INTERVAL_DEFAULT
29
+ -#define VNC_REFRESH_INTERVAL_INC 50
30
+ -#define VNC_REFRESH_INTERVAL_MAX GUI_REFRESH_INTERVAL_IDLE
31
+ +#define VNC_REFRESH_INTERVAL_INC 16 /* SiliconWin: stay responsive when idle */
32
+ +#define VNC_REFRESH_INTERVAL_MAX 100 /* SiliconWin: was GUI_REFRESH_INTERVAL_IDLE (3 s) */
33
+ static const struct timeval VNC_REFRESH_STATS = { 0, 500000 };
34
+ static const struct timeval VNC_REFRESH_LOSSY = { 2, 0 };
35
+
package/README.md DELETED
@@ -1,3 +0,0 @@
1
- # Temporary Holding Version
2
-
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.