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
|
# 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.
|
# 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
|
# 24576 blocks of 4 KB is 96 MB: the apk root's base system is 35 MB, and the rest is
|
||||||
# grown to fill: 5157 of 6000 used, 86%, after toybox gained its pending
|
# room for `apk add` on the live system. The ramdisk is part of the kernel file
|
||||||
# applets and an editor arrived. That still fit, and the *next* thing added
|
# and so of the ISO, empty space included; a system that installs a desktop
|
||||||
# would not have -- and what mkschfs says when an image is full is "try a
|
# wants a disk.
|
||||||
# larger --size", which is a poor way to find out that a build variant you were
|
|
||||||
# not using has been broken for a while.
|
|
||||||
# -----------------------------------------------------------------------
|
# -----------------------------------------------------------------------
|
||||||
RAMDISK_BLOCKS ?= 8000
|
RAMDISK_BLOCKS ?= 24576
|
||||||
|
|
||||||
# RAMDISK_NINODES used to live here, sizing mkfs's preallocated inode table.
|
# 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
|
# 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
|
# 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
|
# the 6 MB image, and mkfs's "increase FSSIZE" message then pointed at a constant
|
||||||
# that had nothing to do with it.
|
# 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.
|
# usb.ids and pci.ids used to be on it, as 2 MB of a 6 MB image. They are
|
||||||
# They are lookup tables for userspace tools, so they stay on the disk image
|
# Alpine's hwdata packages now: apk owns them, and a root missing files its
|
||||||
# and out of the kernel binary.
|
# database lists would be one apk had to repair.
|
||||||
RAMDISK_EXCLUDE = usr/share/hwdata
|
RAMDISK_EXCLUDE =
|
||||||
RAMDISK_EXCLUDE_ARGS = $(foreach p,$(RAMDISK_EXCLUDE),--exclude $(p))
|
RAMDISK_EXCLUDE_ARGS = $(foreach p,$(RAMDISK_EXCLUDE),--exclude $(p))
|
||||||
|
|
||||||
ifdef RAMROOT
|
ifdef RAMROOT
|
||||||
|
|
@ -519,6 +517,17 @@ $(shell mkdir -p $(BUILD); \
|
||||||
printf '%s' '$(RAMROOT_STATE)' > $(RAMROOT_STAMP); \
|
printf '%s' '$(RAMROOT_STATE)' > $(RAMROOT_STAMP); \
|
||||||
fi)
|
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
|
# Top-level targets
|
||||||
# -----------------------------------------------------------------------
|
# -----------------------------------------------------------------------
|
||||||
|
|
@ -758,8 +767,8 @@ iso:
|
||||||
|
|
||||||
# One El Torito entry, pointing at a FAT image holding the loader and kernel.
|
# 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.
|
# 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
|
schos.iso: $(BUILD)/kernel/kernel $(BUILD)/uefi/BOOTX64.EFI tools/posix/mkiso.sh sysroot-install $(ROOT_STAMP)
|
||||||
SYSROOT=$(SYSROOT) sh tools/posix/mkiso.sh $@
|
SYSROOT=$(ROOT_TREE) sh tools/posix/mkiso.sh $@
|
||||||
|
|
||||||
# A partitioned disk -- GPT, an ESP and a SchFS partition -- which is what a
|
# 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
|
# 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.
|
# 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
|
# RAMDISK_NINODES is gone with it: SchFS has no preallocated inode table, which
|
||||||
# is what that knob existed to size.
|
# 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)
|
@mkdir -p $(BUILD)
|
||||||
@rm -f $@
|
@rm -f $@
|
||||||
$(MKSCHFS) $@ --size $(RAMDISK_BLOCKS) --label schos \
|
$(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
|
$(BUILD)/kernel/ramdisk_obj: $(BUILD)/fs-ram.img
|
||||||
@mkdir -p $(BUILD)/kernel
|
@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 "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,
|
# 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.
|
# 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)
|
@mkdir -p $(BUILD)
|
||||||
@rm -f $@
|
@rm -f $@
|
||||||
./$(MKSCHFS) $@ --size $(SCHFS_BLOCKS) --label schos --sysroot $(SYSROOT)
|
./$(MKSCHFS) $@ --size $(SCHFS_BLOCKS) --label schos --sysroot $(ROOT_TREE)
|
||||||
|
|
||||||
# --- The apk-managed root ------------------------------------------------------
|
# --- 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.
|
# apk package schos-base -- a root that `apk add` and `apk upgrade` manage.
|
||||||
# See tools/posix/mkaroot.sh for what goes where and why.
|
# See tools/posix/mkaroot.sh for what goes where and why.
|
||||||
#
|
#
|
||||||
# make aroot build/aroot.img, a SchFS root volume of AROOT_BLOCKS
|
# make aroot the tree and build/schfs.img; `make qemu` boots it
|
||||||
# make qemu-aroot boot it as the root disk (the disk-root kernel)
|
|
||||||
# make alpine-lock re-resolve ports/alpine/world against Alpine's mirror;
|
# make alpine-lock re-resolve ports/alpine/world against Alpine's mirror;
|
||||||
# the one step that looks for newer packages
|
# the one step that looks for newer packages
|
||||||
#
|
#
|
||||||
# The build itself is offline once dist/ has the files world.lock names.
|
# 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
|
AROOT_KEYS = $(BUILD)/apk-keys
|
||||||
APK_STATIC = $(BUILD)/ports/alpine/apk.static
|
APK_STATIC = $(BUILD)/ports/alpine/apk.static
|
||||||
ALPINE_MINI = dist/alpine-minirootfs-3.24.3-x86_64.tar.gz
|
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
|
$(AROOT_KEYS) $(SCHOS_PKGVER) ports/alpine/world.lock dist/alpine
|
||||||
touch $@
|
touch $@
|
||||||
|
|
||||||
$(BUILD)/aroot.img: $(MKSCHFS) $(AROOT_DIR)/stamp
|
aroot: $(BUILD)/schfs.img
|
||||||
@rm -f $@
|
|
||||||
./$(MKSCHFS) $@ --size $(AROOT_BLOCKS) --label schos --sysroot $(AROOT_DIR)/root
|
|
||||||
|
|
||||||
aroot: $(BUILD)/aroot.img
|
.PHONY: alpine-port alpine-lock aroot
|
||||||
|
|
||||||
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
|
|
||||||
|
|
||||||
# Boot with a SchFS volume attached as the second disk.
|
# 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
|
## Building
|
||||||
|
|
||||||
make aroot build/aroot.img: the root, as a SchFS volume
|
make qemu boots build/schfs.img, the root as a 1 GB SchFS disk
|
||||||
make qemu-aroot boot it
|
make iso the same root as the live system's 96 MB ramdisk
|
||||||
make alpine-lock re-resolve world against Alpine (needs the network)
|
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
|
Only `alpine-lock` asks Alpine what is current. A normal build installs
|
||||||
exactly what `world.lock` names: files in `dist/alpine/`, fetched once and
|
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.
|
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
|
## Next
|
||||||
|
|
||||||
- The live ISO and USB stick are still the ramdisk root. They need the apk
|
- The live ISO runs the apk root from RAM: `apk add` works, into 59 MB, and
|
||||||
root on the stick itself, or an installer that writes it to a disk.
|
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
|
- 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 hand port in [xorg.md](xorg.md). The packages install; running them is
|
||||||
the next test.
|
the next test.
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue