File tree Expand file tree Collapse file tree 2 files changed +7
-14
lines changed
src/cargo/ops/cargo_package Expand file tree Collapse file tree 2 files changed +7
-14
lines changed Original file line number Diff line number Diff line change @@ -917,8 +917,12 @@ fn tar(
917917 header. set_entry_type ( EntryType :: file ( ) ) ;
918918 header. set_mode ( 0o644 ) ;
919919 header. set_size ( contents. len ( ) as u64 ) ;
920- // use something nonzero to avoid rust-lang/cargo#9512
921- header. set_mtime ( 1 ) ;
920+ // We need to have the same DETERMINISTIC_TIMESTAMP for generated files
921+ // https://github.com/alexcrichton/tar-rs/blob/d0261f1f6cc959ba0758e7236b3fd81e90dd1dc6/src/header.rs#L18-L24
922+ // Unfortunately tar-rs doesn't expose that so we harcode the timestamp here.
923+ // Hardcoded value be removed once alexcrichton/tar-rs#420 is merged and released.
924+ // See also rust-lang/cargo#16237
925+ header. set_mtime ( 1153704088 ) ;
922926 header. set_cksum ( ) ;
923927 ar. append_data ( & mut header, & ar_path, contents. as_bytes ( ) )
924928 . with_context ( || format ! ( "could not archive source file `{}`" , rel_str) ) ?;
Original file line number Diff line number Diff line change @@ -3171,18 +3171,7 @@ fn reproducible_output() {
31713171 println ! ( "checking {:?}" , ent. path( ) ) ;
31723172 let header = ent. header ( ) ;
31733173 assert_eq ! ( header. mode( ) . unwrap( ) , 0o644 ) ;
3174- assert ! ( header. mtime( ) . unwrap( ) != 0 ) ;
3175- // Generated files do not have deterministic timestamp (yet).
3176- let path = ent. path ( ) . unwrap ( ) ;
3177- let file_name = path. file_name ( ) . unwrap ( ) . to_str ( ) . unwrap ( ) ;
3178- if [ "Cargo.toml" , "Cargo.lock" , ".cargo_vcs_info.json" ]
3179- . into_iter ( )
3180- . any ( |f| f == file_name)
3181- {
3182- assert ! ( header. mtime( ) . unwrap( ) != DETERMINISTIC_TIMESTAMP ) ;
3183- } else {
3184- assert ! ( header. mtime( ) . unwrap( ) == DETERMINISTIC_TIMESTAMP ) ;
3185- }
3174+ assert ! ( header. mtime( ) . unwrap( ) == DETERMINISTIC_TIMESTAMP ) ;
31863175 assert_eq ! ( header. username( ) . unwrap( ) . unwrap( ) , "" ) ;
31873176 assert_eq ! ( header. groupname( ) . unwrap( ) . unwrap( ) , "" ) ;
31883177 }
You can’t perform that action at this time.
0 commit comments