Rename rbos → redbear everywhere, add redbear-info system tool

Replace all 'rbos'/'RBOS' references with 'redbear'/'Red Bear OS'
across the build system, scripts, docs, and configs. Renamed files:
  rbos.ipxe → redbear.ipxe
  assets/rbos-icon.png → assets/redbear-icon.png
  recipes/system/rbos-info → recipes/system/redbear-info

Added redbear-info: a system tool that enumerates all Red Bear OS
custom components, checks runtime availability via scheme paths and
binary presence, and prints status/test info. Supports --verbose,
--json, and --test output modes. Zero external dependencies.
This commit is contained in:
2026-04-12 19:46:54 +01:00
parent 50b731f1b7
commit 43fd088349
36 changed files with 686 additions and 101 deletions
+1 -1
View File
@@ -45,7 +45,7 @@ git rebase upstream-redox/master
# If rebase fails (nuclear option):
git rebase --abort
git reset --hard upstream-redox/master
./local/scripts/apply-patches.sh --force # Rebuild RBOS changes from patch files
./local/scripts/apply-patches.sh --force # Rebuild Red Bear OS changes from patch files
# After sync:
cargo build --release # Rebuild cookbook
@@ -7,11 +7,23 @@ script = """
mkdir -p "${COOKBOOK_STAGE}/usr/lib"
mkdir -p "${COOKBOOK_STAGE}/etc"
mkdir -p "${COOKBOOK_STAGE}/usr/share/redbear"
mkdir -p "${COOKBOOK_STAGE}/usr/share/icons/hicolor/128x128/apps"
mkdir -p "${COOKBOOK_STAGE}/usr/share/redbear/images"
# Core branding
cp "${COOKBOOK_SOURCE}/os-release" "${COOKBOOK_STAGE}/usr/lib/os-release"
cp "${COOKBOOK_SOURCE}/hostname" "${COOKBOOK_STAGE}/etc/hostname"
cp "${COOKBOOK_SOURCE}/motd" "${COOKBOOK_STAGE}/etc/motd"
cp "${COOKBOOK_SOURCE}/banner" "${COOKBOOK_STAGE}/usr/share/redbear/banner"
ln -sf ../usr/lib/os-release "${COOKBOOK_STAGE}/etc/os-release"
# Branding images (staged by integrate-redbear.sh from local/Assets/images/)
if [ -f "${COOKBOOK_SOURCE}/images/icon.png" ]; then
cp "${COOKBOOK_SOURCE}/images/icon.png" "${COOKBOOK_STAGE}/usr/share/icons/hicolor/128x128/apps/redbear-os.png"
cp "${COOKBOOK_SOURCE}/images/icon.png" "${COOKBOOK_STAGE}/usr/share/redbear/images/icon.png"
fi
if [ -f "${COOKBOOK_SOURCE}/images/loading-background.png" ]; then
cp "${COOKBOOK_SOURCE}/images/loading-background.png" "${COOKBOOK_STAGE}/usr/share/redbear/images/loading-background.png"
fi
"""
@@ -4,7 +4,21 @@
path = "source"
[build]
template = "cargo"
template = "custom"
script = """
# Build the firmware-loader daemon
COOKBOOK_CARGO_PATH=. cookbook_cargo
# Stage firmware blobs (copied by integrate-redbear.sh from local/firmware/amdgpu/)
if [ -d "${COOKBOOK_SOURCE}/firmware/amdgpu" ]; then
AMD_FW_COUNT=$(ls "${COOKBOOK_SOURCE}/firmware/amdgpu/"*.bin 2>/dev/null | wc -l)
if [ "${AMD_FW_COUNT}" -gt 0 ]; then
mkdir -p "${COOKBOOK_STAGE}/usr/lib/firmware/amdgpu"
cp "${COOKBOOK_SOURCE}/firmware/amdgpu/"*.bin "${COOKBOOK_STAGE}/usr/lib/firmware/amdgpu/"
echo "Staged ${AMD_FW_COUNT} AMD firmware blobs"
fi
fi
"""
[package.files]
"/usr/lib/drivers/firmware-loader" = "firmware-loader"
@@ -0,0 +1,8 @@
[source]
path = "source"
[build]
template = "cargo"
[package.files]
"/usr/bin/redbear-info" = "redbear-info"
@@ -0,0 +1,8 @@
[package]
name = "redbear-info"
version = "0.1.0"
edition = "2024"
[[bin]]
name = "redbear-info"
path = "src/main.rs"
@@ -0,0 +1,535 @@
use std::env;
use std::fs;
use std::path::Path;
use std::process;
const RESET: &str = "\x1b[0m";
const GREEN: &str = "\x1b[32m";
const YELLOW: &str = "\x1b[33m";
const RED: &str = "\x1b[31m";
const DIVIDER: &str = "═══════════════════════════════════════════════════════════════════";
const REDBEAR_META_README: &str = "/usr/share/doc/redbear-meta/README";
struct Component {
name: &'static str,
description: &'static str,
category: &'static str,
scheme_path: &'static str,
binary_path: &'static str,
test_hint: &'static str,
dependencies: &'static [&'static str],
}
#[derive(Clone, Copy, PartialEq, Eq)]
enum OutputMode {
Table,
Json,
Test,
Help,
}
struct Options {
mode: OutputMode,
verbose: bool,
}
#[derive(Clone, Copy, PartialEq, Eq)]
enum AvailabilityState {
Available,
Unavailable,
BuiltIn,
}
struct ComponentStatus<'a> {
component: &'a Component,
state: AvailabilityState,
available: bool,
status_text: &'static str,
scheme_exists: Option<bool>,
binary_exists: Option<bool>,
}
const COMPONENTS: &[Component] = &[
Component {
name: "redbear-release",
description: "OS identity (hostname, os-release, motd, banner)",
category: "Branding",
scheme_path: "",
binary_path: "",
test_hint: "cat /usr/lib/os-release",
dependencies: &[],
},
Component {
name: "ext4d",
description: "ext4 scheme daemon",
category: "Filesystem",
scheme_path: "/scheme/ext4d",
binary_path: "/usr/bin/ext4d",
test_hint: "ls /scheme/ext4d/",
dependencies: &[],
},
Component {
name: "redox-driver-sys",
description: "Safe Rust wrappers for scheme:memory, scheme:irq, scheme:pci",
category: "Driver",
scheme_path: "",
binary_path: "",
test_hint: "pkg list | grep redox-driver-sys",
dependencies: &[],
},
Component {
name: "linux-kpi",
description:
"Linux Kernel Programming Interface compatibility layer (C headers + Rust impl)",
category: "Driver",
scheme_path: "",
binary_path: "",
test_hint: "pkg list | grep linux-kpi",
dependencies: &["redox-driver-sys"],
},
Component {
name: "firmware-loader",
description: "Loads GPU firmware blobs via scheme:firmware",
category: "System",
scheme_path: "/scheme/firmware",
binary_path: "/usr/lib/drivers/firmware-loader",
test_hint: "ls /scheme/firmware/amdgpu/",
dependencies: &[],
},
Component {
name: "redox-drm",
description: "DRM display driver for AMD and Intel GPUs",
category: "GPU",
scheme_path: "/scheme/drm",
binary_path: "/usr/bin/redox-drm",
test_hint: "ls /scheme/drm/card0/",
dependencies: &["redox-driver-sys", "linux-kpi"],
},
Component {
name: "amdgpu",
description: "AMD GPU driver (Display Core modesetting) via LinuxKPI",
category: "GPU",
scheme_path: "",
binary_path: "/usr/lib/redox/drivers/libamdgpu_dc_redox.so",
test_hint: "ls -la /usr/lib/redox/drivers/libamdgpu_dc_redox.so",
dependencies: &["redox-driver-sys", "linux-kpi", "firmware-loader"],
},
Component {
name: "evdevd",
description: "Translates Redox input events to evdev protocol",
category: "Input",
scheme_path: "/scheme/evdev",
binary_path: "/usr/lib/drivers/evdevd",
test_hint: "ls /scheme/evdev/",
dependencies: &[],
},
Component {
name: "udev-shim",
description: "udev-compatible device enumeration shim (PCI scanning)",
category: "System",
scheme_path: "/scheme/udev",
binary_path: "/usr/lib/drivers/udev-shim",
test_hint: "ls /scheme/udev/",
dependencies: &[],
},
Component {
name: "redbear-meta",
description: "Umbrella meta-package depending on all Red Bear OS components",
category: "System",
scheme_path: "",
binary_path: "",
test_hint: "cat /usr/share/doc/redbear-meta/README",
dependencies: &["redbear-release", "firmware-loader", "evdevd", "udev-shim"],
},
];
fn main() {
if let Err(err) = run() {
eprintln!("redbear-info: {err}");
process::exit(1);
}
}
fn run() -> Result<(), String> {
let options = parse_args(env::args())?;
if options.mode == OutputMode::Help {
print_help();
return Ok(());
}
let branding_available = has_red_bear_branding();
let statuses = collect_statuses(branding_available);
match options.mode {
OutputMode::Table => print_table(&statuses, options.verbose),
OutputMode::Json => print_json(&statuses),
OutputMode::Test => print_tests(&statuses, options.verbose),
OutputMode::Help => {}
}
Ok(())
}
fn parse_args<I>(args: I) -> Result<Options, String>
where
I: IntoIterator<Item = String>,
{
let mut mode = OutputMode::Table;
let mut verbose = false;
for arg in args.into_iter().skip(1) {
match arg.as_str() {
"-v" | "--verbose" => verbose = true,
"--json" => {
if mode == OutputMode::Test {
return Err("cannot combine --json with --test".to_string());
}
mode = OutputMode::Json;
}
"--test" => {
if mode == OutputMode::Json {
return Err("cannot combine --test with --json".to_string());
}
mode = OutputMode::Test;
}
"-h" | "--help" => mode = OutputMode::Help,
_ => return Err(format!("unknown argument: {arg}")),
}
}
Ok(Options { mode, verbose })
}
fn has_red_bear_branding() -> bool {
match fs::read_to_string("/usr/lib/os-release") {
Ok(contents) => contents.contains("Red Bear OS"),
Err(_) => false,
}
}
fn collect_statuses(branding_available: bool) -> Vec<ComponentStatus<'static>> {
COMPONENTS
.iter()
.map(|component| inspect_component(component, branding_available))
.collect()
}
fn inspect_component(
component: &'static Component,
branding_available: bool,
) -> ComponentStatus<'static> {
let scheme_exists = if component.scheme_path.is_empty() {
None
} else {
Some(Path::new(component.scheme_path).exists())
};
let binary_exists = if component.binary_path.is_empty() {
None
} else {
Some(Path::new(component.binary_path).exists())
};
let (state, available, status_text) = if component.name == "redbear-release" {
if branding_available {
(AvailabilityState::Available, true, "available")
} else {
(AvailabilityState::Unavailable, false, "not configured")
}
} else if component.name == "redbear-meta" {
if Path::new(REDBEAR_META_README).exists() {
(AvailabilityState::Available, true, "available")
} else {
(AvailabilityState::Unavailable, false, "missing")
}
} else if let Some(exists) = scheme_exists {
if exists {
(AvailabilityState::Available, true, "available")
} else {
(AvailabilityState::Unavailable, false, "not running")
}
} else if let Some(exists) = binary_exists {
if exists {
(AvailabilityState::Available, true, "available")
} else {
(AvailabilityState::Unavailable, false, "missing")
}
} else {
(AvailabilityState::BuiltIn, true, "built-in")
};
ComponentStatus {
component,
state,
available,
status_text,
scheme_exists,
binary_exists,
}
}
fn print_table(statuses: &[ComponentStatus<'_>], verbose: bool) {
let name_width = statuses
.iter()
.map(|status| status.component.name.len())
.max()
.unwrap_or(0);
let category_width = statuses
.iter()
.map(|status| status.component.category.len())
.max()
.unwrap_or(0);
println!("Red Bear OS Component Status");
println!("{DIVIDER}");
println!();
for status in statuses {
println!(
" {} {:name_width$} [{:category_width$}] {}",
colorize(marker_for(status), marker_color(status)),
status.component.name,
status.component.category,
colorize(status.status_text, status_color(status)),
name_width = name_width,
category_width = category_width,
);
println!(" {}", status.component.description);
println!(" Test: {}", status.component.test_hint);
if verbose {
println!(
" Dependencies: {}",
format_dependencies(status.component.dependencies)
);
}
println!();
}
println!("{DIVIDER}");
println!(
"{}/{} components available",
available_count(statuses),
statuses.len()
);
}
fn print_tests(statuses: &[ComponentStatus<'_>], verbose: bool) {
println!("Red Bear OS Runtime Test Hints");
println!("{DIVIDER}");
println!();
let mut printed = 0usize;
for status in statuses.iter().filter(|status| status.available) {
println!(
" {} {:<16} {}",
colorize("", GREEN),
status.component.name,
status.component.test_hint,
);
if verbose {
println!(
" Dependencies: {}",
format_dependencies(status.component.dependencies)
);
}
printed += 1;
}
if printed == 0 {
println!(" No available Red Bear OS components detected.");
}
println!();
println!("{DIVIDER}");
println!("{} test command(s) ready", printed);
}
fn print_json(statuses: &[ComponentStatus<'_>]) {
let mut output = String::new();
output.push_str("{\n");
output.push_str(" \"summary\": {\n");
output.push_str(&format!(
" \"available\": {},\n \"total\": {}\n",
available_count(statuses),
statuses.len()
));
output.push_str(" },\n");
output.push_str(" \"components\": [\n");
for (index, status) in statuses.iter().enumerate() {
output.push_str(" {\n");
push_json_field(&mut output, "name", status.component.name, true);
push_json_field(
&mut output,
"description",
status.component.description,
true,
);
push_json_field(&mut output, "category", status.component.category, true);
push_json_field(
&mut output,
"scheme_path",
status.component.scheme_path,
true,
);
push_json_field(
&mut output,
"binary_path",
status.component.binary_path,
true,
);
push_json_field(&mut output, "test_hint", status.component.test_hint, true);
output.push_str(" \"dependencies\": ");
push_json_array(&mut output, status.component.dependencies);
output.push_str(",\n");
output.push_str(&format!(
" \"available\": {},\n",
bool_to_json(status.available)
));
push_json_field(&mut output, "status", status.status_text, true);
push_json_optional_bool(&mut output, "scheme_exists", status.scheme_exists, true);
push_json_optional_bool(&mut output, "binary_exists", status.binary_exists, false);
output.push_str("\n }");
if index + 1 != statuses.len() {
output.push(',');
}
output.push('\n');
}
output.push_str(" ]\n");
output.push('}');
println!("{output}");
}
fn print_help() {
println!("Usage: redbear-info [--verbose|-v] [--json|--test]");
println!();
println!("Enumerate Red Bear OS custom components and report runtime availability.");
println!();
println!("Options:");
println!(" -v, --verbose Show component dependencies");
println!(" --json Print machine-readable JSON");
println!(" --test Print runtime test commands for available components");
println!(" -h, --help Show this help message");
}
fn available_count(statuses: &[ComponentStatus<'_>]) -> usize {
statuses.iter().filter(|status| status.available).count()
}
fn format_dependencies(dependencies: &[&str]) -> String {
if dependencies.is_empty() {
"none".to_string()
} else {
dependencies.join(", ")
}
}
fn marker_for(status: &ComponentStatus<'_>) -> &'static str {
if status.available {
""
} else {
""
}
}
fn marker_color(status: &ComponentStatus<'_>) -> &'static str {
match status.state {
AvailabilityState::Available | AvailabilityState::BuiltIn => GREEN,
AvailabilityState::Unavailable => status_color(status),
}
}
fn status_color(status: &ComponentStatus<'_>) -> &'static str {
match status.state {
AvailabilityState::Available | AvailabilityState::BuiltIn => GREEN,
AvailabilityState::Unavailable if status.status_text == "not running" => YELLOW,
AvailabilityState::Unavailable => RED,
}
}
fn colorize(text: &str, color: &str) -> String {
format!("{color}{text}{RESET}")
}
fn bool_to_json(value: bool) -> &'static str {
if value {
"true"
} else {
"false"
}
}
fn push_json_field(output: &mut String, key: &str, value: &str, trailing_comma: bool) {
output.push_str(" ");
push_json_string(output, key);
output.push_str(": ");
push_json_string(output, value);
if trailing_comma {
output.push(',');
}
output.push('\n');
}
fn push_json_array(output: &mut String, values: &[&str]) {
output.push('[');
for (index, value) in values.iter().enumerate() {
if index > 0 {
output.push_str(", ");
}
push_json_string(output, value);
}
output.push(']');
}
fn push_json_optional_bool(
output: &mut String,
key: &str,
value: Option<bool>,
trailing_comma: bool,
) {
output.push_str(" ");
push_json_string(output, key);
output.push_str(": ");
match value {
Some(flag) => output.push_str(bool_to_json(flag)),
None => output.push_str("null"),
}
if trailing_comma {
output.push(',');
}
output.push('\n');
}
fn push_json_string(output: &mut String, value: &str) {
output.push('"');
for ch in value.chars() {
match ch {
'"' => output.push_str("\\\""),
'\\' => output.push_str("\\\\"),
'\n' => output.push_str("\\n"),
'\r' => output.push_str("\\r"),
'\t' => output.push_str("\\t"),
_ => output.push(ch),
}
}
output.push('"');
}
@@ -43,10 +43,7 @@ README
# will ensure all of these are built and staged before this package
dependencies = [
"redbear-release",
"redox-driver-sys",
"linux-kpi",
"firmware-loader",
"redox-drm",
"evdevd",
"udev-shim",
]
+11 -11
View File
@@ -1,5 +1,5 @@
#!/usr/bin/env bash
# apply-patches.sh — Apply all RBOS patches on top of upstream Redox build system.
# apply-patches.sh — Apply all Red Bear OS patches on top of upstream Redox build system.
#
# Usage: ./local/scripts/apply-patches.sh [--force]
#
@@ -95,25 +95,25 @@ mkdir -p recipes/core
symlink "../../local/recipes/core/ext4d" "recipes/core/ext4d"
# ── 4. New files not in upstream ────────────────────────────────────
echo "==> Ensuring RBOS-specific files exist..."
echo "==> Ensuring Red Bear OS-specific files exist..."
# rbos.ipxe (network boot)
if [ ! -f rbos.ipxe ] && [ ! -L rbos.ipxe ]; then
cat > rbos.ipxe <<'IPXE'
# redbear.ipxe (network boot)
if [ ! -f redbear.ipxe ] && [ ! -L redbear.ipxe ]; then
cat > redbear.ipxe <<'IPXE'
#!ipxe
kernel bootloader-live.efi
initrd http://${next-server}:8080/rbos-live.iso
initrd http://${next-server}:8080/redbear-live.iso
boot
IPXE
echo " created rbos.ipxe"
echo " created redbear.ipxe"
fi
# redbear-full config (not in upstream)
if [ ! -f config/redbear-full.toml ] && [ ! -L config/redbear-full.toml ]; then
cat > config/redbear-full.toml <<'TOML'
# Red Bear OS Full Configuration
# Complete desktop + all RBOS custom drivers and tools
# Complete desktop + all Red Bear OS custom drivers and tools
#
# Build: make all CONFIG_NAME=redbear-full
# Live: make live CONFIG_NAME=redbear-full
@@ -132,7 +132,7 @@ redbear-release = {}
# ext4 filesystem support (our custom port)
ext4d = {}
# RBOS driver infrastructure
# Red Bear OS driver infrastructure
redox-driver-sys = {}
linux-kpi = {}
firmware-loader = {}
@@ -145,12 +145,12 @@ udev-shim = {}
redox-drm = {}
amdgpu = {}
# RBOS meta-package (dependencies, default config)
# Red Bear OS meta-package (dependencies, default config)
redbear-meta = {}
TOML
echo " created config/redbear-full.toml"
fi
echo ""
echo "==> All RBOS patches applied. Ready to build."
echo "==> All Red Bear OS patches applied. Ready to build."
echo " make all CONFIG_NAME=redbear-full"
+1 -1
View File
@@ -71,7 +71,7 @@ else
fi
# Step 3: Build
echo ">>> Building RBOS with config: $CONFIG"
echo ">>> Building Red Bear OS with config: $CONFIG"
echo ">>> This may take 30-60 minutes on first build..."
CI=1 make all "CONFIG_NAME=$CONFIG" "JOBS=$JOBS"
+5 -5
View File
@@ -1,12 +1,12 @@
#!/usr/bin/env bash
# sync-upstream.sh — Update from upstream Redox and reapply RBOS patches.
# sync-upstream.sh — Update from upstream Redox and reapply Red Bear OS patches.
#
# Usage:
# ./local/scripts/sync-upstream.sh # Rebase onto upstream master
# ./local/scripts/sync-upstream.sh --dry-run # Preview what would change
# ./local/scripts/sync-upstream.sh --no-merge # Only fetch + check for conflicts
#
# Strategy: git rebase (preserves RBOS commits, replays on new upstream).
# Strategy: git rebase (preserves Red Bear OS commits, replays on new upstream).
# Fallback: if rebase fails, patches in local/patches/build-system/ can be
# applied from scratch via: ./local/scripts/apply-patches.sh --force
@@ -87,7 +87,7 @@ echo ""
echo "=== Sync Summary ==="
echo "Upstream: $UPSTREAM_REF"
echo "Local: HEAD ($(git rev-parse --short HEAD))"
echo "Ahead: $AHEAD RBOS commits"
echo "Ahead: $AHEAD Red Bear OS commits"
echo "Behind: $BEHIND upstream commits"
if [ "$NO_MERGE" = 1 ]; then
@@ -107,7 +107,7 @@ fi
STASHED=0
if ! git diff --quiet 2>/dev/null || ! git diff --cached --quiet 2>/dev/null; then
echo "==> Stashing uncommitted changes..."
git stash push -m "rbos-sync-$(date +%Y%m%d-%H%M%S)"
git stash push -m "redbear-sync-$(date +%Y%m%d-%H%M%S)"
STASHED=1
fi
@@ -115,7 +115,7 @@ PREV_HEAD=$(git rev-parse HEAD)
# ── 5. Rebase ───────────────────────────────────────────────────────
echo ""
echo "==> Rebasing RBOS commits onto $UPSTREAM_REF..."
echo "==> Rebasing Red Bear OS commits onto $UPSTREAM_REF..."
echo " (this replays our $AHEAD commits on top of updated upstream)"
if git rebase "$UPSTREAM_REF"; then
+1 -1
View File
@@ -1,6 +1,6 @@
#!/usr/bin/env bash
# Test AMD GPU driver on Red Bear OS
# Run this inside RBOS (or via QEMU serial console)
# Run this inside Red Bear OS (or via QEMU serial console)
set -euo pipefail
echo "=== AMD GPU Driver Test ==="
+2 -2
View File
@@ -186,7 +186,7 @@ refuse_unsafe_device "$DEVICE"
warn_if_system_disk "$DEVICE"
if [ "$SKIP_BUILD" -eq 0 ]; then
echo "=== Building RBOS image ==="
echo "=== Building Red Bear OS image ==="
run_cmd make -C "$REDOX_ROOT" all CONFIG_NAME="$CONFIG"
else
echo "=== Skipping build step ==="
@@ -194,7 +194,7 @@ fi
echo "=== Checking image ==="
if [ ! -f "$IMAGE_PATH" ]; then
echo "ERROR: RBOS image not found: $IMAGE_PATH"
echo "ERROR: Red Bear OS image not found: $IMAGE_PATH"
exit 1
fi