diff --git a/reproducible.patch b/reproducible.patch new file mode 100644 index 0000000..d494259 --- /dev/null +++ b/reproducible.patch @@ -0,0 +1,48 @@ +From 853a860dd9095b7ed2f95d5aac62f8f1dcc0d229 Mon Sep 17 00:00:00 2001 +From: "Bernhard M. Wiedemann" +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> = Lazy::new(Utc::now); ++static BUILD_TIME: Lazy> = Lazy::new(|| match env::var("SOURCE_DATE_EPOCH") { ++ Ok(val) => { Utc.timestamp_opt(val.parse::().unwrap(), 0).unwrap() } ++ Err(_) => Utc::now(), ++ }); + + /// Build time in UTC. + /// diff --git a/shadowsocks-rust.changes b/shadowsocks-rust.changes index 137cd11..4b0e13f 100644 --- a/shadowsocks-rust.changes +++ b/shadowsocks-rust.changes @@ -1,3 +1,8 @@ +------------------------------------------------------------------- +Wed Nov 13 06:18:54 UTC 2024 - Bernhard Wiedemann + +- Add reproducible.patch to override build date (boo#1047218) + ------------------------------------------------------------------- Thu Sep 12 13:19:28 UTC 2024 - Hillwood Yang diff --git a/shadowsocks-rust.spec b/shadowsocks-rust.spec index cf6ff48..e120b34 100644 --- a/shadowsocks-rust.spec +++ b/shadowsocks-rust.spec @@ -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