Skip to content

Commit 166ac1a

Browse files
authored
Merge branch 'main' into sylvestre-patch-4
2 parents 01a4f6d + 209bb97 commit 166ac1a

File tree

39 files changed

+3482
-2772
lines changed

39 files changed

+3482
-2772
lines changed

.github/workflows/CICD.yml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -378,8 +378,7 @@ jobs:
378378
- { os: ubuntu-latest , target: x86_64-unknown-linux-gnu , features: "feat_os_unix,test_risky_names", use-cross: use-cross, skip-publish: true }
379379
- { os: ubuntu-latest , target: x86_64-unknown-linux-gnu , features: "feat_os_unix,uudoc" , use-cross: no, workspace-tests: true }
380380
- { os: ubuntu-latest , target: x86_64-unknown-linux-musl , features: feat_os_unix_musl , use-cross: use-cross }
381-
# utmpx, chroot stdbuf is broken on NetBSD at least for...
382-
- { os: ubuntu-latest , target: x86_64-unknown-netbsd , features: "feat_Tier1" , use-cross: use-cross , skip-tests: true , check-only: true }
381+
- { os: ubuntu-latest , target: x86_64-unknown-netbsd, features: "feat_Tier1,feat_require_unix_core,feat_require_unix_hostid,feat_require_unix_utmpx", use-cross: use-cross , skip-tests: true , check-only: true }
383382
- { os: ubuntu-latest , target: x86_64-unknown-redox , features: feat_os_unix_redox , use-cross: redoxer , skip-tests: true , check-only: true }
384383
- { os: ubuntu-latest , target: wasm32-wasip1, default-features: false, features: feat_wasm, skip-tests: true }
385384
- { os: macos-latest , target: aarch64-apple-darwin , features: feat_os_macos, workspace-tests: true } # M1 CPU

.github/workflows/code-quality.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ jobs:
116116
;;
117117
esac
118118
- name: "`cargo clippy` lint testing"
119-
uses: nick-fields/retry@v3
119+
uses: nick-fields/retry@v4
120120
with:
121121
max_attempts: 3
122122
retry_on: error

.github/workflows/make.yml

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -266,6 +266,40 @@ jobs:
266266
# 2. the makefile doesn't try to install libstdbuf even though stdbuf is skipped
267267
DESTDIR=/tmp/ make SKIP_UTILS="stdbuf" install
268268
269+
# keep this job minimal to avoid have many duplicated build with CICD
270+
build_makefile-other:
271+
name: Build/Makefile
272+
runs-on: ${{ matrix.job.os }}
273+
env:
274+
CARGO_INCREMENTAL: 0
275+
strategy:
276+
fail-fast: false
277+
matrix:
278+
job:
279+
- { os: windows-latest , features: feat_os_windows }
280+
steps:
281+
- uses: actions/checkout@v6
282+
with:
283+
persist-credentials: false
284+
- uses: Swatinem/rust-cache@v2
285+
- name: Run sccache-cache
286+
id: sccache-setup
287+
uses: mozilla-actions/sccache-action@v0.0.9
288+
continue-on-error: true
289+
- name: Export sccache
290+
if: steps.sccache-setup.outcome == 'success'
291+
run: |
292+
echo "RUSTC_WRAPPER=sccache" >> $GITHUB_ENV
293+
echo "SCCACHE_GHA_ENABLED=true" >> $GITHUB_ENV
294+
- name: "`make build`"
295+
shell: bash
296+
run: |
297+
set -x
298+
# Check that we exclude unix programs to avoid build failure
299+
make PREFIX=/tmp/usr MULTICALL=y COMPLETIONS=n MANPAGES=n LOCALES=n \
300+
SKIP_UTILS="arch b2sum base32 base64 basename basenc cat cksum comm cp csplit cut date dd df dir dircolors dirname du echo env expand expr factor false fmt fold head hostname join 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 sha384sum sha512sum shred shuf sleep sort split sum sync tac tail tee test touch tr truncate tsort uname unexpand uniq unlink vdir wc whoami yes"
301+
target/debug/coreutils.exe true
302+
269303
test_busybox:
270304
name: Tests/BusyBox test suite
271305
runs-on: ${{ matrix.job.os }}

.github/workflows/manpage-lint.yml

Lines changed: 109 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,109 @@
1+
# spell-checker:ignore mandoc uudoc manpages dtolnay libsystemd libattr libcap DESTDIR
2+
3+
name: Manpage Validation
4+
5+
on:
6+
pull_request:
7+
paths:
8+
- 'src/bin/uudoc.rs'
9+
- 'src/uu/*/locales/*.ftl'
10+
- 'src/uu/*/src/*.rs'
11+
- 'Cargo.toml'
12+
- 'GNUmakefile'
13+
- '.github/workflows/manpage-lint.yml'
14+
push:
15+
branches:
16+
- main
17+
paths:
18+
- 'src/bin/uudoc.rs'
19+
- 'src/uu/*/locales/*.ftl'
20+
- 'src/uu/*/src/*.rs'
21+
- 'Cargo.toml'
22+
- 'GNUmakefile'
23+
- '.github/workflows/manpage-lint.yml'
24+
25+
jobs:
26+
manpage-lint:
27+
name: Validate manpages with mandoc
28+
runs-on: ubuntu-latest
29+
strategy:
30+
matrix:
31+
locale: [en_US.UTF-8, fr_FR.UTF-8]
32+
33+
steps:
34+
- name: Checkout repository
35+
uses: actions/checkout@v6
36+
37+
- name: Install prerequisites
38+
shell: bash
39+
run: |
40+
sudo apt-get update
41+
sudo apt-get install -y mandoc locales-all
42+
sudo apt-get install -y libselinux1-dev libsystemd-dev libacl1-dev libattr1-dev libcap-dev
43+
44+
- name: Install Rust toolchain
45+
uses: dtolnay/rust-toolchain@stable
46+
47+
- name: Build manpages (${{ matrix.locale }})
48+
run: |
49+
# Create temporary directory for manpages
50+
MANPAGE_DIR=$(mktemp -d)
51+
echo "MANPAGE_DIR=${MANPAGE_DIR}" >> $GITHUB_ENV
52+
53+
# Set locale for manpage generation
54+
export LANG=${{ matrix.locale }}
55+
56+
# Build and install manpages to temporary directory
57+
make install-manpages DESTDIR="${MANPAGE_DIR}"
58+
59+
- name: Validate manpages with mandoc (${{ matrix.locale }})
60+
run: |
61+
# Find all generated manpages
62+
MANPAGE_PATH="${MANPAGE_DIR}/usr/local/share/man/man1"
63+
64+
# Check if manpages were generated
65+
if [ ! -d "${MANPAGE_PATH}" ]; then
66+
echo "Error: No manpages found at ${MANPAGE_PATH}"
67+
exit 1
68+
fi
69+
70+
# Initialize error tracking
71+
ERRORS_FOUND=0
72+
ERROR_LOG=$(mktemp)
73+
74+
echo "Validating ${{ matrix.locale }} manpages with mandoc..."
75+
echo "=========================================="
76+
77+
# Validate each manpage
78+
for manpage in "${MANPAGE_PATH}"/*.1; do
79+
if [ -f "$manpage" ]; then
80+
filename=$(basename "$manpage")
81+
82+
# Run mandoc lint and capture output (only errors, not style warnings)
83+
if ! mandoc -T lint -W error "$manpage" 2>&1 | tee -a "$ERROR_LOG"; then
84+
echo "Errors found in $filename"
85+
ERRORS_FOUND=1
86+
else
87+
# Check if mandoc produced any output (errors only, not style warnings)
88+
if mandoc -T lint -W error "$manpage" 2>&1 | grep -q .; then
89+
echo "Warnings found in $filename"
90+
ERRORS_FOUND=1
91+
else
92+
echo "$filename is valid"
93+
fi
94+
fi
95+
fi
96+
done
97+
98+
echo ""
99+
echo "=================================="
100+
101+
# Summary and exit
102+
if [ "$ERRORS_FOUND" -eq 1 ]; then
103+
echo "Manpage validation failed. Issues found:"
104+
echo ""
105+
cat "$ERROR_LOG"
106+
exit 1
107+
else
108+
echo "All manpages validated successfully!"
109+
fi

Cargo.lock

Lines changed: 10 additions & 10 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,14 @@ expensive_tests = []
3131
# "test_risky_names" == enable tests that create problematic file names (would make a network share inaccessible to Windows, breaks SVN on Mac OS, etc.)
3232
test_risky_names = []
3333
# * only build `uudoc` when `--feature uudoc` is activated
34-
uudoc = ["dep:clap_complete", "dep:clap_mangen", "dep:fluent-syntax", "dep:zip"]
34+
uudoc = [
35+
"dep:clap_complete",
36+
"dep:clap_mangen",
37+
"dep:fluent-syntax",
38+
"dep:jiff",
39+
"dep:regex",
40+
"dep:zip",
41+
]
3542
## features
3643
## Optional feature for stdbuf
3744
# "feat_external_libstdbuf" == use an external libstdbuf.so for stdbuf instead of embedding it
@@ -471,12 +478,14 @@ uu_checksum_common = { version = "0.7.0", path = "src/uu/checksum_common" }
471478
uutests = { version = "0.7.0", package = "uutests", path = "tests/uutests" }
472479

473480
[dependencies]
481+
clap.workspace = true
474482
clap_complete = { workspace = true, optional = true }
475483
clap_mangen = { workspace = true, optional = true }
476-
clap.workspace = true
477484
fluent-syntax = { workspace = true, optional = true }
478485
itertools.workspace = true
486+
jiff = { workspace = true, optional = true }
479487
phf.workspace = true
488+
regex = { workspace = true, optional = true }
480489
selinux = { workspace = true, optional = true }
481490
textwrap.workspace = true
482491
uucore.workspace = true

GNUmakefile

Lines changed: 14 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -62,44 +62,31 @@ TOYBOX_ROOT := $(BASEDIR)/tmp
6262
TOYBOX_VER := 0.8.12
6363
TOYBOX_SRC := $(TOYBOX_ROOT)/toybox-$(TOYBOX_VER)
6464

65-
#------------------------------------------------------------------------
66-
# Detect the host system.
67-
# On Windows uname -s might return MINGW_NT-* or CYGWIN_NT-*.
68-
# Otherwise let it default to the kernel name returned by uname -s
69-
# (Linux, Darwin, FreeBSD, …).
70-
#------------------------------------------------------------------------
71-
OS ?= $(shell uname -s)
65+
# Detect the target system
66+
# See https://doc.rust-lang.org/beta/rustc/platform-support.html
67+
# todo: support building wasm
68+
OS := $(or $(CARGO_BUILD_TARGET),$(shell rustc --print host-tuple))
7269

7370
# Windows does not allow symlink by default.
7471
# Allow to override LN for AppArmor.
75-
ifneq (,$(findstring _NT,$(OS)))
72+
ifneq (,$(findstring windows,$(OS)))
7673
LN ?= ln -f
7774
endif
7875
LN ?= ln -sf
7976

80-
# Possible programs
81-
PROGS := \
82-
$(shell sed -n '/feat_Tier1 = \[/,/\]/p' Cargo.toml | sed '1d;2d' |tr -d '],"\n')\
83-
$(shell sed -n '/feat_common_core = \[/,/\]/p' Cargo.toml | sed '1d' |tr -d '],"\n')
84-
85-
UNIX_PROGS := \
86-
$(shell sed -n '/feat_require_unix_core = \[/,/\]/p' Cargo.toml | sed '1d' |tr -d '],"\n') \
87-
hostid \
88-
pinky \
89-
stdbuf \
90-
uptime \
91-
users \
92-
who
93-
9477
SELINUX_PROGS := \
9578
chcon \
9679
runcon
9780

9881
$(info Detected OS = $(OS))
9982

100-
ifeq (,$(findstring MINGW,$(OS)))
101-
PROGS += $(UNIX_PROGS)
83+
ifeq (,$(findstring windows,$(OS)))
84+
FEATURE_EXTRACT_UTILS := feat_os_unix
85+
else
86+
FEATURE_EXTRACT_UTILS := feat_Tier1
10287
endif
88+
PROGS := $(shell cargo tree --depth 1 --features $(FEATURE_EXTRACT_UTILS) --format "{p}" --prefix none | sed -E -n 's/^uu_([^ ]+).*/\1/p')
89+
10390
ifeq ($(SELINUX_ENABLED),1)
10491
PROGS += $(SELINUX_PROGS)
10592
endif
@@ -114,7 +101,7 @@ endif
114101
# Programs with usable tests
115102

116103
TESTS := \
117-
$(sort $(filter $(UTILS),$(PROGS) $(UNIX_PROGS) $(SELINUX_PROGS)))
104+
$(sort $(filter $(UTILS),$(PROGS) $(SELINUX_PROGS)))
118105

119106
TEST_NO_FAIL_FAST :=
120107
TEST_SPEC_FEATURE :=
@@ -288,7 +275,7 @@ install: build install-manpages install-completions install-locales
288275
mkdir -p $(INSTALLDIR_BIN)
289276
ifneq (,$(and $(findstring stdbuf,$(UTILS)),$(findstring feat_external_libstdbuf,$(CARGOFLAGS))))
290277
mkdir -p $(DESTDIR)$(LIBSTDBUF_DIR)
291-
ifneq (,$(findstring CYGWIN,$(OS)))
278+
ifneq (,$(findstring cygwin,$(OS)))
292279
$(INSTALL) -m 755 $(BUILDDIR)/deps/stdbuf.dll $(DESTDIR)$(LIBSTDBUF_DIR)/libstdbuf.dll
293280
else
294281
$(INSTALL) -m 755 $(BUILDDIR)/deps/libstdbuf.* $(DESTDIR)$(LIBSTDBUF_DIR)/
@@ -308,7 +295,7 @@ else
308295
endif
309296

310297
uninstall:
311-
ifeq (,$(findstring MINGW,$(OS)))
298+
ifeq (,$(findstring windows,$(OS)))
312299
rm -f $(DESTDIR)$(LIBSTDBUF_DIR)/libstdbuf.*
313300
-rm -d $(DESTDIR)$(LIBSTDBUF_DIR) 2>/dev/null || true
314301
endif

0 commit comments

Comments
 (0)