From d092e23a0003ff8a0b6f595422fc0342d80b3ef63c77cb52eace1ee874e56177 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adrian=20Schr=C3=B6ter?= Date: Tue, 25 Feb 2025 17:52:19 +0100 Subject: [PATCH] Sync from SUSE:SLFO:Main elemental-toolkit revision 820c18cce5a95a75f9a0e4af3dffc292 --- elemental-toolkit.changes | 5 ++++ elemental-toolkit.spec | 3 ++- reproducible-tar.patch | 48 +++++++++++++++++++++++++++++++++++++++ 3 files changed, 55 insertions(+), 1 deletion(-) create mode 100644 reproducible-tar.patch diff --git a/elemental-toolkit.changes b/elemental-toolkit.changes index 1736ec6..909b9d1 100644 --- a/elemental-toolkit.changes +++ b/elemental-toolkit.changes @@ -1,3 +1,8 @@ +------------------------------------------------------------------- +Thu Feb 20 09:14:15 UTC 2025 - Bernhard Wiedemann + +- Add reproducible-tar.patch for reproducible builds (boo#1237212, jsc#PED-12137) + ------------------------------------------------------------------- Wed Oct 2 12:03:00 UTC 2024 - Elemental Bot diff --git a/elemental-toolkit.spec b/elemental-toolkit.spec index 4271286..5009747 100644 --- a/elemental-toolkit.spec +++ b/elemental-toolkit.spec @@ -27,6 +27,7 @@ License: Apache-2.0 Group: System/Management Url: https://github.com/rancher/elemental-toolkit Source: %{name}.tar.xz +Patch0: reproducible-tar.patch Requires: dosfstools Requires: e2fsprogs @@ -67,7 +68,7 @@ This package provides a universal command line client to access Elemental functionality %prep -%setup -q -n %{name} +%autosetup -n %{name} -p1 %build diff --git a/reproducible-tar.patch b/reproducible-tar.patch new file mode 100644 index 0000000..49b2f14 --- /dev/null +++ b/reproducible-tar.patch @@ -0,0 +1,48 @@ +From 65c56676008c20b3ad4a286e9f69e40b8b8b45c4 Mon Sep 17 00:00:00 2001 +From: "Bernhard M. Wiedemann" +Date: Mon, 2 Dec 2024 13:25:19 +0100 +Subject: [PATCH 1/2] Use GNU tar to support --sort + +--- + Dockerfile | 3 +++ + 1 file changed, 3 insertions(+) + +diff --git a/Dockerfile b/Dockerfile +index 7a5234ae03..ae695f63b3 100644 +--- a/Dockerfile ++++ b/Dockerfile +@@ -6,6 +6,9 @@ FROM --platform=$BUILDPLATFORM golang:${GO_VERSION}-alpine AS elemental-bin + ENV CGO_ENABLED=0 + WORKDIR /src/ + ++# install GNU tar instead of busybox one to support --sort ++RUN apk add --no-cache tar ++ + # Add specific dirs to the image so cache is not invalidated when modifying non go files + ADD go.mod . + ADD go.sum . + +From f1e6c778c2b74b712d9f5f679bff159ae8a78268 Mon Sep 17 00:00:00 2001 +From: "Bernhard M. Wiedemann" +Date: Sun, 1 Dec 2024 18:17:31 +0100 +Subject: [PATCH 2/2] Make tar creation deterministic + +for that, we sort entries, override owner+group+mtime +and omit ctime+atime +--- + pkg/features/generate-tarballs.go | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/pkg/features/generate-tarballs.go b/pkg/features/generate-tarballs.go +index 225900970d..1c90de7f72 100644 +--- a/pkg/features/generate-tarballs.go ++++ b/pkg/features/generate-tarballs.go +@@ -62,7 +62,7 @@ func main() { + + fmt.Printf("Generate %s from %s\n", output, input) + +- cmd := exec.Command("tar", "-C", inputDir, "-czvf", output, input) ++ cmd := exec.Command("tar", "--sort=name", "--mtime=@1", "--owner=0", "--group=0", "--numeric-owner", "--pax-option=exthdr.name=%d/PaxHeaders/%f,delete=atime,delete=ctime", "-C", inputDir, "-czvf", output, input) + + out, err := cmd.CombinedOutput() + if err != nil {