summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMazdak Farrokhzad <twingoow@gmail.com>2019-01-31 02:10:42 +0100
committerGitHub <noreply@github.com>2019-01-31 02:10:42 +0100
commit01346563c1d64f666920abc79389d0db5531989e (patch)
tree0c506b83d4b60b591cd72244b94f94489f31fc96
parent7ebb0a8c8ec51c8baa3420ffa0f3621bcec791ca (diff)
parent8db66ca53e9521f5ff52541e5793652688c3c367 (diff)
downloadrust-01346563c1d64f666920abc79389d0db5531989e.tar.gz
Rollup merge of #57920 - euclio:source-date-epoch, r=Mark-Simulacrum
use `SOURCE_DATE_EPOCH` for man page time if set Fixes #57776.
-rw-r--r--src/bootstrap/dist.rs16
1 files changed, 14 insertions, 2 deletions
diff --git a/src/bootstrap/dist.rs b/src/bootstrap/dist.rs
index 116b2720f39..d9bf95d13ac 100644
--- a/src/bootstrap/dist.rs
+++ b/src/bootstrap/dist.rs
@@ -23,7 +23,7 @@ use crate::builder::{Builder, RunConfig, ShouldRun, Step};
use crate::compile;
use crate::tool::{self, Tool};
use crate::cache::{INTERNER, Interned};
-use time;
+use time::{self, Timespec};
pub fn pkgname(builder: &Builder, component: &str) -> String {
if component == "cargo" {
@@ -528,7 +528,19 @@ impl Step for Rustc {
t!(fs::create_dir_all(image.join("share/man/man1")));
let man_src = builder.src.join("src/doc/man");
let man_dst = image.join("share/man/man1");
- let month_year = t!(time::strftime("%B %Y", &time::now()));
+
+ // Reproducible builds: If SOURCE_DATE_EPOCH is set, use that as the time.
+ let time = env::var("SOURCE_DATE_EPOCH")
+ .map(|timestamp| {
+ let epoch = timestamp.parse().map_err(|err| {
+ format!("could not parse SOURCE_DATE_EPOCH: {}", err)
+ }).unwrap();
+
+ time::at(Timespec::new(epoch, 0))
+ })
+ .unwrap_or_else(|_| time::now());
+
+ let month_year = t!(time::strftime("%B %Y", &time));
// don't use our `bootstrap::util::{copy, cp_r}`, because those try
// to hardlink, and we don't want to edit the source templates
for file_entry in builder.read_dir(&man_src) {