Skip to content

Commit 4ce9106

Browse files
committed
gitian: sort generated source distribution archive for windows
Make the bitcoin-X.X.X.tar.gz deterministic.
1 parent 6b55e6b commit 4ce9106

File tree

1 file changed

+12
-7
lines changed

1 file changed

+12
-7
lines changed

contrib/gitian-descriptors/gitian-win.yml

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ script: |
3535
export TZ=UTC
3636
INDIR=$HOME/build
3737
OPTFLAGS='-O2'
38+
TEMPDIR="$HOME/tempdir"
3839
NEEDDIST=1
3940
# Qt: workaround for determinism in resource ordering
4041
# Qt5's rcc uses a QHash to store the files for the resource.
@@ -54,6 +55,7 @@ script: |
5455
else
5556
HOST=x86_64-w64-mingw32
5657
fi
58+
export PATH=$STAGING/host/bin:$PATH
5759
mkdir -p $STAGING $BUILDDIR $BINDIR
5860
#
5961
cd $STAGING
@@ -63,22 +65,18 @@ script: |
6365
unzip $INDIR/protobuf-win${BITS}-2.5.0-gitian-r4.zip
6466
if [ "$NEEDDIST" == "1" ]; then
6567
# Make source code archive which is architecture independent so it only needs to be done once
66-
cd $HOME/build/
67-
cd bitcoin
68-
export PATH=$STAGING/host/bin:$PATH
69-
export TAR_OPTIONS=--mtime=`echo $REFERENCE_DATETIME | awk '{ print $1 }'`
68+
cd $HOME/build/bitcoin
7069
./autogen.sh
7170
./configure --bindir=$OUTDIR --prefix=$STAGING --host=$HOST --with-qt-plugindir=$STAGING/plugins --with-qt-incdir=$STAGING/include --with-qt-bindir=$STAGING/host/bin --with-boost=$STAGING --disable-maintainer-mode --with-protoc-bindir=$STAGING/host/bin --disable-dependency-tracking CPPFLAGS="-I$STAGING/include ${OPTFLAGS}" LDFLAGS="-L$STAGING/lib ${OPTFLAGS}" CXXFLAGS="-frandom-seed=bitcoin ${OPTFLAGS}"
7271
make dist
73-
mkdir -p $OUTDIR/src
74-
cp -f bitcoin-*.tar.* $OUTDIR/src
72+
DISTNAME=`echo bitcoin-*.tar.gz`
7573
NEEDDIST=0
7674
fi
7775
# Build platform-dependent executables from source archive
7876
cd $BUILDDIR
7977
mkdir -p distsrc
8078
cd distsrc
81-
tar --strip-components=1 -xf $HOME/build/bitcoin/bitcoin-*.tar.*
79+
tar --strip-components=1 -xf $HOME/build/bitcoin/$DISTNAME
8280
./configure --bindir=$BINDIR --prefix=$STAGING --host=$HOST --with-qt-plugindir=$STAGING/plugins --with-qt-incdir=$STAGING/include --with-qt-bindir=$STAGING/host/bin --with-boost=$STAGING --disable-maintainer-mode --with-protoc-bindir=$STAGING/host/bin --disable-dependency-tracking CPPFLAGS="-I$STAGING/include ${OPTFLAGS}" LDFLAGS="-L$STAGING/lib ${OPTFLAGS}" CXXFLAGS="-frandom-seed=bitcoin ${OPTFLAGS}"
8381
export LD_PRELOAD=/usr/lib/faketime/libfaketime.so.1
8482
export FAKETIME=$REFERENCE_DATETIME
@@ -90,3 +88,10 @@ script: |
9088
unset FAKETIME
9189
done # for BITS in
9290
91+
# sort distribution tar file and normalize user/group/mtime information for deterministic output
92+
mkdir -p $OUTDIR/src
93+
rm -rf $TEMPDIR
94+
mkdir -p $TEMPDIR
95+
cd $TEMPDIR
96+
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
97+

0 commit comments

Comments
 (0)