@@ -501,28 +501,7 @@ fn tar(
501501 config
502502 . shell ( )
503503 . verbose ( |shell| shell. status ( "Archiving" , & rel_str) ) ?;
504- // The `tar::Builder` type by default will build GNU archives, but
505- // unfortunately we force it here to use UStar archives instead. The
506- // UStar format has more limitations on the length of path name that it
507- // can encode, so it's not quite as nice to use.
508- //
509- // Older cargos, however, had a bug where GNU archives were interpreted
510- // as UStar archives. This bug means that if we publish a GNU archive
511- // which has fully filled out metadata it'll be corrupt when unpacked by
512- // older cargos.
513- //
514- // Hopefully in the future after enough cargos have been running around
515- // with the bugfixed tar-rs library we'll be able to switch this over to
516- // GNU archives, but for now we'll just say that you can't encode paths
517- // in archives that are *too* long.
518- //
519- // For an instance of this in the wild, use the tar-rs 0.3.3 library to
520- // unpack the selectors 0.4.0 crate on crates.io. Either that or take a
521- // look at rust-lang/cargo#2326.
522- let mut header = Header :: new_ustar ( ) ;
523- header
524- . set_path ( & ar_path)
525- . chain_err ( || format ! ( "failed to add to archive: `{}`" , rel_str) ) ?;
504+ let mut header = Header :: new_gnu ( ) ;
526505 match contents {
527506 FileContents :: OnDisk ( disk_path) => {
528507 let mut file = File :: open ( & disk_path) . chain_err ( || {
@@ -533,9 +512,10 @@ fn tar(
533512 } ) ?;
534513 header. set_metadata ( & metadata) ;
535514 header. set_cksum ( ) ;
536- ar. append ( & header, & mut file) . chain_err ( || {
537- format ! ( "could not archive source file `{}`" , disk_path. display( ) )
538- } ) ?;
515+ ar. append_data ( & mut header, & ar_path, & mut file)
516+ . chain_err ( || {
517+ format ! ( "could not archive source file `{}`" , disk_path. display( ) )
518+ } ) ?;
539519 }
540520 FileContents :: Generated ( generated_kind) => {
541521 let contents = match generated_kind {
@@ -553,7 +533,7 @@ fn tar(
553533 ) ;
554534 header. set_size ( contents. len ( ) as u64 ) ;
555535 header. set_cksum ( ) ;
556- ar. append ( & header, contents. as_bytes ( ) )
536+ ar. append_data ( & mut header, & ar_path , contents. as_bytes ( ) )
557537 . chain_err ( || format ! ( "could not archive source file `{}`" , rel_str) ) ?;
558538 }
559539 }
0 commit comments