build: the apk root is the only root
make qemu and make iso went on building sysroot/ as the root while only make aroot built the apk one. Both now come from the apk root: a 1 GB schfs.img for make qemu, and a 96 MB ramdisk for the ISO, 35 MB of it the base system and the rest room for apk add on the live system. sysroot/ is what schos-base is packaged from, not a root of its own. hwdata leaves the ramdisk exclude list: it is Alpine's package now, and a root missing files apk's database lists is one apk has to repair. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01S1giNvrHTrPMPw7V6x1kQ4
This commit is contained in:
parent
0f7bceeb50
commit
3f8e5190aa
2 changed files with 41 additions and 40 deletions
69
Makefile
69
Makefile
|
|
@ -461,14 +461,12 @@ CFLAGS_SYS = $(CFLAGS) -I./kernel/sys
|
|||
# loads that by PIO one sector at a time -- a kernel with a userland inside it
|
||||
# takes visibly longer to boot than a 350 KB one.
|
||||
#
|
||||
# 8000 blocks of 4 KB is 32 MB. It was 6000, which the userland had quietly
|
||||
# grown to fill: 5157 of 6000 used, 86%, after toybox gained its pending
|
||||
# applets and an editor arrived. That still fit, and the *next* thing added
|
||||
# would not have -- and what mkschfs says when an image is full is "try a
|
||||
# larger --size", which is a poor way to find out that a build variant you were
|
||||
# not using has been broken for a while.
|
||||
# 24576 blocks of 4 KB is 96 MB: the apk root's base system is 35 MB, and the rest is
|
||||
# room for `apk add` on the live system. The ramdisk is part of the kernel file
|
||||
# and so of the ISO, empty space included; a system that installs a desktop
|
||||
# wants a disk.
|
||||
# -----------------------------------------------------------------------
|
||||
RAMDISK_BLOCKS ?= 8000
|
||||
RAMDISK_BLOCKS ?= 24576
|
||||
|
||||
# RAMDISK_NINODES used to live here, sizing mkfs's preallocated inode table.
|
||||
# The ramdisk is a SchFS image now (see $(BUILD)/fs-ram.img) and SchFS allocates
|
||||
|
|
@ -486,10 +484,10 @@ RAMDISK_BLOCKS ?= 8000
|
|||
# This is not hypothetical: a 33 MB test payload once landed here and overflowed
|
||||
# the 6 MB image, and mkfs's "increase FSSIZE" message then pointed at a constant
|
||||
# that had nothing to do with it.
|
||||
# usb.ids and pci.ids are 2 MB of a 6 MB image and nothing needs them to boot.
|
||||
# They are lookup tables for userspace tools, so they stay on the disk image
|
||||
# and out of the kernel binary.
|
||||
RAMDISK_EXCLUDE = usr/share/hwdata
|
||||
# usb.ids and pci.ids used to be on it, as 2 MB of a 6 MB image. They are
|
||||
# Alpine's hwdata packages now: apk owns them, and a root missing files its
|
||||
# database lists would be one apk had to repair.
|
||||
RAMDISK_EXCLUDE =
|
||||
RAMDISK_EXCLUDE_ARGS = $(foreach p,$(RAMDISK_EXCLUDE),--exclude $(p))
|
||||
|
||||
ifdef RAMROOT
|
||||
|
|
@ -519,6 +517,17 @@ $(shell mkdir -p $(BUILD); \
|
|||
printf '%s' '$(RAMROOT_STATE)' > $(RAMROOT_STAMP); \
|
||||
fi)
|
||||
|
||||
# -----------------------------------------------------------------------
|
||||
# The root filesystem is an Alpine root that apk manages, with SchOS installed
|
||||
# into it as the package schos-base -- see docs/plan/alpine.md and "The
|
||||
# apk-managed root" below. Both images are made from it: schfs.img, which
|
||||
# `make qemu` boots, and the ramdisk inside the kernel, which `make iso`
|
||||
# boots. sysroot/ is what schos-base is packaged from, not a root of its own.
|
||||
# -----------------------------------------------------------------------
|
||||
AROOT_DIR = $(BUILD)/aroot
|
||||
ROOT_TREE = $(AROOT_DIR)/root
|
||||
ROOT_STAMP = $(AROOT_DIR)/stamp
|
||||
|
||||
# -----------------------------------------------------------------------
|
||||
# Top-level targets
|
||||
# -----------------------------------------------------------------------
|
||||
|
|
@ -758,8 +767,8 @@ iso:
|
|||
|
||||
# One El Torito entry, pointing at a FAT image holding the loader and kernel.
|
||||
# sysroot-install because the disc also carries the tree as a real hierarchy.
|
||||
schos.iso: $(BUILD)/kernel/kernel $(BUILD)/uefi/BOOTX64.EFI tools/posix/mkiso.sh sysroot-install
|
||||
SYSROOT=$(SYSROOT) sh tools/posix/mkiso.sh $@
|
||||
schos.iso: $(BUILD)/kernel/kernel $(BUILD)/uefi/BOOTX64.EFI tools/posix/mkiso.sh sysroot-install $(ROOT_STAMP)
|
||||
SYSROOT=$(ROOT_TREE) sh tools/posix/mkiso.sh $@
|
||||
|
||||
# A partitioned disk -- GPT, an ESP and a SchFS partition -- which is what a
|
||||
# real machine boots from: dd it to a USB stick or a disk. See
|
||||
|
|
@ -825,11 +834,11 @@ $(BUILD)/kernel/kernel: $(BUILD)/kernel/kernel.pass1 $(BUILD)/kernel/ksym.o
|
|||
# volume on the root device" and made `make iso` and `make ramroot` unbootable.
|
||||
# RAMDISK_NINODES is gone with it: SchFS has no preallocated inode table, which
|
||||
# is what that knob existed to size.
|
||||
$(BUILD)/fs-ram.img: $(MKSCHFS) $(BUILD)/sysroot.stamp
|
||||
$(BUILD)/fs-ram.img: $(MKSCHFS) $(ROOT_STAMP)
|
||||
@mkdir -p $(BUILD)
|
||||
@rm -f $@
|
||||
$(MKSCHFS) $@ --size $(RAMDISK_BLOCKS) --label schos \
|
||||
$(RAMDISK_EXCLUDE_ARGS) --sysroot $(SYSROOT)
|
||||
$(RAMDISK_EXCLUDE_ARGS) --sysroot $(ROOT_TREE)
|
||||
|
||||
$(BUILD)/kernel/ramdisk_obj: $(BUILD)/fs-ram.img
|
||||
@mkdir -p $(BUILD)/kernel
|
||||
|
|
@ -1548,12 +1557,15 @@ qemu-console: esp $(BUILD)/schfs.img $(OVMF_CODE) $(OVMF_VARS)
|
|||
# is "try a larger --size", which is a worse thing to read than a number here
|
||||
# is to change. A raw disk image is sparse on any filesystem worth the name,
|
||||
# so the unused part costs nothing until it is used.
|
||||
SCHFS_BLOCKS ?= 25600
|
||||
#
|
||||
# 262144 blocks, 1 GB, since the root became one apk installs into: Xorg alone
|
||||
# is 270 MB. Sparse, so the empty part costs nothing on the host.
|
||||
SCHFS_BLOCKS ?= 262144
|
||||
|
||||
$(BUILD)/schfs.img: $(MKSCHFS) $(BUILD)/sysroot.stamp
|
||||
$(BUILD)/schfs.img: $(MKSCHFS) $(ROOT_STAMP)
|
||||
@mkdir -p $(BUILD)
|
||||
@rm -f $@
|
||||
./$(MKSCHFS) $@ --size $(SCHFS_BLOCKS) --label schos --sysroot $(SYSROOT)
|
||||
./$(MKSCHFS) $@ --size $(SCHFS_BLOCKS) --label schos --sysroot $(ROOT_TREE)
|
||||
|
||||
# --- The apk-managed root ------------------------------------------------------
|
||||
#
|
||||
|
|
@ -1561,14 +1573,11 @@ $(BUILD)/schfs.img: $(MKSCHFS) $(BUILD)/sysroot.stamp
|
|||
# apk package schos-base -- a root that `apk add` and `apk upgrade` manage.
|
||||
# See tools/posix/mkaroot.sh for what goes where and why.
|
||||
#
|
||||
# make aroot build/aroot.img, a SchFS root volume of AROOT_BLOCKS
|
||||
# make qemu-aroot boot it as the root disk (the disk-root kernel)
|
||||
# make aroot the tree and build/schfs.img; `make qemu` boots it
|
||||
# make alpine-lock re-resolve ports/alpine/world against Alpine's mirror;
|
||||
# the one step that looks for newer packages
|
||||
#
|
||||
# The build itself is offline once dist/ has the files world.lock names.
|
||||
AROOT_BLOCKS ?= 262144
|
||||
AROOT_DIR = $(BUILD)/aroot
|
||||
AROOT_KEYS = $(BUILD)/apk-keys
|
||||
APK_STATIC = $(BUILD)/ports/alpine/apk.static
|
||||
ALPINE_MINI = dist/alpine-minirootfs-3.24.3-x86_64.tar.gz
|
||||
|
|
@ -1585,21 +1594,9 @@ $(AROOT_DIR)/stamp: $(BUILD)/sysroot.stamp ports/alpine/world.lock tools/posix/m
|
|||
$(AROOT_KEYS) $(SCHOS_PKGVER) ports/alpine/world.lock dist/alpine
|
||||
touch $@
|
||||
|
||||
$(BUILD)/aroot.img: $(MKSCHFS) $(AROOT_DIR)/stamp
|
||||
@rm -f $@
|
||||
./$(MKSCHFS) $@ --size $(AROOT_BLOCKS) --label schos --sysroot $(AROOT_DIR)/root
|
||||
aroot: $(BUILD)/schfs.img
|
||||
|
||||
aroot: $(BUILD)/aroot.img
|
||||
|
||||
qemu-aroot: esp $(BUILD)/aroot.img $(OVMF_CODE) $(OVMF_VARS)
|
||||
$(QEMU) -machine pc-i440fx-9.2 \
|
||||
-drive if=pflash,format=raw,unit=0,readonly=on,file=$(OVMF_CODE) \
|
||||
-drive if=pflash,format=raw,unit=1,file=$(OVMF_VARS) \
|
||||
-drive file=fat:rw:$(BUILD)/esp,index=0,media=disk,format=raw \
|
||||
-drive file=$(BUILD)/aroot.img,format=raw,index=1,media=disk \
|
||||
-m 2G -smp 2 $(QEMU_ACCEL) -serial mon:stdio $(QEMU_DISPLAY) $(QEMU_INPUT) $(QEMU_NET) $(QEMU_AUDIO)
|
||||
|
||||
.PHONY: alpine-port alpine-lock aroot qemu-aroot
|
||||
.PHONY: alpine-port alpine-lock aroot
|
||||
|
||||
# Boot with a SchFS volume attached as the second disk.
|
||||
#
|
||||
|
|
|
|||
|
|
@ -38,10 +38,12 @@ only what is its own (see `tools/posix/mkaroot.sh`):
|
|||
|
||||
## Building
|
||||
|
||||
make aroot build/aroot.img: the root, as a SchFS volume
|
||||
make qemu-aroot boot it
|
||||
make qemu boots build/schfs.img, the root as a 1 GB SchFS disk
|
||||
make iso the same root as the live system's 96 MB ramdisk
|
||||
make alpine-lock re-resolve world against Alpine (needs the network)
|
||||
|
||||
It is the only root. sysroot/ is what schos-base is packaged from.
|
||||
|
||||
Only `alpine-lock` asks Alpine what is current. A normal build installs
|
||||
exactly what `world.lock` names: files in `dist/alpine/`, fetched once and
|
||||
checked against the lock's sha256, and against Alpine's signatures by apk.
|
||||
|
|
@ -66,8 +68,10 @@ All of it found by running apk:
|
|||
|
||||
## Next
|
||||
|
||||
- The live ISO and USB stick are still the ramdisk root. They need the apk
|
||||
root on the stick itself, or an installer that writes it to a disk.
|
||||
- The live ISO runs the apk root from RAM: `apk add` works, into 59 MB, and
|
||||
is gone at reboot. Keeping packages needs an installer that writes the root
|
||||
to a SATA or NVMe disk, and a kernel that finds its root there by the
|
||||
SchFS GPT type rather than as IDE disk 1.
|
||||
- Xorg from apk (`xorg-server xf86-video-fbdev xf86-input-evdev`) instead of
|
||||
the hand port in [xorg.md](xorg.md). The packages install; running them is
|
||||
the next test.
|
||||
|
|
|
|||
Loading…
Reference in a new issue