Skip to content

Commit c13a13e

Browse files
committed
gitian: add -D flag to ar for deterministic output for linux deps
ar -D: Operate in deterministic mode. When adding files and the archive index use zero for UIDs, GIDs, timestamps, and use consistent file modes for all files. When this option is used, if ar is used with identical options and identical input files, multiple runs will create identical output files regardless of the input files' owners, groups, file modes, or modification times.
1 parent 1552145 commit c13a13e

File tree

2 files changed

+22
-3
lines changed

2 files changed

+22
-3
lines changed

contrib/gitian-descriptors/boost-linux.yml

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ files:
1919
- "boost_1_55_0.tar.bz2"
2020
script: |
2121
STAGING="$HOME/install"
22+
TEMPDIR="$HOME/tmp"
2223
export LIBRARY_PATH="$STAGING/lib"
2324
export LD_PRELOAD=/usr/lib/faketime/libfaketime.so.1
2425
export FAKETIME=$REFERENCE_DATETIME
@@ -38,7 +39,16 @@ script: |
3839
3940
./bootstrap.sh --without-icu
4041
41-
./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
4243
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+
#
4353
cd "$STAGING"
44-
find -type f | sort | zip -X@ $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: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ files:
2323
- "db-4.8.30.NC.tar.gz"
2424
script: |
2525
STAGING="$HOME/install"
26+
TEMPDIR="$HOME/tmp"
2627
OPTFLAGS='-O2'
2728
export LD_PRELOAD=/usr/lib/faketime/libfaketime.so.1
2829
export FAKETIME=$REFERENCE_DATETIME
@@ -84,6 +85,14 @@ script: |
8485
make $MAKEOPTS library_build
8586
make install_lib install_include
8687
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
8796
#
8897
cd $STAGING
89-
find include lib bin host -type f | sort | zip -X@ $OUTDIR/bitcoin-deps-linux${GBUILD_BITS}-gitian-r3.zip
98+
find include lib bin host | sort | zip -X@ $OUTDIR/bitcoin-deps-linux${GBUILD_BITS}-gitian-r3.zip

0 commit comments

Comments
 (0)