First draft for automated latest version builds

master
gdm85 9 years ago
parent 768db46d28
commit 8f79fccb14

@ -6,12 +6,14 @@
##
#
if [[ ! $# -eq 1 ]]; then
echo "Please specify version" 1>&2
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"
@ -30,8 +32,15 @@ if [ ! -d bitcoin ]; then
cd .. || exit $?
fi
## old logic using descriptors
## 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
@ -55,12 +64,17 @@ if ! verlte 0.10.0rc1 ${VERSION}; then
mv -v $(find build/out -type f -name '*gz' -o -name '*.zip') inputs/ || exit $?
done
else
cd bitcoin/depends && \
make download-linux SOURCES_PATH="$HOME/gitian-builder/cache/common" && \
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
cd gitian-builder && \
./bin/gbuild --commit bitcoin=v$VERSION -u bitcoin=$CLONE $CLONE/contrib/gitian-descriptors/gitian-linux.yml && \
## proceed to build of each of the specified gitian descriptors
cd gitian-builder || exit $?
for DESC in $@; do
./bin/gbuild --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/"

@ -1,12 +1,13 @@
#!/bin/bash
if [[ ! $# -eq 2 ]]; then
echo "Please specify version and signer id" 1>&2
if [ ! $# -eq 3 ]; then
echo "Usage: sign.sh version signer-id gitian-descriptor.yml" 1>&2
exit 1
fi
VERSION="$1"
SIGNER="$2"
DESC="$3"
cd gitian-builder && \
./bin/gsign --signer $SIGNER --release ${VERSION} --destination ../gitian.sigs/ ../bitcoin/contrib/gitian-descriptors/gitian-linux.yml
./bin/gsign --signer $SIGNER --release ${VERSION} --destination ../gitian.sigs/ "../bitcoin/contrib/gitian-descriptors/$DESC"

@ -0,0 +1,96 @@
#!/bin/bash
if [ $# -lt 1 ]; then
echo "Usage: gitian-build.sh linux [win] [osx] [...]" 1>&2
exit 1
fi
PARALLEL=""
if type coshell 2>/dev/null >/dev/null; then
PARALLEL="coshell"
else
if type parallel 2>/dev/null >/dev/null; then
PARALLEL="parallel -j$#"
else
echo "Please install coshell (https://github.com/gdm85/coshell) or GNU Parallel (https://www.gnu.org/software/parallel/)" 1>&2
exit 2
fi
fi
set -o pipefail && \
MOSTRECENT="$(curl -s https://api.github.com/repos/bitcoin/bitcoin/tags | jq -r '.[0].name' | awk '{ print substr($0, 2) }')" || exit $?
## run all necessary containers, detached
function run_all() {
local OS
for OS in "$@"; do
echo "docker run -d --privileged gdm85/gitian-bitcoin-host"
done | $PARALLEL
}
## run a simple test to detect if SSH works
function loop_wait_all() {
local RETRIES="$1"
shift
while [ $RETRIES -gt 0 ]; do
wait_all "$@" && break
sleep 1
let RETRIES-=1
done
return 0
}
function wait_all() {
local CID
local IP
for CID in "$@"; do
IP=$(docker inspect --format '{{ .NetworkSettings.IPAddress }}' $CID) && \
echo "ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no debian@$IP true" || return $?
done | $PARALLEL 2>/dev/null
}
function build_all() {
local ALL=($@)
local LEN=$(($#/2))
local CREATED=("${ALL[@]:0:$LEN}")
local OSES=("${ALL[@]:$LEN}")
local CID
local OS
local IP
local I=0
for CID in $CREATED; do
OS=${OSES[$I]}
# IP=$(docker inspect --format '{{ .NetworkSettings.IPAddress }}' $CID) && \
# echo -n "ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no debian@$IP " && \
# echo "./build-bitcoin.sh $MOSTRECENT ${OS}" || return $?
echo "docker-enter $CID su -c 'cd /home/debian && ./build-bitcoin.sh $MOSTRECENT ${OS}' debian"
let I+=1
done | $PARALLEL
}
function copy_all() {
local OS
for OS in "$@"; do
echo "docker cp ${CID}:/home/debian/gitian-build/build/out built-${OS}"
done | $PARALLEL
}
CREATED="$(run_all $@ | tr '\n' ' ')" && \
echo loop_wait_all 5 $CREATED && \
echo "Containers are online: $CREATED, building bitcoin v$MOSTRECENT" && \
build_all $CREATED $@ && \
copy_all $CREATED
RV=$?
## cleanup
#echo "Cleaning up created containers..."
#for CID in $CREATED; do
# docker stop $CID
# docker rm $CID
#done
## return build exit code
exit $RV
Loading…
Cancel
Save