From 2e4307270bd7b6f7123081c26fe11a4b547ebeb1 Mon Sep 17 00:00:00 2001 From: Andrea Rogers Date: Wed, 13 Nov 2024 10:55:50 -0600 Subject: [PATCH] UEFI: Use EFISTUB more better, qemu test, kernel flavors The Wayland QEMU isn't currently working yet. --- GNUmakefile | 14 ++++++++++++++ mk/raspi.mk | 4 +++- mk/uefi.mk | 43 +++++++++++++++++++++++++++++++++++++------ 3 files changed, 54 insertions(+), 7 deletions(-) diff --git a/GNUmakefile b/GNUmakefile index f972ead..722c3f9 100644 --- a/GNUmakefile +++ b/GNUmakefile @@ -27,6 +27,14 @@ else include mk/simplefs.mk endif +ifneq (,$(WAYLAND_DISPLAY)) + XDG_BASEDIR := $(shell dirname $(XDG_RUNTIME_DIR)) + WAYLAND_ASSIST := env WAYLAND_DISPLAY="$(XDG_RUNTIME_DIR)/$(WAYLAND_DISPLAY)" \ + XDG_BASEDIR="$(XDG_BASEDIR)/0" +else + WAYLAND_ASSIST := +endif + RUNLEVEL_BOOT_CMDS := $(foreach SERVICE,$(RUNLEVEL_BOOT),\ rc-update add $(SERVICE) boot &&) RUNLEVEL_SYSINIT_CMDS := $(foreach SERVICE,$(RUNLEVEL_SYSINIT),\ @@ -176,9 +184,15 @@ $(MOUNTPOINT)/.install-done: fstab services fastest-repo install: $(MOUNTPOINT)/.install-done +bootloader: $(MOUNTPOINT)/.bootloader-done + +### POST-INSTALL TOOLS ### + +# Launch a shell into the installed volume install-chroot: $(MOUNTPOINT)/.install-done $(ACHROOT) $(ACHROOTI_CMD)' && sh' +# Launch a shell into the local bootstrapped root chroot: $(DESTROOT)/.bootstrap-done $(ACHROOT) $(ACHROOT_CMD)' && sh' diff --git a/mk/raspi.mk b/mk/raspi.mk index 24bb778..6d93870 100644 --- a/mk/raspi.mk +++ b/mk/raspi.mk @@ -6,7 +6,9 @@ else endif PLATFORM_PHONYS := partition kernel -PLATFORM_PKGS := linux-rpi +KERNEL_FLAVOR := rpi +KERNEL_PKG := linux-$(KERNEL_FLAVOR) +PLATFORM_PKGS := $(KERNEL_PKG) BOOTFS_PART := 1 ROOTFS_PART := 2 diff --git a/mk/uefi.mk b/mk/uefi.mk index 49a3d9b..99612f6 100644 --- a/mk/uefi.mk +++ b/mk/uefi.mk @@ -1,5 +1,7 @@ PLATFORM_PHONYS := partition kernel -PLATFORM_PKGS := linux-lts +KERNEL_FLAVOR ?= lts +KERNEL_PKG := linux-$(KERNEL_FLAVOR) +PLATFORM_PKGS := $(KERNEL_PKG) BOOTFS_PART := 1 ROOTFS_PART := 2 @@ -7,15 +9,44 @@ ROOTFS_PART := 2 RUNLEVEL_BOOT ?= hwclock modules bootmisc hostname networking seedrng swap RUNLEVEL_DEFAULT ?= acpid crond +ifeq ($(ARCH),x86_64) + OVMF_ARCH := x64 +else ifeq ($(ARCH),x86) + OVMF_ARCH := ia32 +else ifneq (,$(findstring arm,$(ARCH))) + OVMF_ARCH := arm +else + OVMF_ARCH := $(ARCH) +endif + +ifeq ($(ARCH),$(shell uname -m)) + KVMFLAGS := -enable-kvm -cpu host +else + KVMFLAGS := +endif + +QEMU_OVMF ?= /usr/share/ovmf/$(OVMF_ARCH)/OVMF.fd +QEMU_SMP ?= 2 +QEMU_MEM ?= 1G + partition: blkcheck $(DOSU) fdisk $(BLKDEV) <<<$$'g\nw\n' $(DOSU) sfdisk $(BLKDEV) <<<$$',1G,C12A7328-F81F-11D2-BA4B-00A0C93EC93B,*\n,,0FC63DAF-8483-4772-8E79-3D69D8477DE4,\n' -$(MOUNTPOINT)/boot/grub: - $(MAKE) $(ACHROOT) - $(ACHROOTI_CMD)' && grub-install --target=x86_64-efi --efi-directory=/boot' +$(MOUNTPOINT)/boot/startup.nsh: + $(MAKE) blkcheck + @echo 'vmlinuz-$(KERNEL_FLAVOR) rw root=UUID=$(shell lsblk -rno UUID $(BLKDEV)$(P)$(ROOTFS_PART)) initrd=\initramfs-$(KERNEL_FLAVOR)' \ + | $(DOSU) tee $@ -$(MOUNTPOINT)/.bootloader-done: $(MOUNTPOINT)/boot/grub +$(MOUNTPOINT)/.bootloader-done: $(MOUNTPOINT)/boot/startup.nsh touch $@ -bootloader: $(MOUNTPOINT)/.bootloader-done +qemu-test: umount + $(DOSU) $(WAYLAND_ASSIST) qemu-system-$(ARCH) \ + $(KVMFLAGS) \ + -smp $(QEMU_SMP) \ + -m $(QEMU_MEM) \ + -bios $(QEMU_OVMF) \ + -vga std -display gtk \ + -drive driver=raw,file.filename=$(BLKDEV) \ + -net user