Skip to content

Commit d5fa3ef

Browse files
committed
Merge pull request #3622
c13a13e gitian: add -D flag to ar for deterministic output for linux deps (Wladimir J. van der Laan) 1552145 gitian: Sort generated source distribution archive (Wladimir J. van der Laan) aabcd11 gitian: Make linux boost dependency completely deterministic (Wladimir J. van der Laan) aa93485 gitian: Make linux build of OpenSSL deterministic (Wladimir J. van der Laan)
2 parents 3e3c25d + c13a13e commit d5fa3ef

File tree

3 files changed

+57
-16
lines changed

3 files changed

+57
-16
lines changed

contrib/gitian-descriptors/boost-linux.yml

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,16 @@ files:
1919
- "boost_1_55_0.tar.bz2"
2020
script: |
2121
STAGING="$HOME/install"
22+
TEMPDIR="$HOME/tmp"
2223
export LIBRARY_PATH="$STAGING/lib"
24+
export LD_PRELOAD=/usr/lib/faketime/libfaketime.so.1
25+
export FAKETIME=$REFERENCE_DATETIME
26+
export TZ=UTC
2327
# Input Integrity Check
2428
echo "fff00023dd79486d444c8e29922f4072e1d451fc5a4d2b6075852ead7f2b7b52 boost_1_55_0.tar.bz2" | shasum -c
2529
2630
mkdir -p "$STAGING"
27-
tar xjf boost_1_55_0.tar.bz2
31+
tar --warning=no-timestamp -xjf boost_1_55_0.tar.bz2
2832
cd boost_1_55_0
2933
GCCVERSION=$(g++ -E -dM $(mktemp --suffix=.h) | grep __VERSION__ | cut -d ' ' -f 3 | cut -d '"' -f 2)
3034
# note: bjam with -d+2 reveals that -O3 is implied by default, no need to provide it in cxxflags
@@ -35,9 +39,16 @@ script: |
3539
3640
./bootstrap.sh --without-icu
3741
38-
./bjam toolset=gcc threadapi=pthread threading=multi variant=release link=static runtime-link=shared --user-config=user-config.jam --without-mpi --without-python -sNO_BZIP2=1 --layout=tagged --build-type=complete --prefix="$STAGING" $MAKEOPTS install
42+
./bjam toolset=gcc threadapi=pthread threading=multi variant=release link=static runtime-link=shared --user-config=user-config.jam --without-mpi --without-python -sNO_BZIP2=1 --layout=tagged --build-type=complete --prefix="$STAGING" $MAKEOPTS -d+2 install
3943
44+
# post-process all generated libraries to be deterministic
45+
# extract them to a temporary directory then re-build them deterministically
46+
for LIB in $(find $STAGING -name \*.a); do
47+
rm -rf $TEMPDIR && mkdir $TEMPDIR && cd $TEMPDIR
48+
ar xv $LIB | cut -b5- > /tmp/list.txt
49+
rm $LIB
50+
ar crsD $LIB $(cat /tmp/list.txt)
51+
done
52+
#
4053
cd "$STAGING"
41-
export LD_PRELOAD=/usr/lib/faketime/libfaketime.so.1
42-
export FAKETIME=$REFERENCE_DATETIME
43-
zip -r $OUTDIR/boost-linux${GBUILD_BITS}-1.55.0-gitian-r1.zip *
54+
find | sort | zip -X@ $OUTDIR/boost-linux${GBUILD_BITS}-1.55.0-gitian-r1.zip

contrib/gitian-descriptors/deps-linux.yml

Lines changed: 28 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,11 @@ files:
2323
- "db-4.8.30.NC.tar.gz"
2424
script: |
2525
STAGING="$HOME/install"
26+
TEMPDIR="$HOME/tmp"
2627
OPTFLAGS='-O2'
28+
export LD_PRELOAD=/usr/lib/faketime/libfaketime.so.1
29+
export FAKETIME=$REFERENCE_DATETIME
30+
export TZ=UTC
2731
export LIBRARY_PATH="$STAGING/lib"
2832
# Integrity Check
2933
echo "f74f15e8c8ff11aa3d5bb5f276d202ec18d7246e95f961db76054199c69c1ae3 openssl-1.0.1e.tar.gz" | sha256sum -c
@@ -37,6 +41,7 @@ script: |
3741
cd openssl-1.0.1e
3842
# need -fPIC to avoid relocation error in 64 bit builds
3943
./config no-shared no-zlib no-dso no-krb5 --openssldir=$STAGING -fPIC
44+
# need to build OpenSSL with faketime because a timestamp is embedded into cversion.o
4045
make
4146
make install_sw
4247
cd ..
@@ -48,28 +53,46 @@ script: |
4853
rm -f $STAGING/lib/libminiupnpc.so* # no way to skip shared lib build
4954
cd ..
5055
#
51-
tar xjfm qrencode-3.4.3.tar.bz2
56+
tar xjf qrencode-3.4.3.tar.bz2
5257
cd qrencode-3.4.3
58+
unset FAKETIME # unset fake time during configure, as it does some clock sanity tests
5359
# need --with-pic to avoid relocation error in 64 bit builds
54-
./configure --prefix=$STAGING --enable-static --disable-shared --with-pic --without-tools --disable-maintainer-mode --disable-dependency-tracking
60+
./configure --prefix=$STAGING --enable-static --disable-shared --with-pic --without-tools --disable-dependency-tracking
61+
# Workaround to prevent re-configuring by make; make all files have a date in the past
62+
find . -print0 | xargs -r0 touch -t 200001010000
63+
export FAKETIME=$REFERENCE_DATETIME
5564
make $MAKEOPTS install
5665
cd ..
5766
#
58-
tar xjfm protobuf-2.5.0.tar.bz2
67+
tar xjf protobuf-2.5.0.tar.bz2
5968
cd protobuf-2.5.0
6069
mkdir -p $STAGING/host/bin
70+
unset FAKETIME # unset fake time during configure, as it does some clock sanity tests
6171
# need --with-pic to avoid relocation error in 64 bit builds
62-
./configure --prefix=$STAGING --bindir=$STAGING/host/bin --enable-static --disable-shared --with-pic
72+
./configure --prefix=$STAGING --bindir=$STAGING/host/bin --enable-static --disable-shared --with-pic --without-zlib
73+
# Workaround to prevent re-configuring by make; make all files have a date in the past
74+
find . -print0 | xargs -r0 touch -t 200001010000
75+
export FAKETIME=$REFERENCE_DATETIME
6376
make $MAKEOPTS install
6477
cd ..
6578
#
6679
tar xzf db-4.8.30.NC.tar.gz
6780
cd db-4.8.30.NC/build_unix
6881
# need --with-pic to avoid relocation error in 64 bit builds
6982
../dist/configure --prefix=$STAGING --enable-cxx --disable-shared --with-pic
83+
# Workaround to prevent re-configuring by make; make all files have a date in the past
84+
find . -print0 | xargs -r0 touch -t 200001010000
7085
make $MAKEOPTS library_build
7186
make install_lib install_include
7287
cd ../..
88+
# post-process all generated libraries to be deterministic
89+
# extract them to a temporary directory then re-build them deterministically
90+
for LIB in $(find $STAGING -name \*.a); do
91+
rm -rf $TEMPDIR && mkdir $TEMPDIR && cd $TEMPDIR
92+
ar xv $LIB | cut -b5- > /tmp/list.txt
93+
rm $LIB
94+
ar crsD $LIB $(cat /tmp/list.txt)
95+
done
7396
#
7497
cd $STAGING
75-
zip -r $OUTDIR/bitcoin-deps-linux${GBUILD_BITS}-gitian-r2.zip include lib bin host
98+
find include lib bin host | sort | zip -X@ $OUTDIR/bitcoin-deps-linux${GBUILD_BITS}-gitian-r3.zip

contrib/gitian-descriptors/gitian-linux.yml

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,33 +21,40 @@ remotes:
2121
- "url": "https://github.com/bitcoin/bitcoin.git"
2222
"dir": "bitcoin"
2323
files:
24-
- "bitcoin-deps-linux32-gitian-r2.zip"
25-
- "bitcoin-deps-linux64-gitian-r2.zip"
24+
- "bitcoin-deps-linux32-gitian-r3.zip"
25+
- "bitcoin-deps-linux64-gitian-r3.zip"
2626
- "boost-linux32-1.55.0-gitian-r1.zip"
2727
- "boost-linux64-1.55.0-gitian-r1.zip"
2828
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
#
3537
mkdir -p $STAGING
3638
cd $STAGING
37-
unzip ../build/bitcoin-deps-linux${GBUILD_BITS}-gitian-r2.zip
39+
unzip ../build/bitcoin-deps-linux${GBUILD_BITS}-gitian-r3.zip
3840
unzip ../build/boost-linux${GBUILD_BITS}-1.55.0-gitian-r1.zip
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)