aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Heiko Thiery <heiko.thiery@gmail.com>2019-12-22 22:31:49 +0100
committerGravatar Yann E. MORIN <yann.morin.1998@free.fr>2019-12-30 10:50:21 +0100
commit89f5e989323ace815a32fced27eaefee2f4666de (patch)
tree7c328400afb00e9be4a38c5a04245a94444602f3
parent9fa2add810c0bda2c727ce55e68b4776a944d141 (diff)
downloadbuildroot-89f5e9893.tar.gz
buildroot-89f5e9893.tar.bz2
support/download/svn: generate reproducible svn archives
To generate a reproducible archive from a svn repository mainly the same aproach is done like for the archives from a git repository. Signed-off-by: Heiko Thiery <heiko.thiery@gmail.com> [yann.morin.1998@free.fr: get the date of the revision] Signed-off-by: Yann E. MORIN <yann.morin.1998@free.fr>
-rwxr-xr-xsupport/download/svn24
1 files changed, 23 insertions, 1 deletions
diff --git a/support/download/svn b/support/download/svn
index 542b25c0a2..012f286dd9 100755
--- a/support/download/svn
+++ b/support/download/svn
@@ -38,4 +38,26 @@ _svn() {
_svn export ${verbose} "${@}" "'${uri}@${rev}'" "'${basename}'"
-tar czf "${output}" "${basename}"
+# Get the date of the revision, to generate reproducible archives.
+# The output format is YYYY-MM-DDTHH:MM:SS.mmmuuuZ (i.e. always in the
+# UTC timezone), which we can feed as-is to the --mtime option for tar.
+# In case there is a redirection (e.g. http -> https), just keep the
+# last line (svn outputs everything on stdout)
+date="$( _svn info --show-item last-changed-date "'${uri}@${rev}'" |tail -n 1 )"
+
+# Generate the archive, sort with the C locale so that it is reproducible.
+# We do not want the .svn dir; we keep other .svn files, in case they are the
+# only files in their directory.
+find "${basename}" -not -type d \
+ -and -not -path "./.svn/*" >"${output}.list"
+LC_ALL=C sort <"${output}.list" >"${output}.list.sorted"
+
+# Create GNU-format tarballs, since that's the format of the tarballs on
+# sources.buildroot.org and used in the *.hash files
+tar cf - --transform="s#^\./#${basename}/#" \
+ --numeric-owner --owner=0 --group=0 --mtime="${date}" --format=gnu \
+ -T "${output}.list.sorted" >"${output}.tar"
+gzip -6 -n <"${output}.tar" >"${output}"
+
+rm -f "${output}.list"
+rm -f "${output}.list.sorted"