# 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 edits live in two durable locations, depending on the component (see "NO OVERLAY-STYLE PATCHES" below for the full policy): - **In-tree Red Bear components** — direct edits in `local/sources//` (kernel, relibc, base, installer, bootloader, redox-drm). - **Big external projects** — external patches in `local/patches//*.patch` applied on top of upstream git/tar source (mesa, libdrm, wayland, qt, KF6, KWin, SDDM, llvm, libepoxy, pipewire, wireplumber). Durable Red Bear state belongs in `local/sources/`, `local/recipes/`, `local/patches/`, `local/docs/`, and tracked Red Bear configs. The current development branch is **`0.2.3`**, and the current Red Bear OS version is **0.2.3** — same as the branch name. The 0.1.0 baseline (Redox snapshot at build-system commit `f55acba68`) is preserved as the historical frozen archive at `sources/redbear-0.1.0/`; the release branches `0.2.0`, `0.2.1`, `0.2.2` carry intermediate work and are also frozen. Active development is on `0.2.3`. ## 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/` (in-tree Red Bear forks) or `local/patches//*.patch` (big external projects) or `local/recipes/`. No depending on upstream crates that we cannot fix ourselves. | | **No waiting for upstream** | If a dependency breaks, we fix it in our fork (in-tree) or via external patch (big externals). 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: (a) forked to `local/sources//` (in-tree Red Bear code), (b) tracked via `local/patches//` (big external projects — the established pattern for pipewire, wireplumber, and upcoming mesa/libdrm), or (c) pinned to a frozen archive (unmodified upstream). 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//` (in-tree Red Bear forks) or `local/patches//*.patch` (big external projects). 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) **Two-rule model**: in-tree Red Bear components get direct edits; big external projects get **external patches in `local/patches//*.patch`** applied on top of the upstream git source. We DO NOT maintain a Red Bear source fork of big external projects — that would diverge from upstream and accumulate upstream history as "Red Bear commits". The patches model keeps us close to upstream and gives a clean audit trail (one mbox-style patch per Red Bear change). The migration of mesa, libdrm, pipewire, and wireplumber to the patches model happened in June 2026 (v6.0). The previous "fork model" was found to be a liability: it diverged from upstream and made every upstream sync a Red Bear rebase exercise. --- #### 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/