Skip to content

Commit 9f04c18

Browse files
authored
Rollup merge of #57920 - euclio:source-date-epoch, r=Mark-Simulacrum
use `SOURCE_DATE_EPOCH` for man page time if set Fixes #57776.
2 parents b93cbfe + 8db66ca commit 9f04c18

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

src/bootstrap/dist.rs

+14-2
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ use crate::builder::{Builder, RunConfig, ShouldRun, Step};
2323
use crate::compile;
2424
use crate::tool::{self, Tool};
2525
use crate::cache::{INTERNER, Interned};
26-
use time;
26+
use time::{self, Timespec};
2727

2828
pub fn pkgname(builder: &Builder, component: &str) -> String {
2929
if component == "cargo" {
@@ -528,7 +528,19 @@ impl Step for Rustc {
528528
t!(fs::create_dir_all(image.join("share/man/man1")));
529529
let man_src = builder.src.join("src/doc/man");
530530
let man_dst = image.join("share/man/man1");
531-
let month_year = t!(time::strftime("%B %Y", &time::now()));
531+
532+
// Reproducible builds: If SOURCE_DATE_EPOCH is set, use that as the time.
533+
let time = env::var("SOURCE_DATE_EPOCH")
534+
.map(|timestamp| {
535+
let epoch = timestamp.parse().map_err(|err| {
536+
format!("could not parse SOURCE_DATE_EPOCH: {}", err)
537+
}).unwrap();
538+
539+
time::at(Timespec::new(epoch, 0))
540+
})
541+
.unwrap_or_else(|_| time::now());
542+
543+
let month_year = t!(time::strftime("%B %Y", &time));
532544
// don't use our `bootstrap::util::{copy, cp_r}`, because those try
533545
// to hardlink, and we don't want to edit the source templates
534546
for file_entry in builder.read_dir(&man_src) {

0 commit comments

Comments
 (0)