Skip to content

Commit aa93485

Browse files
committed
gitian: Make linux build of OpenSSL deterministic
OpenSSL was embedding a timestamp causing its build to be non-deterministic. Change deps-linux to be deterministic by using FAKETIME as needed and disabling it when it gets in the way.
1 parent 23617fd commit aa93485

File tree

2 files changed

+21
-7
lines changed

2 files changed

+21
-7
lines changed

contrib/gitian-descriptors/deps-linux.yml

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,9 @@ files:
2424
script: |
2525
STAGING="$HOME/install"
2626
OPTFLAGS='-O2'
27+
export LD_PRELOAD=/usr/lib/faketime/libfaketime.so.1
28+
export FAKETIME=$REFERENCE_DATETIME
29+
export TZ=UTC
2730
export LIBRARY_PATH="$STAGING/lib"
2831
# Integrity Check
2932
echo "f74f15e8c8ff11aa3d5bb5f276d202ec18d7246e95f961db76054199c69c1ae3 openssl-1.0.1e.tar.gz" | sha256sum -c
@@ -37,6 +40,7 @@ script: |
3740
cd openssl-1.0.1e
3841
# need -fPIC to avoid relocation error in 64 bit builds
3942
./config no-shared no-zlib no-dso no-krb5 --openssldir=$STAGING -fPIC
43+
# need to build OpenSSL with faketime because a timestamp is embedded into cversion.o
4044
make
4145
make install_sw
4246
cd ..
@@ -48,28 +52,38 @@ script: |
4852
rm -f $STAGING/lib/libminiupnpc.so* # no way to skip shared lib build
4953
cd ..
5054
#
51-
tar xjfm qrencode-3.4.3.tar.bz2
55+
tar xjf qrencode-3.4.3.tar.bz2
5256
cd qrencode-3.4.3
57+
unset FAKETIME # unset fake time during configure, as it does some clock sanity tests
5358
# 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
59+
./configure --prefix=$STAGING --enable-static --disable-shared --with-pic --without-tools --disable-dependency-tracking --without-zlib
60+
# Workaround to prevent re-configuring by make; make all files have a date in the past
61+
find . -print0 | xargs -r0 touch -t 200001010000
62+
export FAKETIME=$REFERENCE_DATETIME
5563
make $MAKEOPTS install
5664
cd ..
5765
#
58-
tar xjfm protobuf-2.5.0.tar.bz2
66+
tar xjf protobuf-2.5.0.tar.bz2
5967
cd protobuf-2.5.0
6068
mkdir -p $STAGING/host/bin
69+
unset FAKETIME # unset fake time during configure, as it does some clock sanity tests
6170
# need --with-pic to avoid relocation error in 64 bit builds
6271
./configure --prefix=$STAGING --bindir=$STAGING/host/bin --enable-static --disable-shared --with-pic
72+
# Workaround to prevent re-configuring by make; make all files have a date in the past
73+
find . -print0 | xargs -r0 touch -t 200001010000
74+
export FAKETIME=$REFERENCE_DATETIME
6375
make $MAKEOPTS install
6476
cd ..
6577
#
6678
tar xzf db-4.8.30.NC.tar.gz
6779
cd db-4.8.30.NC/build_unix
6880
# need --with-pic to avoid relocation error in 64 bit builds
6981
../dist/configure --prefix=$STAGING --enable-cxx --disable-shared --with-pic
82+
# Workaround to prevent re-configuring by make; make all files have a date in the past
83+
find . -print0 | xargs -r0 touch -t 200001010000
7084
make $MAKEOPTS library_build
7185
make install_lib install_include
7286
cd ../..
7387
#
7488
cd $STAGING
75-
zip -r $OUTDIR/bitcoin-deps-linux${GBUILD_BITS}-gitian-r2.zip include lib bin host
89+
find include lib bin host -type f | sort | zip -X@ $OUTDIR/bitcoin-deps-linux${GBUILD_BITS}-gitian-r3.zip

contrib/gitian-descriptors/gitian-linux.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@ 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: |
@@ -34,7 +34,7 @@ script: |
3434
#
3535
mkdir -p $STAGING
3636
cd $STAGING
37-
unzip ../build/bitcoin-deps-linux${GBUILD_BITS}-gitian-r2.zip
37+
unzip ../build/bitcoin-deps-linux${GBUILD_BITS}-gitian-r3.zip
3838
unzip ../build/boost-linux${GBUILD_BITS}-1.55.0-gitian-r1.zip
3939
cd ../build
4040
#

0 commit comments

Comments
 (0)