public inbox for gdb-cvs@sourceware.org
help / color / mirror / Atom feed
From: Nick Clifton <nickc@sourceware.org>
To: bfd-cvs@sourceware.org, gdb-cvs@sourceware.org
Subject: [binutils-gdb] Add ability to create reproducible source tarballs.
Date: Mon, 10 Oct 2022 10:29:20 +0000 (GMT)	[thread overview]
Message-ID: <20221010102920.AFF483858D37@sourceware.org> (raw)

https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=f54c53e9f4e01ba19a2b3a664fee42798b60e38a

commit f54c53e9f4e01ba19a2b3a664fee42798b60e38a
Author: Nick Clifton <nickc@redhat.com>
Date:   Mon Oct 10 11:28:45 2022 +0100

    Add ability to create reproducible source tarballs.
    
            * src-release.sh: Add "-r <date>" option to create reproducible
            tarballs based upon a fixed timestamp of <date>.
            * binutils/README-how-to-make-a-release: Add a line showing how to
            use -r <date> when creating a binutils release.

Diff:
---
 ChangeLog                             |  7 +++++++
 binutils/README-how-to-make-a-release |  4 ++++
 src-release.sh                        | 20 ++++++++++++++++----
 3 files changed, 27 insertions(+), 4 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 927e0eed7d8..73c3a006881 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2022-10-10  Nick Clifton  <nickc@redhat.com>
+
+	* src-release.sh: Add "-r <date>" option to create reproducible
+	tarballs based upon a fixed timestamp of <date>.
+	* binutils/README-how-to-make-a-release: Add a line showing how to
+	use -r <date> when creating a binutils release.
+
 2022-10-04  Nick Clifton  <nickc@redhat.com>
 
 	* README-maintainer-mode: Add a minimum version of dejagnu
diff --git a/binutils/README-how-to-make-a-release b/binutils/README-how-to-make-a-release
index 9fcebf5f0a4..3d7f6cec414 100644
--- a/binutils/README-how-to-make-a-release
+++ b/binutils/README-how-to-make-a-release
@@ -251,6 +251,10 @@ When the time comes to actually make the release....
   
             ./src-release.sh -b -g -l -x binutils
 
+      OR ... for a more reproducible tarball:
+
+            ./src-release.sh -b -g -l -x -r `git log -1 --format=%cd --date=format:%F bfd/version.m4` binutils
+
   24. Check that the files in the tarballs have the correct
       permissions.
 
diff --git a/src-release.sh b/src-release.sh
index 079b545ae7c..76c355a583c 100755
--- a/src-release.sh
+++ b/src-release.sh
@@ -30,6 +30,7 @@ SHA256PROG=sha256sum
 MAKE=make
 CC=gcc
 CXX=g++
+release_date=
 
 # Default to avoid splitting info files by setting the threshold high.
 MAKEINFOFLAGS=--split-size=5000000
@@ -184,9 +185,17 @@ do_tar()
     ver=$2
     echo "==> Making $package-$ver.tar"
     rm -f $package-$ver.tar
-    find $package-$ver -follow \( $CVS_NAMES \) -prune \
-	-o -type f -print \
-	| tar cTfh - $package-$ver.tar
+    if test x$release_date == "x" ; then
+       find $package-$ver -follow \( $CVS_NAMES \) -prune -o -type f -print \
+	   | tar cTfh - $package-$ver.tar
+    else
+	# Attempt to create a consistent, reproducible tarball using the
+	# specified date.
+	find $package-$ver -follow \( $CVS_NAMES \) -prune -o -type f -print \
+	    | LC_ALL=C sort \
+	    | tar cTfh - $package-$ver.tar \
+		  --mtime=$release_date --group=0 --owner=0
+    fi
 }
 
 # Compress the output with bzip2
@@ -340,6 +349,7 @@ usage()
     echo "  -g: Compress with gzip"
     echo "  -l: Compress with lzip"
     echo "  -x: Compress with xz"
+    echo "  -r <date>: Create a reproducible tarball using <date> as the mtime"
     exit 1
 }
 
@@ -363,7 +373,7 @@ build_release()
 
 compressors=""
 
-while getopts ":bglx" opt; do
+while getopts ":bglr:x" opt; do
     case $opt in
 	b)
 	    compressors="$compressors bz2";;
@@ -371,6 +381,8 @@ while getopts ":bglx" opt; do
 	    compressors="$compressors gz";;
 	l)
 	    compressors="$compressors lz";;
+	r)
+	    release_date=$OPTARG;;
 	x)
 	    compressors="$compressors xz";;
 	\?)

                 reply	other threads:[~2022-10-10 10:29 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20221010102920.AFF483858D37@sourceware.org \
    --to=nickc@sourceware.org \
    --cc=bfd-cvs@sourceware.org \
    --cc=gdb-cvs@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).