build-redbear.sh: add CLI flags for the common operator knobs
Convert the routinely-used environment knobs to command-line flags (the canonical interface); the REDBEAR_*/JOBS env vars remain deprecated fallbacks. New flags: -j/--jobs, --release VER, --allow-dirty, --keep-build-state (--upstream/--no-cache already existed). Resolved values are re-exported so the gates and sub-scripts observe them. Rare escape hatches stay env-only and are documented under an 'Advanced' section in --help. Dropped the phantom REDBEAR_SKIP_ABI_STALENESS doc; did not add --arch/--target (x86_64-only build). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -9,7 +9,7 @@ PROJECT_ROOT="$(cd "$SCRIPT_DIR/../.." && pwd)"
|
||||
# REDBEAR_VERSION (which tracks the OS release derived from the git branch).
|
||||
# Starts at 1.0 and is bumped AUTOMATICALLY on every change by the pre-commit
|
||||
# git hook (local/scripts/bump-build-version.sh); do not edit the minor by hand.
|
||||
BUILD_REDBEAR_VERSION="1.2"
|
||||
BUILD_REDBEAR_VERSION="1.3"
|
||||
|
||||
# ── Colorized output ──────────────────────────────────
|
||||
# Enabled only on a TTY with NO_COLOR unset, so redirected build logs and CI
|
||||
@@ -204,16 +204,23 @@ if [ -f "$PROJECT_ROOT/.config" ]; then
|
||||
done < "$PROJECT_ROOT/.config"
|
||||
fi
|
||||
|
||||
# ── Operator knobs ─────────────────────────────────────────────
|
||||
# The common knobs below have CLI flags (the canonical interface); the matching
|
||||
# REDBEAR_*/JOBS environment variables remain DEPRECATED fallback defaults so
|
||||
# older automation keeps working. Rarer escape hatches stay env-only (listed in
|
||||
# usage()). Resolved values are re-exported after the parser so this script's
|
||||
# gates and the sub-scripts observe the flag-provided values.
|
||||
CONFIG="redbear-full"
|
||||
JOBS="${JOBS:-$(nproc)}"
|
||||
APPLY_PATCHES="${APPLY_PATCHES:-1}"
|
||||
ALLOW_UPSTREAM=0
|
||||
NO_CACHE=0
|
||||
ALLOW_UPSTREAM="${REDBEAR_ALLOW_UPSTREAM:-0}"
|
||||
ALLOW_DIRTY="${REDBEAR_ALLOW_DIRTY:-0}"
|
||||
KEEP_BUILD_STATE="${REDBEAR_KEEP_BUILD_STATE:-0}"
|
||||
RELEASE="${REDBEAR_RELEASE:-}"
|
||||
|
||||
# ARCH and HOST_ARCH are used by the Makefile (mk/config.mk) and the prefix
|
||||
# rule (mk/prefix.mk). They are derived from `uname -m` if unset. Exporting
|
||||
# them at the top of this script ensures the auto-rebuild-prefix path
|
||||
# below receives a valid value, and the variable is visible to subprocesses.
|
||||
# rule (mk/prefix.mk). They are derived from `uname -m` if unset.
|
||||
export ARCH="${ARCH:-$(uname -m)}"
|
||||
export HOST_ARCH="${HOST_ARCH:-$(uname -m)}"
|
||||
|
||||
@@ -224,8 +231,12 @@ Usage: $(basename "$0") [OPTIONS] [CONFIG]
|
||||
Build a tracked Red Bear OS profile.
|
||||
|
||||
Options:
|
||||
--upstream Allow Redox/upstream recipe source refresh during build
|
||||
--no-cache Force clean rebuild, discarding cached packages
|
||||
-j, --jobs N Parallel build jobs (default: nproc)
|
||||
--upstream Allow Redox/upstream recipe source refresh during build
|
||||
--no-cache Force clean rebuild, discarding cached packages
|
||||
--release VER Build from the immutable release archive VER
|
||||
--allow-dirty Build with uncommitted fork edits (cooks the tree AS-IS)
|
||||
--keep-build-state Keep the diagnostic state dir after exit
|
||||
-h, --help Show this help
|
||||
-V, --version Show build-system version/provenance and exit
|
||||
|
||||
@@ -235,30 +246,34 @@ Configs:
|
||||
redbear-grub Text-only with GRUB boot manager
|
||||
redbear-bare Stripped-to-bare-minimum: kernel+7-initfs-daemons+zsh login
|
||||
|
||||
Environment:
|
||||
REDBEAR_RELEASE If set, builds from immutable release archives.
|
||||
Override to empty for development builds.
|
||||
REDBEAR_SKIP_ABI_STALENESS=1
|
||||
Fast iteration: skip the relibc-consumer invalidation
|
||||
churn so a rerun goes straight to the recipe you changed
|
||||
(the cookbook cache still re-cooks changed sources). Safe
|
||||
ONLY when relibc's ABI is unchanged. Unset it whenever you
|
||||
bump relibc/base, or stale binaries may ship.
|
||||
REDBEAR_FORCE_TOOLCHAIN_RECOOK=1
|
||||
Force a full re-cook of preserved toolchain packages
|
||||
(llvm21/clang21/lld21/rust) on a relibc change.
|
||||
Advanced (rare escape hatches — set as environment variables):
|
||||
REDBEAR_ALLOW_CONCURRENT=1 Skip the single-build lock
|
||||
REDBEAR_ALLOW_WRONG_BRANCH=1 Build with a fork off its submodule/<name> branch
|
||||
REDBEAR_SKIP_PREFIX_REBUILD=1 Do not auto-rebuild a stale prefix sysroot
|
||||
REDBEAR_FORCE_TOOLCHAIN_RECOOK=1 Re-cook llvm21/clang21/lld21/rust on a relibc change
|
||||
REDBEAR_SKIP_FORK_VERIFY=1 Skip fork version verification (preflight)
|
||||
REDBEAR_SKIP_DRIFT_CHECK=1 Skip upstream drift check (preflight)
|
||||
REDBEAR_SKIP_FUNCTION_CHECK=1 Skip fork-function verification (preflight)
|
||||
REDBEAR_SKIP_COLLISION_CHECK=1 Skip config-vs-package collision detection (preflight)
|
||||
REDBEAR_SKIP_PATCH_CONTENT_CHECK=1 Skip orphaned-patch content check (preflight)
|
||||
REDBEAR_STRICT_DURABILITY=1 Fail on non-durable source edits (preflight)
|
||||
REDBEAR_STRICT_METADATA=1 Fail on recipe metadata issues (preflight)
|
||||
REDBEAR_NO_VALIDATE=1 Skip the post-build image validation chain (make)
|
||||
REDBEAR_COLLISIONS_WARN=1 Downgrade install-collision failures to warnings (make)
|
||||
EOF
|
||||
}
|
||||
|
||||
POSITIONAL=()
|
||||
while [ $# -gt 0 ]; do
|
||||
case "$1" in
|
||||
--upstream)
|
||||
ALLOW_UPSTREAM=1
|
||||
;;
|
||||
--no-cache)
|
||||
NO_CACHE=1
|
||||
;;
|
||||
--upstream) ALLOW_UPSTREAM=1 ;;
|
||||
--no-cache) NO_CACHE=1 ;;
|
||||
-j|--jobs) shift; JOBS="${1:?--jobs requires a number}" ;;
|
||||
--jobs=*) JOBS="${1#*=}" ;;
|
||||
--release) shift; RELEASE="${1:?--release requires a version}" ;;
|
||||
--release=*) RELEASE="${1#*=}" ;;
|
||||
--allow-dirty) ALLOW_DIRTY=1 ;;
|
||||
--keep-build-state) KEEP_BUILD_STATE=1 ;;
|
||||
-h|--help)
|
||||
usage
|
||||
exit 0
|
||||
@@ -297,6 +312,14 @@ case "$CONFIG" in
|
||||
;;
|
||||
esac
|
||||
|
||||
# Re-export resolved common knobs so this script's gates, build-preflight.sh and
|
||||
# the Makefile see the flag-provided values (flags override the deprecated
|
||||
# REDBEAR_* env fallbacks). REDBEAR_RELEASE is exported as-is (empty = dev build).
|
||||
export REDBEAR_ALLOW_UPSTREAM="$ALLOW_UPSTREAM"
|
||||
export REDBEAR_ALLOW_DIRTY="$ALLOW_DIRTY"
|
||||
export REDBEAR_KEEP_BUILD_STATE="$KEEP_BUILD_STATE"
|
||||
export REDBEAR_RELEASE="$RELEASE"
|
||||
|
||||
hdr "========================================"
|
||||
hdr " Red Bear OS Build System"
|
||||
hdr "========================================"
|
||||
@@ -341,7 +364,7 @@ if [ "${REDBEAR_ALLOW_DIRTY:-0}" != "1" ] && [ -z "${REDBEAR_RELEASE:-}" ]; then
|
||||
echo "committed state. Commit, stash, or reset your changes before" >&2
|
||||
echo "running a canonical build." >&2
|
||||
echo "" >&2
|
||||
echo "Override (emergency only): REDBEAR_ALLOW_DIRTY=1 $0 $*" >&2
|
||||
echo "Override (emergency only): $0 --allow-dirty $*" >&2
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
@@ -441,7 +464,7 @@ redbear_dump_failure_diagnostics() {
|
||||
echo "Diagnostic state preserved at:"
|
||||
echo " $REDBEAR_BUILD_STATE_DIR"
|
||||
echo ""
|
||||
echo "Set REDBEAR_KEEP_BUILD_STATE=1 before running to retain this directory"
|
||||
echo "Pass --keep-build-state to retain this directory"
|
||||
echo "after the script exits."
|
||||
echo ""
|
||||
|
||||
|
||||
Reference in New Issue
Block a user