Files
RedBear-OS/recipes/core/base-initfs/recipe.toml
T
vasilito 5f99f19411 base-initfs: drop ion (initfs recovery shell) to move forward with nix
ion pulls nix 0.23.1 (git), which has the Redox SaFlags_t=c_ulong bug
(relibc/libc use c_int) and fails to compile on a clean rebuild with the
`kill`/signal feature. ion was only a bundled initfs recovery shell that
nothing execs (init runs daemons then switchroots to /usr, where the
interactive login shell is brush). Per operator directive, drop ion rather
than hold nix back on an ancient pinned version for its sake.
2026-07-17 09:01:14 +09:00

180 lines
5.9 KiB
TOML

[source]
same_as = "../base"
[package]
version = "0.3.1"
[build]
template = "custom"
dependencies = [
"redoxfs",
"driver-manager",
# userutils provides `getty`, copied into the bare initfs from the
# sysroot below. Without this dependency getty is absent from the
# sysroot at cook time, the copy is silently skipped, and the bare
# ISO has no login (init fails to exec /scheme/initfs/bin/getty).
"userutils",
]
script = """
set -eo pipefail
BINS=(
init
logd
ramfs
randd
zerod
acpid
fbbootlogd
fbcond
hwd
inputd
lived
nvmed
pcid
pcid-spawner
rtcd
vesad
)
virt_bins()
{
BINS+=(virtio-blkd virtio-gpud)
}
x86_common_bins()
{
BINS+=(ahcid ided ps2d usbhidd usbscsid usbhubd xhcid vesad e1000d rtl8168d)
virt_bins
}
aarch64_bins()
{
case "${BOARD}" in
raspi3b*)
BINS+=(bcm2835-sdhcid)
;;
*)
#qemu-virt
virt_bins
;;
esac
}
bare_initfs()
{
# Per user directive, the bare initfs ships the FULL driver set —
# identical to the standard x86 initfs (pcid, pcid-spawner, ahcid, ided,
# nvmed, virtio-*, ps2d, usb*, e1000d, rtl8168d, acpid, hwd, rtcd, lived)
# plus the framebuffer console stack (inputd, vesad, fbcond, fbbootlogd).
# Every driver initialises at boot and redoxfs can find/mount a real disk.
#
# The interactive login is NOT run from the initfs: after the initfs
# brings up the drivers + framebuffer console it switchroots to /usr,
# where the rootfs config (config/minimal.toml, included by redbear-bare)
# provides 00_ptyd.service + 29_activate_console + 30_console.service
# (getty -> login -> zsh) with a real /etc/passwd and shell. So the bare
# initfs matches the mainline initfs exactly — no getty/login/ptyd here.
x86_common_bins
}
case "${TARGET}" in
i586-unknown-redox | i686-unknown-redox)
x86_common_bins
;;
x86_64-unknown-redox)
if [ "${REDBEAR_BARE_INITFS:-0}" = "1" ]; then
bare_initfs
else
x86_common_bins
fi
;;
aarch64-unknown-redox)
aarch64_bins
;;
*)
;;
esac
rm -rf "${COOKBOOK_BUILD}/initfs"
mkdir -p "${COOKBOOK_BUILD}/initfs/lib/init.d"
# The bare initfs now uses the full mainline unit graph (all driver +
# console + rootfs units). The interactive login runs from /usr after
# switchroot (see bare_initfs() above), so no initfs-specific getty/ptyd
# units are injected — bare and non-bare copy the identical unit set.
cp "${COOKBOOK_SOURCE}/init.initfs.d"/* "${COOKBOOK_BUILD}/initfs/lib/init.d/"
mkdir -pv "${COOKBOOK_BUILD}/initfs/lib/drivers.d"
cp -v "${COOKBOOK_SOURCE}/drivers/initfs-storage.toml" "${COOKBOOK_BUILD}/initfs/lib/drivers.d/00-storage.toml"
mkdir -pv "${COOKBOOK_BUILD}/initfs/lib/pcid.d"
cp -v "${COOKBOOK_SOURCE}/drivers/initfs-pcid-storage.toml" "${COOKBOOK_BUILD}/initfs/lib/pcid.d/00-storage.toml"
export CARGO_PROFILE_RELEASE_OPT_LEVEL=s
export CARGO_PROFILE_RELEASE_PANIC=abort
rm -rf "${CARGO_TARGET_DIR}"
"${COOKBOOK_CARGO}" build ${build_flags} \
--manifest-path "${COOKBOOK_SOURCE}/Cargo.toml" \
$(for bin in "${BINS[@]}"; do echo "-p" "${bin}"; done)
mkdir -pv "${COOKBOOK_BUILD}/initfs/bin" "${COOKBOOK_BUILD}/initfs/lib/drivers"
for bin in "${BINS[@]}"
do
case "${bin}" in
init | logd | ramfs | randd | zerod | pcid | pcid-spawner | fbbootlogd | fbcond | inputd | vesad | lived | ps2d | acpid | bcm2835-sdhcid | rtcd | hwd | ptyd | getty)
cp -v "target/${TARGET}/${build_type}/${bin}" "${COOKBOOK_BUILD}/initfs/bin"
;;
*)
cp -v "target/${TARGET}/${build_type}/${bin}" "${COOKBOOK_BUILD}/initfs/lib/drivers"
;;
esac
done
cp "${COOKBOOK_SYSROOT}/usr/bin/redoxfs" "${COOKBOOK_BUILD}/initfs/bin"
# ion removed: it was only a bundled initfs recovery shell (nothing execs it);
# not worth holding nix back on old 0.23.1. The interactive login runs from
# /usr (brush) after switchroot.
cp "${COOKBOOK_SYSROOT}/usr/bin/driver-manager" "${COOKBOOK_BUILD}/initfs/bin"
# NB: getty/login are intentionally NOT copied into the initfs. The
# interactive login runs from /usr after switchroot (config/minimal.toml's
# 30_console.service), where a real /etc/passwd, login and shell exist.
ARCH="$(echo "${GNU_TARGET}" | cut -d - -f1)"
RUSTFLAGS="$RUSTFLAGS -Ctarget-feature=+crt-static -Clink-arg=-nostartfiles -Clink-arg=-nostdlib" cargo \
-Zbuild-std=core,alloc,compiler_builtins \
-Zbuild-std-features=compiler-builtins-mem build \
--target "${TARGET}" \
--manifest-path "${COOKBOOK_SOURCE}/bootstrap/Cargo.toml" \
--release \
--target-dir "${COOKBOOK_BUILD}"
if [ -f "${COOKBOOK_BUILD}/${TARGET}/release/libbootstrap.a" ]; then
"${GNU_TARGET}-ld" \
-o "${COOKBOOK_BUILD}/bootstrap" \
-nostdlib \
--gc-sections \
-T "${COOKBOOK_SOURCE}/bootstrap/src/${ARCH}.ld" \
-z max-page-size=4096 \
"${COOKBOOK_BUILD}/${TARGET}/release/libbootstrap.a"
else
cp -v "${COOKBOOK_BUILD}/${TARGET}/release/bootstrap" "${COOKBOOK_BUILD}/bootstrap"
fi
# Build the loop_mnt discovery helper as a separate target so the
# initfs can fall back to scanning for the live medium at runtime
# (analogous to CachyOS's archiso_loop_mnt hook). Cross-compile
# directly so we don't need a runtime libstd.
CARGO_PROFILE_RELEASE_OPT_LEVEL=s CARGO_PROFILE_RELEASE_PANIC=abort \
"${COOKBOOK_CARGO}" build ${build_flags} \
--manifest-path "${COOKBOOK_SOURCE}/initfs/tools/Cargo.toml" \
--target "${TARGET}" \
--bin loop_mnt
cp -v "target/${TARGET}/${build_type}/loop_mnt" "${COOKBOOK_BUILD}/initfs/bin/loop_mnt"
env -u CARGO -u RUSTFLAGS cargo run --manifest-path "${COOKBOOK_SOURCE}/initfs/tools/Cargo.toml" --bin redox-initfs-ar -- "${COOKBOOK_BUILD}/initfs" "${COOKBOOK_BUILD}/bootstrap" -o "${COOKBOOK_BUILD}/initfs.img"
mkdir -pv "${COOKBOOK_STAGE}/usr/lib/boot"
cp "${COOKBOOK_BUILD}/initfs.img" "${COOKBOOK_STAGE}/usr/lib/boot/initfs"
"""