# RED BEAR OS BUILD SYSTEM — PROJECT KNOWLEDGE BASE **Generated:** 2026-04-12 (P1/P2 complete) · Updated: 2026-06 (source ownership migration) **Toolchain:** Rust nightly (edition 2024) **Architecture:** Microkernel OS in Rust, ~38k files, ~294k LoC Rust **Target Hardware**: AMD64 bare metal, with AMD and Intel machines treated as equal-priority Red Bear OS targets ## OVERVIEW Red Bear OS build system orchestrator — builds and packages ~100+ Git repositories into a bootable Redox image. Uses a Makefile + Rust "cookbook" tool + TOML configs. Languages: Rust (core), C (ported packages), TOML (config), Make (build orchestration). RedBearOS is a **full fork** of Redox OS with direct source ownership. Red Bear maintains its own git forks of every patched component under `local/sources/`. Sources are directly editable — no patches, no indirection. Changes are committed to the appropriate fork repo. Durable Red Bear state belongs in `local/sources/`, `local/recipes/`, `local/docs/`, and tracked Red Bear configs. The current baseline is **Red Bear OS 0.1.0** (Redox snapshot at build-system commit `f55acba68`). ## FULL FORK PRINCIPLE **Red Bear OS is a FULL FORK. We do not depend on Redox. We reuse Redox code only when needed — and when we do, we fork it into our own repos.** This means: | Rule | Explanation | |---|---| | **Own your dependencies** | Every crate and library Red Bear uses must have its source accessible in `local/sources/` or `local/recipes/`. No dependiendo on upstream crates that we cannot fix ourselves. | | **No waiting for upstream** | If a dependency breaks, we fix it in our fork. We do not file issues and wait. | | **Frozen snapshots only** | Upstream Redox is a reference, not a live dependency. We baseline on frozen snapshots and never auto-pull. | | **Upstream gitlab URLs are temporary** | Any recipe pointing at `gitlab.redox-os.org` (91 currently) must eventually be forked to `local/sources/` or pinned to a frozen archive. Exceptions: unmodified upstream packages with pinned revisions. | | **Our code, our fixes** | When crate APIs change (e.g., `libredox 0.1.0` → `0.1.17` broke `call_ro`/`call_wo` signatures), we update OUR fork's code. We don't revert our code to match old APIs — we fix forward. | | **Durable state** | All source modifications are committed to `local/sources//`. No edits in `recipes/*/source/` survive a rebuild. | **Concretely:** - `local/recipes/drivers/redox-driver-sys/` is OUR fork. We fix compilation errors there. - `local/sources/kernel/` is OUR kernel. We don't pull from `gitlab.redox-os.org/redox-oskernel`. - If a Cargo dependency breaks, we fork the dependency crate to `local/sources/` and pin our Cargo.toml to our fork. - The Linux kernel in `local/reference/` is read-only reference — never a dependency. ### NO OVERLAY-STYLE PATCHES — SCOPED POLICY (AMENDED 2026) **Hard policy for in-tree Red Bear components. Explicit allowance for Red Bear forks of big external projects.** The blanket "no patches anywhere" reading from commit `5396e6c3c` was too broad — it would have forced every direct edit to mesa, wayland, qt, KF6, KWin, SDDM, llvm, libdrm, redox-drm, libepoxy, and similar multi-million-line external projects to live inside `recipes//source/`, where a `make clean` or upstream sync would clobber it. That is not a full fork, that is a liability. This section sets the two-rule model Red Bear OS actually follows. --- #### Rule 1 — In-tree Red Bear components: NO overlay, NO local fork of mainline These are Red Bear's own core components. They are small, fast-moving, and tightly coupled to the rest of the system. **Direct edits go into the mainline `recipes//recipe.toml` and `recipes//source/`.** There is **no** Red Bear fork in `local/`, **no** symlink layer, **no** patch file. | Component | Why in-tree, not a fork | |---|---| | `kernel` (`recipes/core/kernel`) | Red Bear's microkernel fork; ACPI, x2APIC, MSI/MSI-X, scheduling, branding — all live in `recipes/core/kernel/source/` directly | | `relibc` (`recipes/core/relibc`) | Red Bear's C library fork; eventfd, signalfd, timerfd, waitid, SysV IPC, credential syscalls — all live in `recipes/core/relibc/source/` directly | | `base` (drivers) (`recipes/core/base`) | Red Bear's userspace drivers fork; acpid, pcid, inputd, ps2d, xhcid migrations — all live in `recipes/core/base/source/` directly | | `installer` (`recipes/core/installer`) | Red Bear's installer fork; ext4 + GRUB support — all lives in `recipes/core/installer/source/` directly | | `bootloader` (`recipes/core/bootloader`) | Red Bear's UEFI bootloader fork; UEFI alloc fix, branding, GPT offset — all lives in `recipes/core/bootloader/source/` directly | For these components, the mainline recipe IS the Red Bear fork. We own it. There is no upstream to sync with — it is our code, full stop. The same rule applies to Red Bear-initiated new packages in `local/recipes///`. | Want to change | Where to do it (DIRECT EDIT) | |---|---| | Change a recipe's build config | Edit `local/recipes///recipe.toml` directly. If the recipe is in upstream `recipes///recipe.toml`, fork it: copy to `local/recipes///recipe.toml` and edit there. | | Change a source file | Edit `local/sources//.rs` directly. | | Add a new package | Create `local/recipes///recipe.toml` directly. | | Change a build script | Edit `local/scripts/