diff --git a/mage.changes b/mage.changes index a4b2573..8a204e1 100644 --- a/mage.changes +++ b/mage.changes @@ -1,3 +1,8 @@ +------------------------------------------------------------------- +Sat Feb 15 04:06:34 UTC 2025 - Bernhard Wiedemann + +- Add reproducible.patch to override build date (boo#1047218) + ------------------------------------------------------------------- Sat Jan 6 16:23:45 UTC 2024 - Dirk Müller diff --git a/mage.spec b/mage.spec index c3f7e54..da255e6 100644 --- a/mage.spec +++ b/mage.spec @@ -23,6 +23,7 @@ Summary: A make-like build tool using Go License: Apache-2.0 URL: https://github.com/magefile/mage Source: https://github.com/magefile/mage/archive/refs/tags/v%{version}.tar.gz +Patch0: https://github.com/magefile/mage/pull/474.patch#/reproducible.patch BuildRequires: go BuildRequires: golang-packaging BuildRequires: golang(API) >= 1.12 @@ -32,7 +33,7 @@ BuildRequires: golang(API) >= 1.12 Mage is a make-like build tool using Go. You write plain-old go functions, and Mage automatically uses them as Makefile-like runnable targets. %prep -%setup -q +%autosetup -p1 %build if test -z "$GOPATH"; then diff --git a/reproducible.patch b/reproducible.patch new file mode 100644 index 0000000..5ec6df7 --- /dev/null +++ b/reproducible.patch @@ -0,0 +1,42 @@ +From fbeaad11b0452a336cc23545aee709e811fdb9cc Mon Sep 17 00:00:00 2001 +From: "Bernhard M. Wiedemann" +Date: Sun, 25 Jun 2023 09:33:48 +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. +--- + magefile.go | 9 +++++++++ + 1 file changed, 9 insertions(+) + +diff --git a/magefile.go b/magefile.go +index c08ffa37..ab91e4fe 100644 +--- a/magefile.go ++++ b/magefile.go +@@ -14,6 +14,7 @@ import ( + "path/filepath" + "regexp" + "runtime" ++ "strconv" + "strings" + "time" + +@@ -100,6 +101,14 @@ func Clean() error { + + func flags() string { + timestamp := time.Now().Format(time.RFC3339) ++ source_date_epoch := os.Getenv("SOURCE_DATE_EPOCH") ++ if source_date_epoch != "" { ++ sde, err := strconv.ParseInt(source_date_epoch, 10, 64) ++ if err != nil { ++ panic(fmt.Sprintf("Invalid SOURCE_DATE_EPOCH: %s", err)) ++ } ++ timestamp = time.Unix(sde, 0).UTC().Format(time.RFC3339) ++ } + hash := hash() + tag := tag() + if tag == "" {