From f8c434d21e6f560808f17ef27514c7bf9aa37b3e Mon Sep 17 00:00:00 2001 From: xzfc Date: Tue, 24 Sep 2024 21:17:08 +0000 Subject: [PATCH] chore(deps): update tar to 0.4.42 The new version of tar enables the creation of sparse tar archives by default. The ability to read such sparse entries was added in tar 0.4.6, which has been in use starting from Cargo 0.13 and Rust 1.12. Additionally, `docker cp` doesn't support sparse tar entries in the GNU format. For compatibility with older versions of Rust and Cargo, as well as with `docker cp`, this commit disables sparse archive creation everywhere the `tar::Builder` is used. See #14594. --- Cargo.lock | 4 ++-- Cargo.toml | 2 +- benches/capture/src/main.rs | 1 + build.rs | 1 + crates/cargo-test-support/src/containers.rs | 1 + crates/cargo-test-support/src/registry.rs | 1 + src/cargo/ops/cargo_package.rs | 1 + 7 files changed, 8 insertions(+), 3 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 06c2c5a04536..aa88e03af981 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3371,9 +3371,9 @@ dependencies = [ [[package]] name = "tar" -version = "0.4.41" +version = "0.4.42" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cb797dad5fb5b76fcf519e702f4a589483b5ef06567f160c392832c1f5e44909" +checksum = "4ff6c40d3aedb5e06b57c6f669ad17ab063dd1e63d977c6a88e7f4dfa4f04020" dependencies = [ "filetime", "libc", diff --git a/Cargo.toml b/Cargo.toml index 9682e216dc12..c62dc28df49b 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -94,7 +94,7 @@ shell-escape = "0.1.5" similar = "2.6.0" supports-hyperlinks = "3.0.0" snapbox = { version = "0.6.17", features = ["diff", "dir", "term-svg", "regex", "json"] } -tar = { version = "0.4.41", default-features = false } +tar = { version = "0.4.42", default-features = false } tempfile = "3.10.1" thiserror = "1.0.63" time = { version = "0.3.36", features = ["parsing", "formatting", "serde"] } diff --git a/benches/capture/src/main.rs b/benches/capture/src/main.rs index dcded3b1a3a8..803fc94d80a2 100644 --- a/benches/capture/src/main.rs +++ b/benches/capture/src/main.rs @@ -48,6 +48,7 @@ fn capture(source_root: &Path, dest: &Path, force: bool) { .write(dst, Compression::best()); let mut ar = tar::Builder::new(encoder); ar.mode(tar::HeaderMode::Deterministic); + ar.sparse(false); if let Some(info) = &vcs_info { add_ar_file(&mut ar, &name.join(".cargo_vcs_info.json"), info); } diff --git a/build.rs b/build.rs index 9b1e2662eaf4..962554ecdc5d 100644 --- a/build.rs +++ b/build.rs @@ -24,6 +24,7 @@ fn compress_man() { .write(dst, Compression::best()); let mut ar = tar::Builder::new(encoder); ar.mode(tar::HeaderMode::Deterministic); + ar.sparse(false); let mut add_files = |dir, extension| { let mut files = fs::read_dir(dir) diff --git a/crates/cargo-test-support/src/containers.rs b/crates/cargo-test-support/src/containers.rs index 22fd5fd855e5..4ce6e1d5048c 100644 --- a/crates/cargo-test-support/src/containers.rs +++ b/crates/cargo-test-support/src/containers.rs @@ -122,6 +122,7 @@ impl Container { return; } let mut ar = tar::Builder::new(Vec::new()); + ar.sparse(false); let files = std::mem::replace(&mut self.files, Vec::new()); for mut file in files { ar.append_data(&mut file.header, &file.path, file.contents.as_slice()) diff --git a/crates/cargo-test-support/src/registry.rs b/crates/cargo-test-support/src/registry.rs index 5af522a38cc7..9e0bc9e3ed9a 100644 --- a/crates/cargo-test-support/src/registry.rs +++ b/crates/cargo-test-support/src/registry.rs @@ -1513,6 +1513,7 @@ impl Package { t!(fs::create_dir_all(dst.parent().unwrap())); let f = t!(File::create(&dst)); let mut a = Builder::new(GzEncoder::new(f, Compression::none())); + a.sparse(false); if !self .files diff --git a/src/cargo/ops/cargo_package.rs b/src/cargo/ops/cargo_package.rs index 04708584027f..239e5af2afb2 100644 --- a/src/cargo/ops/cargo_package.rs +++ b/src/cargo/ops/cargo_package.rs @@ -903,6 +903,7 @@ fn tar( // Put all package files into a compressed archive. let mut ar = Builder::new(encoder); + ar.sparse(false); let gctx = ws.gctx(); let base_name = format!("{}-{}", pkg.name(), pkg.version());