e6b907a130
The recipe adds a forkpty extern to the libc crate's Redox module (which relibc provides but the libc crate does not declare) so nix 0.30.1's pty module compiles. The sed anchor was `)-> c_int;` (no space), which matched older libc formatting but NOT libc 0.2.189's multi-line openpty close `) -> c_int;` (with space) — pulled in by the latest-upstream rule. The sed silently no-op'd, forkpty was never declared, and nix failed with "cannot find function forkpty in crate libc", breaking the mini build. Fix: anchor `) *-> c_int;` (optional space) matches both the old and new formatting. Verified: clean uutils-tar build compiles nix and finishes. Note on the stale-rlib symptom seen during diagnosis: cargo fingerprints registry crates by version, not source content, so a libc rlib compiled while the anchor was broken (forkpty absent) is reused even after the source is patched. A clean/target-wiped build recompiles correctly; the anchor fix is the durable root fix.
68 lines
2.6 KiB
TOML
68 lines
2.6 KiB
TOML
[source]
|
|
git = "https://github.com/uutils/tar"
|
|
rev = "5540ce1877e7cd964ebec75c92541c4d1e0472db"
|
|
shallow_clone = true
|
|
|
|
[build]
|
|
template = "custom"
|
|
script = """
|
|
DYNAMIC_INIT
|
|
|
|
# Patch nix-0.30.1 for Redox:
|
|
# 1. Enable the pty module (excluded for Redox+fuchsia, should be fuchsia-only)
|
|
# 2. SaFlags_t is c_ulong for Redox, matching relibc and libc crate
|
|
for nix_src in "${HOME}/.cargo/registry/src/"*/nix-0.30.1; do
|
|
if [ -f "$nix_src/src/lib.rs" ]; then
|
|
# Fix 1: Enable pty module for Redox
|
|
sed -i 's/#\\[cfg(not(any(target_os = "redox", target_os = "fuchsia")))\\]/#[cfg(not(target_os = "fuchsia"))]/' \
|
|
"$nix_src/src/lib.rs"
|
|
fi
|
|
done
|
|
|
|
# Patch libc for Redox to expose PTY functions that relibc implements
|
|
# but the libc Rust crate doesn't declare for the redox target.
|
|
# Matches any 0.2.x version since the Cargo.lock may resolve differently.
|
|
for libc_src in "${HOME}/.cargo/registry/src/"*/libc-0.2.*; do
|
|
if [ -f "$libc_src/src/unix/redox/mod.rs" ]; then
|
|
# Add forkpty declaration if missing.
|
|
# Anchor `) *-> c_int;` (optional space) so it matches both the older
|
|
# `)-> c_int;` and libc >=0.2.189's `) -> c_int;` close of the
|
|
# multi-line openpty declaration; the no-space anchor silently missed on
|
|
# 0.2.189 and left forkpty undeclared, breaking nix 0.30.1.
|
|
if ! grep -q 'pub fn forkpty' "$libc_src/src/unix/redox/mod.rs"; then
|
|
sed -i '/pub fn openpty(/,/) *-> c_int;/{
|
|
/) *-> c_int;/a\\
|
|
pub fn forkpty(\\
|
|
amaster: *mut c_int,\\
|
|
name: *mut c_char,\\
|
|
termp: *const termios,\\
|
|
winp: *const crate::winsize,\\
|
|
) -> c_int;
|
|
}' "$libc_src/src/unix/redox/mod.rs"
|
|
fi
|
|
|
|
# Add grantpt, posix_openpt, ptsname, ptsname_r, unlockpt if missing
|
|
if ! grep -q 'pub fn grantpt' "$libc_src/src/unix/redox/mod.rs"; then
|
|
sed -i '/pub fn reallocarray/a\\
|
|
pub fn grantpt(fd: c_int) -> c_int;\\
|
|
pub fn posix_openpt(flags: c_int) -> c_int;\\
|
|
pub fn ptsname(fd: c_int) -> *mut c_char;\\
|
|
pub fn ptsname_r(fd: c_int, buf: *mut c_char, buflen: size_t) -> c_int;\\
|
|
pub fn unlockpt(fd: c_int) -> c_int;' "$libc_src/src/unix/redox/mod.rs"
|
|
fi
|
|
|
|
# Add tcgetpgrp, tcsetpgrp if missing
|
|
if ! grep -q 'pub fn tcgetpgrp' "$libc_src/src/unix/redox/mod.rs"; then
|
|
sed -i '/pub fn setresuid/a\\
|
|
pub fn tcgetpgrp(fd: c_int) -> crate::pid_t;\\
|
|
pub fn tcsetpgrp(fd: c_int, pgrp: crate::pid_t) -> c_int;' "$libc_src/src/unix/redox/mod.rs"
|
|
fi
|
|
fi
|
|
done
|
|
|
|
cookbook_cargo
|
|
"""
|
|
|
|
[package]
|
|
description = "GNU tar-compatible archive utility (Rust uutils implementation)"
|