Blame SOURCES/0011-make-archive-Build-reproducible-tarball.patch

9de34f
From 5169769e0f84dd227592cb73da97dacd61ae40b9 Mon Sep 17 00:00:00 2001
9de34f
From: Julian Andres Klode <julian.klode@canonical.com>
9de34f
Date: Mon, 14 Nov 2022 12:16:29 +0100
9de34f
Subject: [PATCH 11/13] make-archive: Build reproducible tarball
9de34f
9de34f
Remove timestamps, user names, etc. from the tarball so that
9de34f
it can be built reproducibly by multiple people, on different
9de34f
machines.
9de34f
9de34f
The outer bzip2 layer might still be different, no reproducible
9de34f
bzip2 known.
9de34f
9de34f
Signed-off-by: Julian Andres Klode <julian.klode@canonical.com>
9de34f
---
9de34f
 make-archive | 4 +++-
9de34f
 1 file changed, 3 insertions(+), 1 deletion(-)
9de34f
9de34f
diff --git a/make-archive b/make-archive
9de34f
index d4f095f0a46..9ae9eef077a 100755
9de34f
--- a/make-archive
9de34f
+++ b/make-archive
9de34f
@@ -86,14 +86,16 @@ main() {
9de34f
 	cd ..
9de34f
 	if [ "x" = "x${SHIM_GIT_TAG}" ] ; then
9de34f
 		git archive --format=tar "$(git log -1 --pretty=format:%h)" | ( cd "${ARCHIVE_DIR}/shim-${VERSION}" ; tar x )
9de34f
+		TIMESTAMP=0
9de34f
 	else
9de34f
 		# ORIGIN doesn't yet have this tag
9de34f
 		git archive --format=tar "${SHIM_GIT_TAG}" | ( cd "${ARCHIVE_DIR}/shim-${VERSION}" ; tar x )
9de34f
+		TIMESTAMP=$(git log -1 --pretty=%ct "${SHIM_GIT_TAG}")
9de34f
 	fi
9de34f
 	git log -1 --pretty=format:%H > "${ARCHIVE_DIR}/shim-${VERSION}/commit"
9de34f
 	DIR="$PWD"
9de34f
 	cd "${ARCHIVE_DIR}"
9de34f
-	tar -c --bzip2 -f "${DIR}/shim-${VERSION}.tar.bz2" "shim-${VERSION}"
9de34f
+	tar -c --sort=name --mtime="@${TIMESTAMP}" --owner=0 --group=0 --numeric-owner --pax-option=exthdr.name=%d/PaxHeaders/%f,delete=atime,delete=ctime --bzip2 -f "${DIR}/shim-${VERSION}.tar.bz2" "shim-${VERSION}"
9de34f
 	rm -rf "${ARCHIVE_DIR}"
9de34f
 	echo "The archive is in shim-${VERSION}.tar.bz2"
9de34f
 	exit 0
9de34f
-- 
9de34f
2.37.1
9de34f