c843db2682
- Track base submodule pointer for output_level Warn console-quiet change. - Capture brush entry.rs redox edits (tokio current-thread runtime, default minimal input backend) as patches/brush-redox-runtime-and-input.patch and apply it in the recipe, so a clean source re-fetch keeps the Redox port.
85 lines
3.9 KiB
TOML
85 lines
3.9 KiB
TOML
[package]
|
|
name = "brush"
|
|
version = "0.1.0"
|
|
|
|
[source]
|
|
git = "https://github.com/reubeno/brush"
|
|
|
|
[build]
|
|
template = "custom"
|
|
script = """
|
|
# ---------------------------------------------------------------------------
|
|
# RedBear Redox port for brush.
|
|
#
|
|
# brush pulls `nix` 0.31.x and `libc` 0.2.x, neither of which builds for Redox
|
|
# as-is: upstream nix only partially cfg-enables Redox, and the `libc` crate's
|
|
# Redox module omits several POSIX symbols that relibc actually provides. The
|
|
# fixes live as reviewable unified diffs under patches/:
|
|
#
|
|
# patches/nix-0.31-redox.patch cfg-enable resource/Id/waitid/from_siginfo,
|
|
# rlimit import + repr(i32), SaFlags width
|
|
# casts, and pty for Redox.
|
|
# patches/libc-0.2-redox.patch add idtype_t, P_*/CLD_*, rusage, getrusage
|
|
# + waitid externs, siginfo child accessors.
|
|
# patches/brush-umask-redox.patch mode_t is signed on Redox; use a cast
|
|
# instead of u32::from (widening-only).
|
|
# patches/brush-redox-runtime-and-input.patch use tokio current-thread
|
|
# runtime on Redox (multi-thread build fails),
|
|
# and default to the minimal input backend
|
|
# (reedline/crossterm raw mode does not yet
|
|
# work over the fbcon console scheme).
|
|
#
|
|
# Registry dependency sources are only unpacked during the build, so we run
|
|
# `cargo fetch` first to materialise them, then patch. apply_patch is
|
|
# idempotent (skips if already applied) but fails loudly if a patch does not
|
|
# apply cleanly -- the intended signal that a version bump moved the code.
|
|
# ---------------------------------------------------------------------------
|
|
|
|
PATCHES="${COOKBOOK_RECIPE}/patches"
|
|
|
|
# Materialise all dependency sources into the cargo registry before patching.
|
|
cargo fetch --manifest-path "${COOKBOOK_SOURCE}/Cargo.toml"
|
|
|
|
# Resolve the extracted registry directory for a crate whose Cargo.lock version
|
|
# begins with the given prefix (brush may depend on several majors of the same
|
|
# crate, e.g. nix 0.26 and 0.31; the patch targets one specific series).
|
|
crate_dir() {
|
|
local name="$1" prefix="$2" ver
|
|
ver="$(awk -v n="name = \\"$1\\"" -v p="$2" '
|
|
$0 == n { getline; gsub(/[^0-9.]/, "", $0);
|
|
if (index($0, p) == 1) { print; exit } }
|
|
' "${COOKBOOK_SOURCE}/Cargo.lock")"
|
|
[ -n "$ver" ] || { echo "crate_dir: ${name} ${prefix}* not found in Cargo.lock" >&2; return 1; }
|
|
local d
|
|
for d in "${HOME}/.cargo/registry/src/"*/"${name}-${ver}"; do
|
|
[ -d "$d" ] && { echo "$d"; return 0; }
|
|
done
|
|
echo "crate_dir: ${name}-${ver} not extracted" >&2
|
|
return 1
|
|
}
|
|
|
|
# apply_patch <target_dir> <patch_file>: apply forward, or skip if the patch is
|
|
# already applied (detected via a clean reverse dry-run). Any other failure is
|
|
# fatal.
|
|
apply_patch() {
|
|
local dir="$1" patch="$2"
|
|
if patch -p1 -R --dry-run -f -d "$dir" < "$patch" >/dev/null 2>&1; then
|
|
echo "apply_patch: $(basename "$patch") already applied in $dir, skipping"
|
|
return 0
|
|
fi
|
|
echo "apply_patch: applying $(basename "$patch") in $dir"
|
|
patch -p1 -f -d "$dir" < "$patch"
|
|
}
|
|
|
|
apply_patch "$(crate_dir nix 0.31)" "${PATCHES}/nix-0.31-redox.patch"
|
|
apply_patch "$(crate_dir libc 0.2)" "${PATCHES}/libc-0.2-redox.patch"
|
|
apply_patch "${COOKBOOK_SOURCE}" "${PATCHES}/brush-umask-redox.patch"
|
|
apply_patch "${COOKBOOK_SOURCE}" "${PATCHES}/brush-redox-runtime-and-input.patch"
|
|
|
|
# The shell lives in the `brush-shell` package but its binary target is named
|
|
# `brush` (see brush-shell/Cargo.toml `[[bin]] name = "brush"`), so
|
|
# cookbook_cargo_packages (which copies a binary matching the package name)
|
|
# cannot find it. Build the package explicitly and install the `brush` binary.
|
|
bin_name="brush" bin_flags="--package brush-shell --bin brush" bin_final_name="brush" cookbook_cargo_build
|
|
"""
|