Ana Guerrero 2024-11-14 15:09:40 +00:00 committed by Git OBS Bridge
commit 845a630375
3 changed files with 55 additions and 0 deletions

48
reproducible.patch Normal file
View File

@ -0,0 +1,48 @@
From 853a860dd9095b7ed2f95d5aac62f8f1dcc0d229 Mon Sep 17 00:00:00 2001
From: "Bernhard M. Wiedemann" <bwiedemann@suse.de>
Date: Wed, 28 Jun 2023 16:48:35 +0200
Subject: [PATCH] Allow to override build date with SOURCE_DATE_EPOCH
in order 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.
Index: shadowsocks-rust-1.20.4/Cargo.toml
===================================================================
--- shadowsocks-rust-1.20.4.orig/Cargo.toml
+++ shadowsocks-rust-1.20.4/Cargo.toml
@@ -281,3 +281,6 @@ byteorder = "1.5"
env_logger = "0.11"
byte_string = "1.0"
tokio = { version = "1", features = ["net", "time", "macros", "io-util"] }
+
+[patch.crates-io]
+build-time = { path="vendor/build-time" }
diff --git a/build-time/src/lib.rs b/build-time/src/lib.rs
index c3484307..7ae9e03e 100644
--- a/vendor/build-time/src/lib.rs
+++ b/vendor/build-time/src/lib.rs
@@ -28,14 +28,18 @@ let local_build_time = build_time_local!("%Y-%m-%dT%H:%M:%S%.f%:z");
```
*/
-use chrono::{DateTime, Local, Utc};
+use chrono::{DateTime, Local, TimeZone, Utc};
use once_cell::sync::Lazy;
use proc_macro::TokenStream;
use proc_macro2::Span;
use quote::quote;
+use std::env;
use syn::{parse_macro_input, LitStr};
-static BUILD_TIME: Lazy<DateTime<Utc>> = Lazy::new(Utc::now);
+static BUILD_TIME: Lazy<DateTime<Utc>> = Lazy::new(|| match env::var("SOURCE_DATE_EPOCH") {
+ Ok(val) => { Utc.timestamp_opt(val.parse::<i64>().unwrap(), 0).unwrap() }
+ Err(_) => Utc::now(),
+ });
/// Build time in UTC.
///

View File

@ -1,3 +1,8 @@
-------------------------------------------------------------------
Wed Nov 13 06:18:54 UTC 2024 - Bernhard Wiedemann <bwiedemann@suse.com>
- Add reproducible.patch to override build date (boo#1047218)
-------------------------------------------------------------------
Thu Sep 12 13:19:28 UTC 2024 - Hillwood Yang <hillwood@opensuse.org>

View File

@ -29,6 +29,8 @@ Source2: %{name}.json
Source3: %{name}-client.service
Source4: %{name}-server.service
Source5: %{name}-manager.service
# PATCH-FIX-UPSTREAM https://github.com/AlephAlpha/build-time/pull/5
Patch0: reproducible.patch
BuildRequires: cargo
BuildRequires: cargo-packaging
BuildRequires: systemd-rpm-macros