Skip to content

Commit 35848e2

Browse files
authored
Merge branch 'main' into mv-folder-containing-symlinks-across-fs
2 parents 91747f8 + 1eea517 commit 35848e2

38 files changed

Lines changed: 916 additions & 368 deletions

.github/workflows/CICD.yml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -814,6 +814,8 @@ jobs:
814814
if: matrix.job.skip-tests != true
815815
shell: bash
816816
run: |
817+
command -v sudo && sudo rm -rf /usr/local/lib/android /usr/share/dotnet # avoid no space left
818+
df -h ||:
817819
## Test individual utilities
818820
${{ steps.vars.outputs.CARGO_CMD }} ${{ steps.vars.outputs.CARGO_CMD_OPTIONS }} test --target=${{ matrix.job.target }} \
819821
${{ matrix.job.cargo-options }} ${{ steps.dep_vars.outputs.CARGO_UTILITY_LIST_OPTIONS }}
@@ -1194,7 +1196,8 @@ jobs:
11941196
- name: build and test all features individually
11951197
shell: bash
11961198
run: |
1197-
command -v sudo && sudo rm -rf /usr/share/dotnet # avoid no space left
1199+
command -v sudo && sudo rm -rf /usr/local/lib/android /usr/share/dotnet # avoid no space left
1200+
df -h ||:
11981201
CARGO_FEATURES_OPTION='--features=${{ matrix.job.features }}' ;
11991202
for f in $(util/show-utils.sh ${CARGO_FEATURES_OPTION})
12001203
do

.github/workflows/GnuTests.yml

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ name: GnuTests
22

33
# spell-checker:ignore (abbrev/names) CodeCov gnulib GnuTests Swatinem
44
# spell-checker:ignore (jargon) submodules devel
5-
# spell-checker:ignore (libs/utils) autopoint chksum dpkg getenforce getlimits gperf lcov libexpect limactl pyinotify setenforce shopt texinfo valgrind libattr libcap taiki-e zstd cpio
5+
# spell-checker:ignore (libs/utils) autopoint chksum dpkg getenforce getlimits gperf lcov libexpect limactl pyinotify setenforce shopt valgrind libattr libcap taiki-e zstd cpio
66
# spell-checker:ignore (options) Ccodegen Coverflow Cpanic Zpanic
77
# spell-checker:ignore (people) Dawid Dziurla * dawidd dtolnay
88
# spell-checker:ignore (vars) FILESET SUBDIRS XPASS
@@ -47,7 +47,6 @@ jobs:
4747
- uses: dtolnay/rust-toolchain@master
4848
with:
4949
toolchain: stable
50-
components: rustfmt
5150
- uses: Swatinem/rust-cache@v2
5251
with:
5352
workspaces: "./uutils -> target"
@@ -105,7 +104,7 @@ jobs:
105104
## Build binaries
106105
cd 'uutils'
107106
env PROFILE=release-small bash util/build-gnu.sh
108-
107+
109108
- name: Save files for faster configure and skipping make
110109
uses: actions/cache/save@v5
111110
if: always() && steps.cache-config-gnu.outputs.cache-hit != 'true'
@@ -211,7 +210,6 @@ jobs:
211210
- uses: dtolnay/rust-toolchain@master
212211
with:
213212
toolchain: stable
214-
components: rustfmt
215213
- uses: Swatinem/rust-cache@v2
216214
with:
217215
workspaces: "./uutils -> target"
@@ -247,7 +245,7 @@ jobs:
247245
- name: Install dependencies in VM
248246
run: |
249247
lima sudo dnf -y update
250-
lima sudo dnf -y install git autoconf autopoint bison texinfo gperf gcc gdb jq libacl-devel libattr-devel libcap-devel libselinux-devel attr rustup clang-devel texinfo-tex automake patch quilt
248+
lima sudo dnf -y install git autoconf autopoint bison gperf gcc gdb jq libacl-devel libattr-devel libcap-devel libselinux-devel attr rustup clang-devel automake patch quilt
251249
lima rustup-init -y --default-toolchain stable
252250
- name: Copy the sources to VM
253251
run: |
@@ -331,7 +329,6 @@ jobs:
331329
- uses: dtolnay/rust-toolchain@master
332330
with:
333331
toolchain: stable
334-
components: rustfmt
335332
- uses: Swatinem/rust-cache@v2
336333
with:
337334
workspaces: "./uutils -> target"

.github/workflows/benchmarks.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ jobs:
2727
- { package: uu_cksum }
2828
- { package: uu_cp }
2929
- { package: uu_cut }
30+
- { package: uu_dd }
3031
- { package: uu_du }
3132
- { package: uu_expand }
3233
- { package: uu_fold }

.github/workflows/openbsd.yml

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ jobs:
4747
prepare: |
4848
# Clean up disk space before installing packages
4949
df -h
50-
rm -rf /usr/share/doc/* /usr/share/man/* /var/cache/* /tmp/* || true
50+
rm -rf /usr/share/relink/* /usr/X11R6/* /usr/share/doc/* /usr/share/man/* || :
5151
pkg_add curl sudo-- jq coreutils bash rust rust-clippy rust-rustfmt llvm--
5252
# Clean up package cache after installation
5353
pkg_delete -a || true
@@ -115,8 +115,6 @@ jobs:
115115
fi
116116
# Clean to avoid to rsync back the files and free up disk space
117117
cargo clean
118-
# Additional cleanup to free disk space
119-
rm -rf ~/.cargo/registry/cache ~/.cargo/git/db || true
120118
if [ -n "\${FAIL_ON_FAULT}" ] && [ -n "\${FAULT}" ]; then exit 1 ; fi
121119
EOF
122120
@@ -144,10 +142,10 @@ jobs:
144142
prepare: |
145143
# Clean up disk space before installing packages
146144
df -h
147-
rm -rf /usr/share/doc/* /usr/share/man/* /var/cache/* /tmp/* || true
145+
rm -rf /usr/share/relink/* /usr/X11R6/* /usr/share/doc/* /usr/share/man/* || :
148146
pkg_add curl gmake sudo-- jq rust llvm--
149147
# Clean up package cache after installation
150-
pkg_delete -a || true
148+
pkg_delete -a || :
151149
df -h
152150
run: |
153151
## Prepare, build, and test
@@ -197,8 +195,6 @@ jobs:
197195
cd "${WORKSPACE}"
198196
unset FAULT
199197
cargo build || FAULT=1
200-
# Clean build artifacts to save disk space before testing
201-
rm -rf target/debug/build target/debug/incremental || true
202198
export PATH=~/.cargo/bin:${PATH}
203199
export RUST_BACKTRACE=1
204200
export CARGO_TERM_COLOR=always
@@ -216,6 +212,5 @@ jobs:
216212
# Clean to avoid to rsync back the files and free up disk space
217213
cargo clean
218214
# Additional cleanup to free disk space
219-
rm -rf ~/.cargo/registry/cache ~/.cargo/git/db target/debug/deps target/release/deps || true
220215
if (test -n "\$FAULT"); then exit 1 ; fi
221216
EOF

.vscode/cspell.dictionaries/workspace.wordlist.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -379,6 +379,7 @@ istrip
379379
litout
380380
opost
381381
parodd
382+
ENOTTY
382383

383384
# translation tests
384385
CLICOLOR

Cargo.lock

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

DEVELOPMENT.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -262,6 +262,7 @@ To generate [gcov-based](https://github.com/mozilla/grcov#example-how-to-generat
262262
export CARGO_INCREMENTAL=0
263263
export RUSTFLAGS="-Cinstrument-coverage -Ccodegen-units=1 -Copt-level=0 -Clink-dead-code -Coverflow-checks=off -Zpanic_abort_tests -Cpanic=abort"
264264
export RUSTDOCFLAGS="-Cpanic=abort"
265+
export RUSTUP_TOOLCHAIN="nightly"
265266
cargo build <options...> # e.g., --features feat_os_unix
266267
cargo test <options...> # e.g., --features feat_os_unix test_pathchk
267268
grcov . -s . --binary-path ./target/debug/ -t html --branch --ignore-not-existing --ignore build.rs --excl-br-line "^\s*((debug_)?assert(_eq|_ne)?\#\[derive\()" -o ./target/debug/coverage/

docs/src/extensions.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -200,3 +200,7 @@ With `-U`/`--no-utf8`, you can interpret input files as 8-bit ASCII rather than
200200
## `expand`
201201

202202
`expand` also offers the `-U`/`--no-utf8` option to interpret input files as 8-bit ASCII instead of UTF-8.
203+
204+
## `install`
205+
206+
`install` offers FreeBSD's `-U` unprivileged option to not change the owner, the group, or the file flags of the destination.

src/uu/cp/benches/cp_bench.rs

Lines changed: 5 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -4,24 +4,11 @@
44
// file that was distributed with this source code.
55

66
use divan::{Bencher, black_box};
7-
use std::fs::{self, File};
8-
use std::io::Write;
7+
use std::fs;
98
use std::path::Path;
109
use tempfile::TempDir;
1110
use uu_cp::uumain;
12-
use uucore::benchmark::{fs_tree, run_util_function};
13-
14-
fn remove_path(path: &Path) {
15-
if !path.exists() {
16-
return;
17-
}
18-
19-
if path.is_dir() {
20-
fs::remove_dir_all(path).unwrap();
21-
} else {
22-
fs::remove_file(path).unwrap();
23-
}
24-
}
11+
use uucore::benchmark::{binary_data, fs_tree, fs_utils, run_util_function};
2512

2613
fn bench_cp_directory<F>(bencher: Bencher, args: &[&str], setup_source: F)
2714
where
@@ -38,7 +25,7 @@ where
3825
let dest_str = dest.to_str().unwrap();
3926

4027
bencher.bench(|| {
41-
remove_path(&dest);
28+
fs_utils::remove_path(&dest);
4229

4330
let mut full_args = Vec::with_capacity(args.len() + 2);
4431
full_args.extend_from_slice(args);
@@ -99,16 +86,13 @@ fn cp_large_file(bencher: Bencher, size_mb: usize) {
9986
let source = temp_dir.path().join("source.bin");
10087
let dest = temp_dir.path().join("dest.bin");
10188

102-
let buffer = vec![b'x'; size_mb * 1024 * 1024];
103-
let mut file = File::create(&source).unwrap();
104-
file.write_all(&buffer).unwrap();
105-
file.sync_all().unwrap();
89+
binary_data::create_file(&source, size_mb, b'x');
10690

10791
let source_str = source.to_str().unwrap();
10892
let dest_str = dest.to_str().unwrap();
10993

11094
bencher.bench(|| {
111-
remove_path(&dest);
95+
fs_utils::remove_path(&dest);
11296

11397
black_box(run_util_function(uumain, &[source_str, dest_str]));
11498
});

src/uu/cp/src/cp.rs

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2510,11 +2510,13 @@ fn copy_file(
25102510
}
25112511

25122512
if options.dereference(source_in_command_line) {
2513-
if let Ok(src) = canonicalize(source, MissingHandling::Normal, ResolveMode::Physical) {
2514-
if src.exists() {
2515-
copy_attributes(&src, dest, &options.attributes)?;
2516-
}
2517-
}
2513+
// Try to canonicalize, but if it fails (e.g., due to inaccessible parent directories),
2514+
// fall back to the original source path
2515+
let src_for_attrs = canonicalize(source, MissingHandling::Normal, ResolveMode::Physical)
2516+
.ok()
2517+
.filter(|p| p.exists())
2518+
.unwrap_or_else(|| source.to_path_buf());
2519+
copy_attributes(&src_for_attrs, dest, &options.attributes)?;
25182520
} else if source_is_stream && !source.exists() {
25192521
// Some stream files may not exist after we have copied it,
25202522
// like anonymous pipes. Thus, we can't really copy its

0 commit comments

Comments
 (0)