Refresh build infrastructure scripts and cross-tool wrappers

Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent)

Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
This commit is contained in:
2026-04-18 17:58:22 +01:00
parent 73d10558c1
commit 670529ae81
12 changed files with 129 additions and 80 deletions
+32
View File
@@ -0,0 +1,32 @@
#!/usr/bin/env bash
set -euo pipefail
tool_name="${1:?missing tool name}"
shift
script_dir="$(CDPATH= cd -- "$(dirname -- "$0")" && pwd)"
root_dir="$(CDPATH= cd -- "${script_dir}/.." && pwd)"
target_prefix="${tool_name%-*}"
candidate_roots=()
for env_var in REDBEAR_REDOX_SYSROOT COOKBOOK_TOOLCHAIN REDOXER_TOOLCHAIN RUSTUP_TOOLCHAIN; do
env_value="${!env_var:-}"
if [ -n "${env_value}" ]; then
candidate_roots+=("${env_value}")
fi
done
candidate_roots+=("${root_dir}/prefix/${target_prefix}/sysroot")
for tool_root in "${candidate_roots[@]}"; do
tool_path="${tool_root}/bin/${tool_name}"
if [ -x "${tool_path}" ]; then
exec "${tool_path}" "$@"
fi
done
missing_root="${candidate_roots[0]}"
echo "error: missing toolchain binary: ${missing_root}/bin/${tool_name}" >&2
echo "hint: run 'make prefix' or otherwise populate ${missing_root}" >&2
exit 1
+1 -12
View File
@@ -2,15 +2,4 @@
set -euo pipefail
script_dir="$(CDPATH= cd -- "$(dirname -- "$0")" && pwd)"
root_dir="$(CDPATH= cd -- "${script_dir}/.." && pwd)"
sysroot="${REDBEAR_REDOX_SYSROOT:-${root_dir}/prefix/x86_64-unknown-redox/sysroot}"
tool="${sysroot}/bin/x86_64-unknown-redox-ar"
if [ ! -x "${tool}" ]; then
echo "error: missing toolchain binary: ${tool}" >&2
echo "hint: run 'make prefix' or otherwise populate ${sysroot}" >&2
exit 1
fi
exec "${tool}" "$@"
exec "${script_dir}/redbear-run-tool" "$(basename "$0")" "$@"
+1 -12
View File
@@ -2,15 +2,4 @@
set -euo pipefail
script_dir="$(CDPATH= cd -- "$(dirname -- "$0")" && pwd)"
root_dir="$(CDPATH= cd -- "${script_dir}/.." && pwd)"
sysroot="${REDBEAR_REDOX_SYSROOT:-${root_dir}/prefix/x86_64-unknown-redox/sysroot}"
tool="${sysroot}/bin/x86_64-unknown-redox-c++"
if [ ! -x "${tool}" ]; then
echo "error: missing toolchain binary: ${tool}" >&2
echo "hint: run 'make prefix' or otherwise populate ${sysroot}" >&2
exit 1
fi
exec "${tool}" "$@"
exec "${script_dir}/redbear-run-tool" "$(basename "$0")" "$@"
+1 -12
View File
@@ -2,15 +2,4 @@
set -euo pipefail
script_dir="$(CDPATH= cd -- "$(dirname -- "$0")" && pwd)"
root_dir="$(CDPATH= cd -- "${script_dir}/.." && pwd)"
sysroot="${REDBEAR_REDOX_SYSROOT:-${root_dir}/prefix/x86_64-unknown-redox/sysroot}"
tool="${sysroot}/bin/x86_64-unknown-redox-gcc"
if [ ! -x "${tool}" ]; then
echo "error: missing toolchain binary: ${tool}" >&2
echo "hint: run 'make prefix' or otherwise populate ${sysroot}" >&2
exit 1
fi
exec "${tool}" "$@"
exec "${script_dir}/redbear-run-tool" "$(basename "$0")" "$@"
+1 -12
View File
@@ -2,15 +2,4 @@
set -euo pipefail
script_dir="$(CDPATH= cd -- "$(dirname -- "$0")" && pwd)"
root_dir="$(CDPATH= cd -- "${script_dir}/.." && pwd)"
sysroot="${REDBEAR_REDOX_SYSROOT:-${root_dir}/prefix/x86_64-unknown-redox/sysroot}"
tool="${sysroot}/bin/x86_64-unknown-redox-ld"
if [ ! -x "${tool}" ]; then
echo "error: missing toolchain binary: ${tool}" >&2
echo "hint: run 'make prefix' or otherwise populate ${sysroot}" >&2
exit 1
fi
exec "${tool}" "$@"
exec "${script_dir}/redbear-run-tool" "$(basename "$0")" "$@"
+1 -12
View File
@@ -2,15 +2,4 @@
set -euo pipefail
script_dir="$(CDPATH= cd -- "$(dirname -- "$0")" && pwd)"
root_dir="$(CDPATH= cd -- "${script_dir}/.." && pwd)"
sysroot="${REDBEAR_REDOX_SYSROOT:-${root_dir}/prefix/x86_64-unknown-redox/sysroot}"
tool="${sysroot}/bin/x86_64-unknown-redox-ranlib"
if [ ! -x "${tool}" ]; then
echo "error: missing toolchain binary: ${tool}" >&2
echo "hint: run 'make prefix' or otherwise populate ${sysroot}" >&2
exit 1
fi
exec "${tool}" "$@"
exec "${script_dir}/redbear-run-tool" "$(basename "$0")" "$@"
+5 -5
View File
@@ -22,11 +22,11 @@ usage()
echo " i686. ARCH is not checked, so you can add a new architecture."
echo " Defaults to the directory containing the FILESYSTEM_CONFIG file,"
echo " or x86_64 if no FILESYSTEM_CONFIG is specified."
echo " -c CONFIG: The name of the config, e.g. desktop, server or demo."
echo " -c CONFIG: The name of the config, e.g. redbear-kde, redbear-full or redbear-minimal."
echo " Determines the name of the image, build/ARCH/CONFIG/harddrive.img"
echo " e.g. build/x86_64/desktop/harddrive.img"
echo " e.g. build/x86_64/redbear-kde/harddrive.img"
echo " Determines the name of FILESYSTEM_CONFIG if none is specified."
echo " Defaults to the basename of FILESYSTEM_CONFIG, or 'desktop'"
echo " Defaults to the basename of FILESYSTEM_CONFIG, or 'redbear-kde'"
echo " if FILESYSTEM_CONFIG is not specified."
echo " -f FILESYSTEM_CONFIG:"
echo " The config file to use. It can be in any location."
@@ -37,7 +37,7 @@ usage()
echo " If you specify both CONFIG and FILESYSTEM_CONFIG, it is not"
echo " necessary that they match, but it is recommended."
echo " Examples: ./build.sh -c demo live - make build/x86_64/demo/redbear-live.iso"
echo " ./build.sh -6 qemu - make build/i686/desktop/harddrive.img and"
echo " ./build.sh -6 qemu - make build/i686/redbear-kde/harddrive.img and"
echo " and run it in qemu"
echo " NOTE: If you do not change ARCH or CONFIG very often, edit mk/config.mk"
echo " and set ARCH and FILESYSTEM_CONFIG. You only need to use this"
@@ -50,7 +50,7 @@ if [ "$1" == "-h" ] || [ "$1" == "--help" ]; then
fi
defaultarch="x86_64"
defaultname="desktop"
defaultname="redbear-kde"
ARCH=""
CONFIG_NAME=""
FILESYSTEM_CONFIG=""
+4 -2
View File
@@ -16,8 +16,10 @@ PREFIX_BINARY?=1
PREFIX_USE_UPSTREAM_RUST_COMPILER?=0
## Enable to use binary packages (much faster)
REPO_BINARY?=0
## Name of the configuration to include in the image name e.g. desktop or server
CONFIG_NAME?=desktop
## Name of the configuration to include in the image name e.g. desktop or server.
## Red Bear's tracked default desktop target is redbear-kde. Runtime claims remain evidence-qualified
## until compositor/session proof is strong enough for broader support language.
CONFIG_NAME?=redbear-kde
## Build appstream data for repo
REPO_APPSTREAM?=0
## Ignore errors when building the repo, attempt to build every package
+2
View File
@@ -63,6 +63,8 @@ else
cp -r "$(PREFIX)/gcc-install/include/c++" "$@.partial/include/c++"
endif
export PATH="$(ROOT)/$@.partial/bin:$$PATH" && \
export COOKBOOK_TOOLCHAIN="$(ROOT)/$@.partial" REDBEAR_REDOX_SYSROOT="$(ROOT)/$@.partial" && \
export RUSTUP_TOOLCHAIN="$(ROOT)/$@.partial" REDOXER_TOOLCHAIN="$(ROOT)/$@.partial" && \
export CARGO="env -u CARGO cargo" $(PREFIX_CONFIG) && \
$(REPO_BIN) cook relibc
ifneq ($(HOSTED_REDOX),1)
+63 -5
View File
@@ -1,14 +1,67 @@
#!/usr/bin/env bash
# Build Red Bear OS live ISO
# Usage: ./scripts/build-iso.sh [CONFIG_NAME] [ARCH]
# Usage: ./scripts/build-iso.sh [--upstream] [CONFIG_NAME] [ARCH]
# CONFIG_NAME - build config (default: redbear-live)
# ARCH - target architecture (default: x86_64)
set -euo pipefail
CONFIG_NAME="${1:-redbear-live}"
ARCH="${2:-x86_64}"
CONFIG_NAME="redbear-live"
ARCH="x86_64"
ALLOW_UPSTREAM=0
usage() {
cat <<EOF
Usage: $(basename "$0") [OPTIONS] [CONFIG_NAME] [ARCH]
Build a Red Bear OS live ISO.
Options:
--upstream Allow Redox/upstream recipe source refresh during build
-h, --help Show this help
Defaults:
CONFIG_NAME=redbear-live
ARCH=x86_64
EOF
}
POSITIONAL=()
while [ $# -gt 0 ]; do
case "$1" in
--upstream)
ALLOW_UPSTREAM=1
;;
-h|--help)
usage
exit 0
;;
--)
shift
POSITIONAL+=("$@")
break
;;
-*)
echo "Unknown option: $1" >&2
usage >&2
exit 1
;;
*)
POSITIONAL+=("$1")
;;
esac
shift
done
if [ ${#POSITIONAL[@]} -gt 2 ]; then
echo "ERROR: Too many positional arguments" >&2
usage >&2
exit 1
fi
[ ${#POSITIONAL[@]} -ge 1 ] && CONFIG_NAME="${POSITIONAL[0]}"
[ ${#POSITIONAL[@]} -ge 2 ] && ARCH="${POSITIONAL[1]}"
if [ -z "${CI:-}" ] && { [ ! -t 0 ] || [ ! -t 1 ]; }; then
export CI=1
@@ -17,8 +70,13 @@ fi
echo "Building Red Bear OS ISO"
echo " config: ${CONFIG_NAME}"
echo " arch: ${ARCH}"
make live CONFIG_NAME="${CONFIG_NAME}" ARCH="${ARCH}"
if [ "$ALLOW_UPSTREAM" -eq 1 ]; then
echo " upstream recipe refresh: enabled"
REPO_OFFLINE=0 COOKBOOK_OFFLINE=false make live CONFIG_NAME="${CONFIG_NAME}" ARCH="${ARCH}"
else
echo " upstream recipe refresh: disabled (pass --upstream to enable)"
REPO_OFFLINE=1 COOKBOOK_OFFLINE=true make live CONFIG_NAME="${CONFIG_NAME}" ARCH="${ARCH}"
fi
echo ""
echo "Done: build/${ARCH}/${CONFIG_NAME}.iso"
+7 -7
View File
@@ -5,7 +5,7 @@
# blake3. Falls back to file-size comparison when no blake3 is recorded.
#
# Usage:
# ./scripts/fetch-all-sources.sh # Fetch for default desktop config
# ./scripts/fetch-all-sources.sh # Fetch for the tracked KWin default config
# ./scripts/fetch-all-sources.sh redbear-full # Fetch for a specific config
# ./scripts/fetch-all-sources.sh --all-configs # Fetch for every config
# ./scripts/fetch-all-sources.sh --recipe kernel # Fetch a single recipe
@@ -32,7 +32,7 @@ REPO_ROOT="$(cd "$SCRIPT_DIR/.." && pwd)"
cd "$REPO_ROOT"
REPO_BIN="./target/release/repo"
CONFIG_NAME="${1:-desktop}"
CONFIG_NAME="${1:-redbear-kde}"
ACTION="fetch"
# ── Colors (disabled when not a terminal) ───────────────────────────
@@ -58,8 +58,8 @@ usage() {
echo " --force Force re-download even if checksums match"
echo " --help Show this help"
echo ""
echo "Configs: desktop, redbear-full, redbear-minimal, server, minimal, wayland, x11"
echo "Default config: desktop"
echo "Configs: redbear-kde, redbear-live, redbear-full, redbear-minimal, redbear-wayland"
echo "Default config: redbear-kde"
}
ALL_CONFIGS=0
@@ -481,7 +481,7 @@ case "$ACTION" in
preflight)
build_repo
if [ "$ALL_CONFIGS" -eq 1 ]; then
for cfg in desktop redbear-full redbear-minimal server minimal wayland x11; do
for cfg in redbear-kde redbear-live redbear-full redbear-minimal redbear-wayland; do
preflight_scan "$cfg" || true
done
else
@@ -491,7 +491,7 @@ case "$ACTION" in
list)
build_repo
if [ "$ALL_CONFIGS" -eq 1 ]; then
for cfg in desktop redbear-full redbear-minimal server minimal wayland x11; do
for cfg in redbear-kde redbear-live redbear-full redbear-minimal redbear-wayland; do
list_for_config "$cfg" 2>/dev/null || true
done
else
@@ -506,7 +506,7 @@ case "$ACTION" in
elif [ "$ALL_CONFIGS" -eq 1 ]; then
echo "==> Fetching sources for ALL configs"
echo " This ensures every recipe needed by any config is downloaded."
for cfg in desktop redbear-full redbear-minimal server minimal wayland x11; do
for cfg in redbear-kde redbear-live redbear-full redbear-minimal redbear-wayland; do
fetch_for_config "$cfg" 2>/dev/null || {
echo " WARNING: failed to fetch for $cfg (some recipes may not exist)"
echo ""
+11 -1
View File
@@ -7,6 +7,7 @@ PROJECT_ROOT="$(cd "$SCRIPT_DIR/.." && pwd)"
CONFIG_NAME="redbear-full"
ARCH="$(uname -m)"
BUILD=0
ALLOW_UPSTREAM=0
QEMU_EXTRA_ARGS=()
usage() {
@@ -19,12 +20,14 @@ Options:
-b, --build Build full OS before running
-c, --config NAME Config name (default: redbear-full)
-a, --arch ARCH Target architecture (default: host arch)
--upstream Allow Redox/upstream recipe source refresh during build
-- ARGS Pass remaining args to make qemu (e.g. -- QEMUFLAGS="-m 8G")
-h, --help Show this help
Examples:
$(basename "$0") # Run existing image
$(basename "$0") --build # Build + run
$(basename "$0") --build --upstream # Build + run with upstream source refresh enabled
$(basename "$0") -b -c redbear-minimal # Build minimal + run
$(basename "$0") -- QEMUFLAGS="-m 8G" # Run with 8G RAM
$(basename "$0") -b -- serial=yes # Build + run with serial console
@@ -38,6 +41,7 @@ while [ $# -gt 0 ]; do
-b|--build) BUILD=1 ;;
-c|--config) CONFIG_NAME="$2"; shift ;;
-a|--arch) ARCH="$2"; shift ;;
--upstream) ALLOW_UPSTREAM=1 ;;
-h|--help) usage ;;
--) shift; QEMU_EXTRA_ARGS=("$@"); break ;;
*) echo "Unknown option: $1"; exit 1 ;;
@@ -62,7 +66,13 @@ if [ "$BUILD" -eq 1 ]; then
cargo build --release
echo "==> Building Red Bear OS ($CONFIG_NAME, $ARCH)..."
CI=1 make all "CONFIG_NAME=$CONFIG_NAME" ARCH="$ARCH"
if [ "$ALLOW_UPSTREAM" -eq 1 ]; then
echo "==> Upstream recipe refresh: enabled"
REPO_OFFLINE=0 COOKBOOK_OFFLINE=false CI=1 make all "CONFIG_NAME=$CONFIG_NAME" ARCH="$ARCH"
else
echo "==> Upstream recipe refresh: disabled (pass --upstream to enable)"
REPO_OFFLINE=1 COOKBOOK_OFFLINE=true CI=1 make all "CONFIG_NAME=$CONFIG_NAME" ARCH="$ARCH"
fi
echo "==> Build complete."
fi