Skip to content

Commit cbc064b

Browse files
committedMar 28, 2023
Auto merge of rust-lang#109577 - jonhoo:long-tar-names, r=Mark-Simulacrum
[rust-installer] Allow long link names in tar files Without this, users trying to run `x.py dist` under a sufficiently long path run into problems when we build the resulting tarballs due to length limits in the original tar spec. The error looks like: Finished release [optimized + debuginfo] target(s) in 0.34s Copying stage0 std from stage0 (x86_64-unknown-linux-gnu -> x86_64-unknown-linux-gnu / x86_64-unknown-linux-musl) Building stage0 tool rust-installer (x86_64-unknown-linux-gnu) Finished release [optimized] target(s) in 0.35s Dist rust-std-1.67.1-x86_64-unknown-linux-musl Error: failed to generate installer Caused by: 0: failed to tar file '/home/AAAAAAAAAAAAAA/BBBBBB/CCCC/DDD/EEEEE/FFFFFFFFFFFF/GGGGGGGGGGGGGGGG/HHHHHHHHHH/IIIIIIIIIIIIIII/JJJJJ/KKKKKKK/src/build/tmp/tarball/rust-std/x86_64-unknown-linux-musl/rust-std-1.67.1-x86_64-unknown-linux-musl/rust-std-x86_64-unknown-linux-musl/lib/rustlib/x86_64-unknown-linux-musl/lib/self-contained/libc.a' 1: provided value is too long when setting link name for Build completed unsuccessfully in 0:00:03 The fix is to make use of the widely-supported GNU tar extensions which lift this restriction. Switching to [`tar::Builder::append_link`] takes care of that for us. See also alexcrichton/tar-rs#273. [`tar::Builder::append_link`]: https://docs.rs/tar/0.4.38/tar/struct.Builder.html#method.append_link
2 parents 5ce70ed + 4d55010 commit cbc064b

File tree

2 files changed

+3
-4
lines changed

2 files changed

+3
-4
lines changed
 

‎src/tools/rust-installer/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ path = "src/main.rs"
1313
anyhow = "1.0.19"
1414
flate2 = "1.0.1"
1515
rayon = "1.0"
16-
tar = "0.4.13"
16+
tar = "0.4.38"
1717
walkdir = "2"
1818
xz2 = "0.1.4"
1919
num_cpus = "1"

‎src/tools/rust-installer/src/tarballer.rs

+2-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use anyhow::{bail, Context, Result};
22
use std::fs::{read_link, symlink_metadata};
3-
use std::io::{empty, BufWriter, Write};
3+
use std::io::{BufWriter, Write};
44
use std::path::Path;
55
use tar::{Builder, Header};
66
use walkdir::WalkDir;
@@ -93,8 +93,7 @@ fn append_path<W: Write>(builder: &mut Builder<W>, src: &Path, path: &String) ->
9393
header.set_metadata(&stat);
9494
if stat.file_type().is_symlink() {
9595
let link = read_link(src)?;
96-
header.set_link_name(&link)?;
97-
builder.append_data(&mut header, path, &mut empty())?;
96+
builder.append_link(&mut header, path, &link)?;
9897
} else {
9998
if cfg!(windows) {
10099
// Windows doesn't really have a mode, so `tar` never marks files executable.

0 commit comments

Comments
 (0)