Skip to content

Commit

Permalink
make-archive: Build reproducible tarball
Browse files Browse the repository at this point in the history
Remove timestamps, user names, etc. from the tarball so that
it can be built reproducibly by multiple people, on different
machines.

The outer bzip2 layer might still be different, no reproducible
bzip2 known.

Signed-off-by: Julian Andres Klode <julian.klode@canonical.com>
  • Loading branch information
julian-klode committed Nov 14, 2022
1 parent 5c537b3 commit e29b971
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion make-archive
Original file line number Diff line number Diff line change
Expand Up @@ -86,14 +86,16 @@ main() {
cd ..
if [ "x" = "x${SHIM_GIT_TAG}" ] ; then
git archive --format=tar "$(git log -1 --pretty=format:%h)" | ( cd "${ARCHIVE_DIR}/shim-${VERSION}" ; tar x )
TIMESTAMP=0
else
# ORIGIN doesn't yet have this tag
git archive --format=tar "${SHIM_GIT_TAG}" | ( cd "${ARCHIVE_DIR}/shim-${VERSION}" ; tar x )
TIMESTAMP=$(git log -1 --pretty=%ct "${SHIM_GIT_TAG}")
fi
git log -1 --pretty=format:%H > "${ARCHIVE_DIR}/shim-${VERSION}/commit"
DIR="$PWD"
cd "${ARCHIVE_DIR}"
tar -c --bzip2 -f "${DIR}/shim-${VERSION}.tar.bz2" "shim-${VERSION}"
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}"
rm -rf "${ARCHIVE_DIR}"
echo "The archive is in shim-${VERSION}.tar.bz2"
exit 0
Expand Down

0 comments on commit e29b971

Please sign in to comment.