Files
RedBear-OS/recipes/core/uutils/recipe.toml
T
vasilito ca757f9898 uutils: fix nix 0.30.1 Redox SaFlags_t (c_ulong -> c_int)
nix 0.30.1 wrongly types Redox's sigaction SaFlags_t as c_ulong, but
relibc and the libc crate both declare sa_flags/SA_* as c_int (nix 0.31
already uses c_int for Redox). With the `kill` feature the nix signal
module is compiled and the u64-vs-i32 mismatch breaks the SaFlags
bitflags (E0308). This was latent (uutils built from cache); the relibc
epoll rebuild forced a clean recompile and surfaced it.

Patch the nix Redox branch before cookbook_cargo, with cargo fetch first
so the registry source exists before patching.
2026-07-17 08:19:10 +09:00

152 lines
3.1 KiB
TOML

[package]
name = "uutils"
version = "0.1.0"
# TODO Fix coreutils i18n/l10n behavior on Redox
# TODO Fix locale init bug on aarch64 before removing patches
# TODO https://github.com/uutils/coreutils/commit/e6f7ad06 broke locales on x86_64
[source]
git = "https://github.com/uutils/coreutils"
rev = "1f7c81f5d2d3e56c518349c0392158871a1ea9ec"
patches = [
"redox.patch"
]
[build]
template = "custom"
script = """
DYNAMIC_INIT
python3 - <<'PY'
import os
from pathlib import Path
tmp_dir = Path(os.environ["COOKBOOK_SOURCE"]) / "src/uu/sort/src/tmp_dir.rs"
text = tmp_dir.read_text()
text = text.replace('use std::sync::atomic::{AtomicBool, Ordering};\\n', '')
text = text.replace('use uucore::{\\n error::{UResult, USimpleError},\\n show_error, translate,\\n};\\n', 'use uucore::error::UResult;\\n')
text = text.replace(' path::{Path, PathBuf},\\n', ' path::PathBuf,\\n')
start = text.find('/// Remove the directory at `path` by deleting its child files and then itself.')
if start != -1:
end = text.find('\\n}\\n', start)
if end != -1:
text = text[:start] + text[end + 3:]
tmp_dir.write_text(text)
PY
# nix 0.30.1 wrongly types Redox's sigaction SaFlags_t as c_ulong, but relibc
# and the libc crate both declare sa_flags/SA_* as c_int (nix 0.31 already uses
# c_int for Redox). With the `kill` feature the nix signal module is compiled,
# and the u64-vs-i32 mismatch breaks the SaFlags bitflags (E0308). Correct the
# Redox branch. cargo fetch first so the registry source exists before patching
# (it is only unpacked during the build).
cargo fetch --manifest-path "${COOKBOOK_SOURCE}/Cargo.toml" || true
for nix_src in "${HOME}/.cargo/registry/src/"*/nix-0.30.1; do
sig="$nix_src/src/sys/signal.rs"
[ -f "$sig" ] || continue
sed -i '/if #\\[cfg(target_os = "redox")\\] {/{n;s/type SaFlags_t = libc::c_ulong;/type SaFlags_t = libc::c_int;/}' "$sig"
done
# TODO: upstream changes, consider using feat_require_unix_core if relibc is ready?
CARGO_PROFILE_RELEASE_LTO=thin cookbook_cargo --no-default-features --features feat_os_unix_redox,kill --bin coreutils
BINS=(
'['
b2sum
b3sum
base32
base64
basename
basenc
cat
chmod
cksum
comm
cp
csplit
cut
date
dd
#df not working, use redox coreutils
dir
dircolors
dirname
du
echo
env
expand
expr
factor
false
fmt
fold
hashsum
head
join
install
kill
link
ln
ls
md5sum
mkdir
mktemp
more
mv
nl
nproc
numfmt
od
paste
pr
printenv
printf
ptx
pwd
readlink
realpath
rm
rmdir
seq
sha1sum
sha224sum
sha256sum
sha3-224sum
sha3-256sum
sha3-384sum
sha3-512sum
sha384sum
sha3sum
sha512sum
shake128sum
shake256sum
shred
shuf
sleep
sort
split
stat
sum
tac
tail
tee
test
touch
tr
true
truncate
tsort
unexpand
uname
uniq
unlink
vdir
wc
yes
)
for bin in "${BINS[@]}"
do
ln -sv coreutils "${COOKBOOK_STAGE}/usr/bin/$bin"
done
"""