Sync from SUSE:SLFO:Main elemental-toolkit revision 820c18cce5a95a75f9a0e4af3dffc292

This commit is contained in:
Adrian Schröter 2025-02-25 17:52:19 +01:00
parent 3d82aac9fa
commit d092e23a00
3 changed files with 55 additions and 1 deletions

View File

@ -1,3 +1,8 @@
-------------------------------------------------------------------
Thu Feb 20 09:14:15 UTC 2025 - Bernhard Wiedemann <bwiedemann@suse.com>
- Add reproducible-tar.patch for reproducible builds (boo#1237212, jsc#PED-12137)
-------------------------------------------------------------------
Wed Oct 2 12:03:00 UTC 2024 - Elemental Bot <elemental@suse.de>

View File

@ -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

48
reproducible-tar.patch Normal file
View File

@ -0,0 +1,48 @@
From 65c56676008c20b3ad4a286e9f69e40b8b8b45c4 Mon Sep 17 00:00:00 2001
From: "Bernhard M. Wiedemann" <bwiedemann@suse.de>
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" <bwiedemann@suse.de>
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 {