Prepare for the move to Fedora

tools/posix/setup-fedora.sh installs the toolchain and reports what it
cannot: PowerShell has no Fedora package, and bootcheck is the test
suite, so the script says how to get pwsh rather than failing quietly.
It also checks /dev/kvm, since a Ryzen box can run the tests at native
speed.

docs/moving-to-linux.md is the actual procedure: copy the repo, restore
the memory, install, build. The memory travels inside the repo and
`memory-sync.sh import` puts it under the key this machine derives from
its own path -- /home/nexoniarz/Documents/SchOS becomes
-home-nexoniarz-Documents-SchOS, where D:\DEV\SchOS was D--DEV-SchOS.

OVMF discovery no longer assumes QEMU's Windows layout. Fedora ships
edk2-ovmf to /usr/share/edk2/ovmf/, Debian and Arch differ again, so the
Makefile searches a list and names the packages when it finds nothing.
Tested through the shell rather than $(wildcard): on Windows make is a
native binary using Win32 file calls, while `command -v` returns an MSYS
path like /c/Users/..., which $(wildcard) cannot see -- it returned
nothing on a machine that had the firmware.

Two things only that machine can test: `make ports` builds musl, toybox
and mksh from source, which Windows cannot do at all; and the SchFS
round-trip needs symlinks and hard links, so it has never actually run.
This commit is contained in:
Nexoniarz 2026-08-09 17:25:07 +02:00
commit 4ac7e19397
5 changed files with 249 additions and 4 deletions

View file

@ -383,16 +383,35 @@ esp: $(BUILD)/esp/EFI/BOOT/BOOTX64.EFI
# simply not be there.
OVMF_CODE = $(BUILD)/OVMF_CODE.fd
OVMF_VARS = $(BUILD)/OVMF_VARS.fd
QEMU_SHARE = $(dir $(shell command -v $(QEMU)))share
# OVMF, wherever this host keeps it.
#
# There is no common location: QEMU's own Windows build puts it beside the
# binary as edk2-x86_64-code.fd, Fedora ships edk2-ovmf into
# /usr/share/edk2/ovmf/OVMF_CODE.fd, Debian and Arch each differ again. Search
# rather than assume, and say something useful when nothing is found -- an
# unhelpful "cp: no such file" is a poor way to learn that a package is
# missing.
QEMU_SHARE = $(dir $(shell command -v $(QEMU) 2>/dev/null))share
OVMF_CODE_CANDIDATES = $(QEMU_SHARE)/edk2-x86_64-code.fd /usr/share/edk2/ovmf/OVMF_CODE.fd /usr/share/OVMF/OVMF_CODE.fd /usr/share/ovmf/x64/OVMF_CODE.fd /usr/share/qemu/edk2-x86_64-code.fd
OVMF_VARS_CANDIDATES = $(QEMU_SHARE)/edk2-i386-vars.fd /usr/share/edk2/ovmf/OVMF_VARS.fd /usr/share/OVMF/OVMF_VARS.fd /usr/share/ovmf/x64/OVMF_VARS.fd /usr/share/qemu/edk2-i386-vars.fd
# Tested through the shell rather than with $(wildcard). On Windows, make is a
# native binary using Win32 file calls while `command -v` hands back an MSYS
# path like /c/Users/..., which $(wildcard) cannot see -- it silently returns
# nothing and the firmware looks missing on a machine that has it.
OVMF_CODE_SRC = $(shell for f in $(OVMF_CODE_CANDIDATES); do [ -f "$$f" ] && { echo "$$f"; break; }; done)
OVMF_VARS_SRC = $(shell for f in $(OVMF_VARS_CANDIDATES); do [ -f "$$f" ] && { echo "$$f"; break; }; done)
$(OVMF_CODE):
@mkdir -p $(BUILD)
cp "$(QEMU_SHARE)/edk2-x86_64-code.fd" $@
@test -n "$(OVMF_CODE_SRC)" || { echo "no OVMF firmware found. Install it:"; echo " Fedora sudo dnf install edk2-ovmf"; echo " Debian sudo apt install ovmf"; echo " Arch sudo pacman -S edk2-ovmf"; exit 1; }
cp "$(OVMF_CODE_SRC)" $@
chmod u+w $@
$(OVMF_VARS):
@mkdir -p $(BUILD)
cp "$(QEMU_SHARE)/edk2-i386-vars.fd" $@
@test -n "$(OVMF_VARS_SRC)" || { echo "no OVMF varstore found -- install the OVMF package (see above)"; exit 1; }
cp "$(OVMF_VARS_SRC)" $@
chmod u+w $@
qemu-uefi: esp $(BUILD)/schfs.img $(OVMF_CODE) $(OVMF_VARS)