summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBernhard M. Wiedemann <githubbmwprimary@lsmod.de>2024-05-16 17:17:58 +0200
committerGitHub <noreply@github.com>2024-05-16 17:17:58 +0200
commitf56844501e12b11a112a986dda9ab06c39cf60a3 (patch)
tree5d89d464a93c07126f4bdfe1074959e97ab58c2a
parent3dca5feeec12dd82e1dbe5f70fa8a22b5a200d20 (diff)
Allow to override build date with SOURCE_DATE_EPOCH (#2202)
to make builds reproducible. See https://reproducible-builds.org/ for why this is good and https://reproducible-builds.org/specs/source-date-epoch/ for the definition of this variable. This patch was done while working on reproducible builds for openSUSE. --------- Co-authored-by: extrawurst <mail@rusticorn.com>
-rw-r--r--CHANGELOG.md3
-rw-r--r--build.rs10
2 files changed, 12 insertions, 1 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md
index b124b554..a5f887c6 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -12,6 +12,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
* respect configuration for remote when fetching (also applies to pulling) [[@cruessler](https://github.com/cruessler)] ([#1093](https://github.com/extrawurst/gitui/issues/1093))
* add `:` character to sign-off trailer to comply with Conventinoal Commits standard [@semioticrobotic](https://github.com/semioticrobotic) ([#2196](https://github.com/extrawurst/gitui/issues/2196))
+### Added
+* support overriding `build_date` for [reproducible builds](https://reproducible-builds.org/) [[@bmwiedemann](https://github.com/bmwiedemann)] ([#2202](https://github.com/extrawurst/gitui/pull/2202))
+
## [0.26.0+1] - 2024-04-14
**0.26.1**
diff --git a/build.rs b/build.rs
index 64470c19..e217973c 100644
--- a/build.rs
+++ b/build.rs
@@ -1,3 +1,5 @@
+use chrono::TimeZone;
+
fn get_git_hash() -> String {
use std::process::Command;
@@ -18,7 +20,13 @@ fn get_git_hash() -> String {
}
fn main() {
- let build_date = chrono::Local::now().date_naive();
+ let now = match std::env::var("SOURCE_DATE_EPOCH") {
+ Ok(val) => chrono::Local
+ .timestamp_opt(val.parse::<i64>().unwrap(), 0)
+ .unwrap(),
+ Err(_) => chrono::Local::now(),
+ };
+ let build_date = now.date_naive();
let build_name = if std::env::var("GITUI_RELEASE").is_ok() {
format!(