From patchwork Mon Oct 3 14:40:03 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nick Clifton X-Patchwork-Id: 58727 From: nickc@redhat.com (Nick Clifton) Date: Mon, 3 Oct 2022 15:40:03 +0100 List-Id: gdb-patches mailing list Subject: RFC: Sort tarballs created by the src-release.sh script In-Reply-To: References: <07a1ca21-5569-e67b-d0c7-6069974b1068@redhat.com> <3EC98FFD-FD7A-4A17-9FE0-EF5DAFB36B3C@gentoo.org> Message-ID: <1e772307-1f10-6e1c-5ffb-8513a41db5ab@redhat.com> Hi Guys, [This appears to be getting slightly out of hand...] > Not sure what "creation date" might mean here. Assuming the script is > (typically) run from a git tree, perhaps the commit date of the top> level commit on the branch would be best to use? Except that a commit to the branch that does not affect something that would go into the tarball would then result in a changed date. We could use the src-release.sh file itself, like this: Would that work ? Cheers Nick diff --git a/src-release.sh b/src-release.sh index 079b545ae7c..de1f98a70bb 100755 --- a/src-release.sh +++ b/src-release.sh @@ -184,9 +184,15 @@ do_tar() ver=$2 echo "==> Making $package-$ver.tar" rm -f $package-$ver.tar + # The sort command and --mtime, --group and --owner options are + # used in order to create consistent, reproducible tarballs. + # BUILD_DATE is set to SOURCE_DATE_EPOCH if defined, or the + # modification date of this file otherwise. cf: + # https://reproducible-builds.org/docs/source-date-epoch/ + BUILD_DATE="$(date --utc --date="@${SOURCE_DATE_EPOCH:-$(date -r src-release.sh +%s)}" +%Y-%m-%d)" find $package-$ver -follow \( $CVS_NAMES \) -prune \ - -o -type f -print \ - | tar cTfh - $package-$ver.tar + -o -type f -print | LC_ALL=C sort \ + | tar cTfh - $package-$ver.tar --mtime=$BUILD_DATE --group=0 --owner=0 } # Compress the output with bzip2