Skip to content

Commit e092d75

Browse files
authored
Merge branch 'main' into test/cat-stdbuf-broken-pipe
2 parents 15741ba + daa74e7 commit e092d75

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

83 files changed

+2531
-597
lines changed

.github/workflows/CICD.yml

Lines changed: 75 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -364,29 +364,15 @@ jobs:
364364
test -h /tmp/usr/local/bin/sha512sum
365365
test -h /tmp/usr/local/bin/shake128sum
366366
test -h /tmp/usr/local/bin/shake256sum
367-
- name: "`make install MULTICALL=y`"
367+
- name: "`make install MULTICALL=y LN=ln -svf`"
368368
shell: bash
369369
run: |
370370
set -x
371-
DESTDIR=/tmp/ make PROFILE=release MULTICALL=y install
372-
# Check that the utils are present
373-
test -f /tmp/usr/local/bin/coreutils
374-
# Check that hashsum symlinks are present
375-
test -h /tmp/usr/local/bin/b2sum
376-
test -h /tmp/usr/local/bin/b3sum
377-
test -h /tmp/usr/local/bin/md5sum
378-
test -h /tmp/usr/local/bin/sha1sum
379-
test -h /tmp/usr/local/bin/sha224sum
380-
test -h /tmp/usr/local/bin/sha256sum
381-
test -h /tmp/usr/local/bin/sha3-224sum
382-
test -h /tmp/usr/local/bin/sha3-256sum
383-
test -h /tmp/usr/local/bin/sha3-384sum
384-
test -h /tmp/usr/local/bin/sha3-512sum
385-
test -h /tmp/usr/local/bin/sha384sum
386-
test -h /tmp/usr/local/bin/sha3sum
387-
test -h /tmp/usr/local/bin/sha512sum
388-
test -h /tmp/usr/local/bin/shake128sum
389-
test -h /tmp/usr/local/bin/shake256sum
371+
DESTDIR=/tmp/ make PROFILE=release MULTICALL=y LN="ln -svf" install
372+
# Check that relative symlinks of hashsum are present
373+
[ $(readlink /tmp/usr/local/bin/b2sum) = coreutils ]
374+
[ $(readlink /tmp/usr/local/bin/md5sum) = coreutils ]
375+
[ $(readlink /tmp/usr/local/bin/sha512sum) = coreutils ]
390376
- name: "`make UTILS=XXX`"
391377
shell: bash
392378
run: |
@@ -483,9 +469,13 @@ jobs:
483469
run: |
484470
## `make install`
485471
make install DESTDIR=target/size-release/
486-
make install MULTICALL=y DESTDIR=target/size-multi-release/
472+
make install MULTICALL=y LN="ln -vf" DESTDIR=target/size-multi-release/
487473
# strip the results
488474
strip target/size*/usr/local/bin/*
475+
- name: Test for hardlinks
476+
shell: bash
477+
run: |
478+
[ $(stat -c %i target/size-multi-release/usr/local/bin/cp) = $(stat -c %i target/size-multi-release/usr/local/bin/coreutils) ]
489479
- name: Compute uutil release sizes
490480
shell: bash
491481
run: |
@@ -1199,11 +1189,14 @@ jobs:
11991189

12001190
test_separately:
12011191
name: Separate Builds
1202-
runs-on: ${{ matrix.os }}
1192+
runs-on: ${{ matrix.job.os }}
12031193
strategy:
12041194
fail-fast: false
12051195
matrix:
1206-
os: [ubuntu-latest, macos-latest, windows-latest]
1196+
job:
1197+
- { os: ubuntu-latest , features: feat_os_unix }
1198+
- { os: macos-latest , features: feat_os_macos }
1199+
- { os: windows-latest , features: feat_os_windows }
12071200
steps:
12081201
- uses: actions/checkout@v5
12091202
with:
@@ -1213,7 +1206,8 @@ jobs:
12131206
- name: build and test all programs individually
12141207
shell: bash
12151208
run: |
1216-
for f in $(util/show-utils.sh)
1209+
CARGO_FEATURES_OPTION='--features=${{ matrix.job.features }}' ;
1210+
for f in $(util/show-utils.sh ${CARGO_FEATURES_OPTION})
12171211
do
12181212
echo "Building and testing $f"
12191213
cargo test -p "uu_$f" || exit 1
@@ -1222,12 +1216,14 @@ jobs:
12221216
test_all_features:
12231217
name: Test all features separately
12241218
needs: [ min_version, deps ]
1225-
runs-on: ${{ matrix.os }}
1219+
runs-on: ${{ matrix.job.os }}
12261220
strategy:
12271221
fail-fast: false
12281222
matrix:
1229-
os: [ubuntu-latest, macos-latest]
1230-
# windows-latest - https://github.com/uutils/coreutils/issues/7044
1223+
job:
1224+
- { os: ubuntu-latest , features: feat_os_unix }
1225+
- { os: macos-latest , features: feat_os_macos }
1226+
# - { os: windows-latest , features: feat_os_windows } https://github.com/uutils/coreutils/issues/7044
12311227
steps:
12321228
- uses: actions/checkout@v5
12331229
with:
@@ -1237,7 +1233,8 @@ jobs:
12371233
- name: build and test all features individually
12381234
shell: bash
12391235
run: |
1240-
for f in $(util/show-utils.sh)
1236+
CARGO_FEATURES_OPTION='--features=${{ matrix.job.features }}' ;
1237+
for f in $(util/show-utils.sh ${CARGO_FEATURES_OPTION})
12411238
do
12421239
echo "Running tests with --features=$f and --no-default-features"
12431240
cargo test --features=$f --no-default-features
@@ -1280,6 +1277,56 @@ jobs:
12801277
- name: Lint with SELinux
12811278
run: lima bash -c "cd work && cargo clippy --all-targets --features 'feat_selinux' -- -D warnings"
12821279

1280+
test_selinux_stubs:
1281+
name: Build/SELinux-Stubs (Non-Linux)
1282+
needs: [ min_version, deps ]
1283+
runs-on: ${{ matrix.job.os }}
1284+
strategy:
1285+
fail-fast: false
1286+
matrix:
1287+
job:
1288+
- { os: macos-latest , features: feat_os_macos }
1289+
- { os: windows-latest , features: feat_os_windows }
1290+
1291+
steps:
1292+
- uses: actions/checkout@v5
1293+
with:
1294+
persist-credentials: false
1295+
- uses: dtolnay/rust-toolchain@stable
1296+
- uses: Swatinem/rust-cache@v2
1297+
- name: Build SELinux utilities as stubs
1298+
run: cargo build -p uu_chcon -p uu_runcon
1299+
- name: Verify stub binaries exist
1300+
shell: bash
1301+
run: |
1302+
if [ "${{ runner.os }}" = "Windows" ]; then
1303+
test -f target/debug/chcon.exe || exit 1
1304+
test -f target/debug/runcon.exe || exit 1
1305+
else
1306+
test -f target/debug/chcon || exit 1
1307+
test -f target/debug/runcon || exit 1
1308+
fi
1309+
- name: Verify workspace builds with stubs
1310+
run: cargo build --features ${{ matrix.job.features }}
1311+
1312+
test_safe_traversal:
1313+
name: Safe Traversal Security Check
1314+
runs-on: ubuntu-latest
1315+
needs: [ min_version, deps ]
1316+
1317+
steps:
1318+
- uses: actions/checkout@v5
1319+
with:
1320+
persist-credentials: false
1321+
- uses: dtolnay/rust-toolchain@stable
1322+
- uses: Swatinem/rust-cache@v2
1323+
- name: Install strace
1324+
run: sudo apt-get update && sudo apt-get install -y strace
1325+
- name: Build utilities with safe traversal
1326+
run: cargo build --release -p uu_rm -p uu_chmod -p uu_chown -p uu_chgrp -p uu_mv -p uu_du
1327+
- name: Run safe traversal verification
1328+
run: ./util/check-safe-traversal.sh
1329+
12831330
benchmarks:
12841331
name: Run benchmarks (CodSpeed)
12851332
runs-on: ubuntu-latest

.github/workflows/code-quality.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,7 @@ jobs:
110110
## Install/setup prerequisites
111111
case '${{ matrix.job.os }}' in
112112
ubuntu-*)
113+
sudo apt-get -y update
113114
# selinux and systemd headers needed to enable all features
114115
sudo apt-get -y install libselinux1-dev libsystemd-dev
115116
;;

.github/workflows/l10n.yml

Lines changed: 81 additions & 119 deletions
Original file line numberDiff line numberDiff line change
@@ -1147,146 +1147,108 @@ jobs:
11471147
run: |
11481148
bash util/test_locale_regression.sh
11491149
1150-
l10n_locale_embedding_regression_test:
1151-
name: L10n/Locale Embedding Regression Test
1150+
l10n_locale_embedding_cat:
1151+
name: L10n/Locale Embedding - Cat Utility
11521152
runs-on: ubuntu-latest
1153-
env:
1154-
SCCACHE_GHA_ENABLED: "true"
1155-
RUSTC_WRAPPER: "sccache"
11561153
steps:
11571154
- uses: actions/checkout@v5
11581155
with:
11591156
persist-credentials: false
11601157
- uses: dtolnay/rust-toolchain@stable
11611158
- uses: Swatinem/rust-cache@v2
1162-
- name: Run sccache-cache
1163-
uses: mozilla-actions/[email protected]
1164-
- name: Install/setup prerequisites
1165-
shell: bash
1166-
run: |
1167-
## Install/setup prerequisites
1168-
sudo apt-get -y update ; sudo apt-get -y install libselinux1-dev build-essential
1169-
- name: Build binaries for locale embedding test
1170-
shell: bash
1171-
run: |
1172-
## Build individual utilities and multicall binary for locale embedding test
1173-
echo "Building binaries with different locale embedding configurations..."
1174-
mkdir -p target
1175-
1176-
# Build cat utility with targeted locale embedding
1177-
echo "Building cat utility with targeted locale embedding..."
1178-
echo "cat" > target/uucore_target_util.txt
1179-
cargo build -p uu_cat --release
1180-
1181-
# Build ls utility with targeted locale embedding
1182-
echo "Building ls utility with targeted locale embedding..."
1183-
echo "ls" > target/uucore_target_util.txt
1184-
cargo build -p uu_ls --release
1185-
1186-
# Build multicall binary (should have all locales)
1187-
echo "Building multicall binary (should have all locales)..."
1188-
echo "multicall" > target/uucore_target_util.txt
1189-
cargo build --release
1190-
1191-
echo "✓ All binaries built successfully"
1192-
env:
1193-
RUST_BACKTRACE: "1"
1194-
1195-
- name: Analyze embedded locale files
1196-
shell: bash
1159+
with:
1160+
# Use different cache key for each build to avoid conflicts
1161+
key: cat-locale-embedding
1162+
- name: Install prerequisites
1163+
run: sudo apt-get -y update && sudo apt-get -y install libselinux1-dev build-essential
1164+
- name: Build cat with targeted locale embedding
1165+
run: UUCORE_TARGET_UTIL=cat cargo build -p uu_cat --release
1166+
- name: Verify cat locale count
11971167
run: |
1198-
## Extract and analyze .ftl files embedded in each binary
1199-
echo "=== Embedded Locale File Analysis ==="
1200-
1201-
# Analyze cat binary
1202-
echo "--- cat binary embedded .ftl files ---"
1203-
cat_ftl_files=$(strings target/release/cat | grep -o "[a-z_][a-z_]*/en-US\.ftl" | sort | uniq)
1204-
cat_locales=$(echo "$cat_ftl_files" | wc -l)
1205-
if [ -n "$cat_ftl_files" ]; then
1206-
echo "$cat_ftl_files"
1207-
else
1208-
echo "(no locale keys found)"
1209-
fi
1210-
echo "Total: $cat_locales files"
1211-
echo
1212-
1213-
# Analyze ls binary
1214-
echo "--- ls binary embedded .ftl files ---"
1215-
ls_ftl_files=$(strings target/release/ls | grep -o "[a-z_][a-z_]*/en-US\.ftl" | sort | uniq)
1216-
ls_locales=$(echo "$ls_ftl_files" | wc -l)
1217-
if [ -n "$ls_ftl_files" ]; then
1218-
echo "$ls_ftl_files"
1219-
else
1220-
echo "(no locale keys found)"
1168+
locale_file=$(find target/release/build -name "embedded_locales.rs" | head -1)
1169+
if [ -z "$locale_file" ]; then
1170+
echo "ERROR: Could not find embedded_locales.rs"
1171+
exit 1
12211172
fi
1222-
echo "Total: $ls_locales files"
1223-
echo
1224-
1225-
# Analyze multicall binary
1226-
echo "--- multicall binary embedded .ftl files (first 10) ---"
1227-
multi_ftl_files=$(strings target/release/coreutils | grep -o "[a-z_][a-z_]*/en-US\.ftl" | sort | uniq)
1228-
multi_locales=$(echo "$multi_ftl_files" | wc -l)
1229-
if [ -n "$multi_ftl_files" ]; then
1230-
echo "$multi_ftl_files" | head -10
1231-
echo "... (showing first 10 of $multi_locales total files)"
1173+
locale_count=$(grep -c '/en-US\.ftl' "$locale_file")
1174+
echo "Cat binary has $locale_count embedded locales"
1175+
if [ "$locale_count" -le 5 ]; then
1176+
echo "✓ SUCCESS: Cat uses targeted locale embedding ($locale_count files)"
12321177
else
1233-
echo "(no locale keys found)"
1178+
echo "✗ FAILURE: Cat has too many locale files ($locale_count). Expected ≤ 5"
1179+
exit 1
12341180
fi
1235-
echo
1236-
1237-
# Store counts for validation step
1238-
echo "cat_locales=$cat_locales" >> $GITHUB_ENV
1239-
echo "ls_locales=$ls_locales" >> $GITHUB_ENV
1240-
echo "multi_locales=$multi_locales" >> $GITHUB_ENV
12411181
1242-
- name: Validate cat binary locale embedding
1243-
shell: bash
1182+
l10n_locale_embedding_ls:
1183+
name: L10n/Locale Embedding - Ls Utility
1184+
runs-on: ubuntu-latest
1185+
steps:
1186+
- uses: actions/checkout@v5
1187+
with:
1188+
persist-credentials: false
1189+
- uses: dtolnay/rust-toolchain@stable
1190+
- uses: Swatinem/rust-cache@v2
1191+
with:
1192+
# Use different cache key for each build to avoid conflicts
1193+
key: ls-locale-embedding
1194+
- name: Install prerequisites
1195+
run: sudo apt-get -y update && sudo apt-get -y install libselinux1-dev build-essential
1196+
- name: Build ls with targeted locale embedding
1197+
run: UUCORE_TARGET_UTIL=ls cargo build -p uu_ls --release
1198+
- name: Verify ls locale count
12441199
run: |
1245-
## Validate that cat binary only embeds its own locale files
1246-
echo "Validating cat binary locale embedding..."
1247-
if [ "$cat_locales" -le 5 ]; then
1248-
echo "✓ SUCCESS: cat binary uses targeted locale embedding ($cat_locales files)"
1249-
else
1250-
echo "✗ FAILURE: cat binary has too many embedded locale files ($cat_locales). Expected ≤ 5."
1251-
echo "This indicates LOCALE EMBEDDING REGRESSION - all locales are being embedded instead of just the target utility's locale."
1252-
echo "The optimization is not working correctly!"
1200+
locale_file=$(find target/release/build -name "embedded_locales.rs" | head -1)
1201+
if [ -z "$locale_file" ]; then
1202+
echo "ERROR: Could not find embedded_locales.rs"
12531203
exit 1
12541204
fi
1255-
1256-
- name: Validate ls binary locale embedding
1257-
shell: bash
1258-
run: |
1259-
## Validate that ls binary only embeds its own locale files
1260-
echo "Validating ls binary locale embedding..."
1261-
if [ "$ls_locales" -le 5 ]; then
1262-
echo "✓ SUCCESS: ls binary uses targeted locale embedding ($ls_locales files)"
1205+
locale_count=$(grep -c '/en-US\.ftl' "$locale_file")
1206+
echo "Ls binary has $locale_count embedded locales"
1207+
if [ "$locale_count" -le 5 ]; then
1208+
echo "✓ SUCCESS: Ls uses targeted locale embedding ($locale_count files)"
12631209
else
1264-
echo "✗ FAILURE: ls binary has too many embedded locale files ($ls_locales). Expected ≤ 5."
1265-
echo "This indicates LOCALE EMBEDDING REGRESSION - all locales are being embedded instead of just the target utility's locale."
1266-
echo "The optimization is not working correctly!"
1210+
echo "✗ FAILURE: Ls has too many locale files ($locale_count). Expected ≤ 5"
12671211
exit 1
12681212
fi
12691213
1270-
- name: Validate multicall binary locale embedding
1271-
shell: bash
1214+
l10n_locale_embedding_multicall:
1215+
name: L10n/Locale Embedding - Multicall Binary
1216+
runs-on: ubuntu-latest
1217+
steps:
1218+
- uses: actions/checkout@v5
1219+
with:
1220+
persist-credentials: false
1221+
- uses: dtolnay/rust-toolchain@stable
1222+
- uses: Swatinem/rust-cache@v2
1223+
with:
1224+
# Use different cache key for each build to avoid conflicts
1225+
key: multicall-locale-embedding
1226+
- name: Install prerequisites
1227+
run: sudo apt-get -y update && sudo apt-get -y install libselinux1-dev build-essential
1228+
- name: Build multicall binary with all locales
1229+
run: cargo build --release
1230+
- name: Verify multicall locale count
12721231
run: |
1273-
## Validate that multicall binary embeds all utility locale files
1274-
echo "Validating multicall binary locale embedding..."
1275-
if [ "$multi_locales" -ge 80 ]; then
1276-
echo "✓ SUCCESS: multicall binary has all locales ($multi_locales files)"
1232+
locale_file=$(find target/release/build -name "embedded_locales.rs" | head -1)
1233+
if [ -z "$locale_file" ]; then
1234+
echo "ERROR: Could not find embedded_locales.rs"
1235+
exit 1
1236+
fi
1237+
locale_count=$(grep -c '/en-US\.ftl' "$locale_file")
1238+
echo "Multicall binary has $locale_count embedded locales"
1239+
echo "First 10 locales:"
1240+
grep -o '[a-z_][a-z_0-9]*/en-US\.ftl' "$locale_file" | head -10
1241+
if [ "$locale_count" -ge 80 ]; then
1242+
echo "✓ SUCCESS: Multicall has all locales ($locale_count files)"
12771243
else
1278-
echo "✗ FAILURE: multicall binary has too few embedded locale files ($multi_locales). Expected ≥ 80."
1279-
echo "This indicates the multicall binary is not getting all required locales."
1244+
echo "✗ FAILURE: Multicall has too few locale files ($locale_count). Expected ≥ 80"
12801245
exit 1
12811246
fi
12821247
1283-
- name: Finalize locale embedding tests
1284-
shell: bash
1285-
run: |
1286-
## Clean up and report overall test results
1287-
rm -f test.txt target/uucore_target_util.txt
1288-
echo "✓ All locale embedding regression tests passed"
1289-
echo "Summary:"
1290-
echo " - cat binary: $cat_locales locale files (targeted embedding)"
1291-
echo " - ls binary: $ls_locales locale files (targeted embedding)"
1292-
echo " - multicall binary: $multi_locales locale files (full embedding)"
1248+
l10n_locale_embedding_regression_test:
1249+
name: L10n/Locale Embedding Regression Test
1250+
runs-on: ubuntu-latest
1251+
needs: [l10n_locale_embedding_cat, l10n_locale_embedding_ls, l10n_locale_embedding_multicall]
1252+
steps:
1253+
- name: All locale embedding tests passed
1254+
run: echo "✓ All locale embedding tests passed successfully"

0 commit comments

Comments
 (0)