You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
tenku/docker/gitian-bitcoin-host/bin/build-bitcoin.sh

82 lines
2.3 KiB
Bash

#!/bin/bash
## automatic Gitian build of bitcoin
## @author gdm85
## @version 0.3.1
## see also https://github.com/gdm85/tenku/blob/master/docker/gitian-bitcoin-host/
##
#
if [ $# -lt 2 ]; then
echo "Usage: build-bitcoin.sh version linux [win] [osx] [...]" 1>&2
exit 1
fi
VERSION="$1"
shift
## remaining parameters are OS targets to be build (e.g. win,osx,linux)
CLONE="$HOME/bitcoin"
function verlte() {
[ "$1" = "`echo -e "$1\n$2" | sort -V | head -n1`" ]
}
NPROC=$(nproc) && \
cd gitian-builder && \
mkdir -p inputs && \
cd .. || exit $?
if [ ! -d bitcoin ]; then
git clone https://github.com/bitcoin/bitcoin.git && \
cd bitcoin && \
git checkout v$VERSION && \
cd .. || exit $?
fi
## old logic using descriptors (only linux supported
if ! verlte 0.10.0rc1 ${VERSION}; then
## make sure only Linux is being built
if [[ ! $# -eq 1 && "$1" != "linux" ]]; then
echo "For versions before 0.10.0rc1, only Linux building is supported" 1>&2
exit 1
fi
cd gitian-builder/inputs || exit $?
## get each dependency
## they are validated afterwards by gbuild
while read -r URL FNAME; do
if [ -z "$URL" ]; then
continue
fi
if [ ! -f $FNAME ]; then
echo "echo 'Downloading $FNAME'"
echo "wget -q --no-check-certificate '$URL' -O '$FNAME' || echo 'Failed to download $FNAME from $URL'"
fi
done < ../../input-sources/${VERSION}-inputs.txt | parallel -j10 || exit $?
## verify that all sources are correct before continuing
md5sum -c < ../../input-sources/${VERSION}-inputs.md5 && \
DESCRIPTORS="$(<../input-sources/${VERSION}-descriptors.txt)" && \
cd .. || exit $?
for DESC in $DESCRIPTORS; do
./bin/gbuild -j$NPROC ../bitcoin/contrib/gitian-descriptors/${DESC}.yml && \
mv -v $(find build/out -type f -name '*gz' -o -name '*.zip') inputs/ || exit $?
done
else
cd bitcoin/depends || exit $?
for DESC in $@; do
make download-${DESC} SOURCES_PATH="$HOME/gitian-builder/cache/common" || exit $?
done
cd ../.. || exit $?
fi
## proceed to build of each of the specified gitian descriptors
cd gitian-builder || exit $?
for DESC in $@; do
./bin/gbuild -j$NPROC --commit bitcoin=v$VERSION -u bitcoin=$CLONE "$CLONE/contrib/gitian-descriptors/gitian-${DESC}.yml" || exit $?
done
echo "Build completed successfully, output files are in: ~/gitian-builder/build/out/"