Skip to content

Commit 1552145

Browse files
committed
gitian: Sort generated source distribution archive
Sort the filenames in the resulting tar, normalize the time/date and user/group information.
1 parent aabcd11 commit 1552145

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

contrib/gitian-descriptors/gitian-linux.yml

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@ script: |
2929
STAGING="$HOME/install"
3030
OPTFLAGS='-O2'
3131
BINDIR="${OUTDIR}/bin/${GBUILD_BITS}" # 32/64 bit build specific output directory
32+
TEMPDIR="$HOME/tempdir"
33+
export TZ=UTC
3234
export LIBRARY_PATH="$STAGING/lib"
3335
mkdir -p ${BINDIR}
3436
#
@@ -39,15 +41,20 @@ script: |
3941
cd ../build
4042
#
4143
cd bitcoin
42-
export TAR_OPTIONS=--mtime=`echo $REFERENCE_DATETIME | awk '{ print $1 }'`
4344
./autogen.sh
4445
./configure --prefix=$STAGING --bindir=$BINDIR --with-protoc-bindir=$STAGING/host/bin --with-boost=$STAGING --disable-maintainer-mode --disable-dependency-tracking PKG_CONFIG_PATH="$STAGING/lib/pkgconfig" CPPFLAGS="-I$STAGING/include ${OPTFLAGS}" LDFLAGS="-L$STAGING/lib ${OPTFLAGS}" CXXFLAGS="-frandom-seed=bitcoin ${OPTFLAGS}" BOOST_CHRONO_EXTRALIBS="-lrt"
4546
make dist
47+
DISTNAME=`echo bitcoin-*.tar.gz`
4648
mkdir -p distsrc
4749
cd distsrc
48-
tar --strip-components=1 -xf ../bitcoin-*.tar.*
50+
tar --strip-components=1 -xf ../$DISTNAME
4951
./configure --prefix=$STAGING --bindir=$BINDIR --with-protoc-bindir=$STAGING/host/bin --with-boost=$STAGING --disable-maintainer-mode --disable-dependency-tracking PKG_CONFIG_PATH="$STAGING/lib/pkgconfig" CPPFLAGS="-I$STAGING/include ${OPTFLAGS}" LDFLAGS="-L$STAGING/lib ${OPTFLAGS}" CXXFLAGS="-frandom-seed=bitcoin ${OPTFLAGS}" BOOST_CHRONO_EXTRALIBS="-lrt"
5052
make $MAKEOPTS
5153
make $MAKEOPTS install-strip
54+
55+
# sort distribution tar file and normalize user/group/mtime information for deterministic output
5256
mkdir -p $OUTDIR/src
53-
cp ../bitcoin-*.tar.* $OUTDIR/src
57+
rm -rf $TEMPDIR
58+
mkdir -p $TEMPDIR
59+
cd $TEMPDIR
60+
tar -xvf $HOME/build/bitcoin/$DISTNAME | sort | tar --no-recursion -cT /dev/stdin --mode='u+rw,go+r-w,a+X' --owner=0 --group=0 --mtime="$REFERENCE_DATETIME" | gzip -n > $OUTDIR/src/$DISTNAME

0 commit comments

Comments
 (0)