Better output directory format (human readable)
Use commits SHA hashes as unique references
This commit is contained in:
parent
0f0c14a80a
commit
3aaaa2e188
@ -7,11 +7,11 @@
|
|||||||
#
|
#
|
||||||
|
|
||||||
if [ $# -lt 2 ]; then
|
if [ $# -lt 2 ]; then
|
||||||
echo "Usage: build-bitcoin.sh version linux [win] [osx] [...]" 1>&2
|
echo "Usage: build-bitcoin.sh commit linux [win] [osx] [...]" 1>&2
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
VERSION="$1"
|
COMMIT="$1"
|
||||||
shift
|
shift
|
||||||
## remaining parameters are OS targets to be build (e.g. win,osx,linux)
|
## remaining parameters are OS targets to be build (e.g. win,osx,linux)
|
||||||
|
|
||||||
@ -29,19 +29,20 @@ cd .. || exit $?
|
|||||||
if [ ! -d bitcoin ]; then
|
if [ ! -d bitcoin ]; then
|
||||||
git clone https://github.com/bitcoin/bitcoin.git && \
|
git clone https://github.com/bitcoin/bitcoin.git && \
|
||||||
cd bitcoin && \
|
cd bitcoin && \
|
||||||
git checkout v$VERSION && \
|
git checkout $COMMIT && \
|
||||||
cd .. || exit $?
|
cd .. || exit $?
|
||||||
fi
|
fi
|
||||||
|
|
||||||
## old logic using descriptors (only linux supported
|
## old logic using descriptors (only linux supported)
|
||||||
if ! verlte 0.10.0rc1 ${VERSION}; then
|
if echo "$COMMIT" | grep ^v >/dev/null && ! verlte v0.10.0rc1 $COMMIT; then
|
||||||
|
|
||||||
## make sure only Linux is being built
|
## make sure only Linux is being built
|
||||||
if [[ ! $# -eq 1 && "$1" != "linux" ]]; then
|
if [[ ! $# -eq 1 && "$1" != "linux" ]]; then
|
||||||
echo "For versions before 0.10.0rc1, only Linux building is supported" 1>&2
|
echo "For versions before 0.10.0rc1, only Linux building is supported" 1>&2
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
VERSION=$(echo "$COMMIT" | awk '{ print substr($0, 2) }')
|
||||||
|
|
||||||
cd gitian-builder/inputs || exit $?
|
cd gitian-builder/inputs || exit $?
|
||||||
## get each dependency
|
## get each dependency
|
||||||
## they are validated afterwards by gbuild
|
## they are validated afterwards by gbuild
|
||||||
@ -75,7 +76,7 @@ fi
|
|||||||
## proceed to build of each of the specified gitian descriptors
|
## proceed to build of each of the specified gitian descriptors
|
||||||
cd gitian-builder || exit $?
|
cd gitian-builder || exit $?
|
||||||
for DESC in $@; do
|
for DESC in $@; do
|
||||||
./bin/gbuild -j$NPROC --commit bitcoin=v$VERSION -u bitcoin=$CLONE "$CLONE/contrib/gitian-descriptors/gitian-${DESC}.yml" || exit $?
|
./bin/gbuild -j$NPROC --commit bitcoin=$COMMIT -u bitcoin=$CLONE "$CLONE/contrib/gitian-descriptors/gitian-${DESC}.yml" || exit $?
|
||||||
done
|
done
|
||||||
|
|
||||||
echo "Build completed successfully, output files are in: ~/gitian-builder/build/out/"
|
echo "Successfully built gitian-${DESC} at $COMMIT"
|
||||||
|
@ -15,9 +15,6 @@ SCRIPTS=$(dirname $(readlink -m $0)) || exit $?
|
|||||||
## place this file in script's directory in order to build for Mac OS X
|
## place this file in script's directory in order to build for Mac OS X
|
||||||
SDK=MacOSX10.7.sdk.tar.gz
|
SDK=MacOSX10.7.sdk.tar.gz
|
||||||
|
|
||||||
## change the assert directory as desired
|
|
||||||
SIGNER="$USER"
|
|
||||||
|
|
||||||
if [ $# -lt 1 ]; then
|
if [ $# -lt 1 ]; then
|
||||||
echo "Usage: gitian-build.sh linux [win] [osx] [...]" 1>&2
|
echo "Usage: gitian-build.sh linux [win] [osx] [...]" 1>&2
|
||||||
exit 1
|
exit 1
|
||||||
@ -42,19 +39,21 @@ else
|
|||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
## retrieve latest tagged release/release candidate
|
## change the assert directory as desired
|
||||||
set -o pipefail && \
|
if [ -z "$SIGNER" ]; then
|
||||||
MOSTRECENT="$(curl -s https://api.github.com/repos/bitcoin/bitcoin/tags | jq -r '.[0].name' | awk '{ print substr($0, 2) }')" || exit $?
|
SIGNER="$USER"
|
||||||
|
fi
|
||||||
|
|
||||||
## volumes inside container that are provided externally (bind mount)
|
## customize output volumes
|
||||||
LRESULT="$SCRIPTS/gitian-result"
|
if [ -z "$OUTPUTDIR" ]; then
|
||||||
LSIGS="$SCRIPTS/gitian-sigs"
|
OUTPUTDIR="$SCRIPTS/output"
|
||||||
LSOURCE="$SCRIPTS/gitian-cache"
|
fi
|
||||||
LDEST="$SCRIPTS/gitian-built"
|
|
||||||
CRESULT="/home/debian/gitian-builder/result"
|
function read_commit() {
|
||||||
CSIGS="/home/debian/gitian.sigs"
|
local SHA="$1"
|
||||||
CSOURCE="/home/debian/gitian-builder/cache"
|
set -o pipefail && \
|
||||||
CDEST="/home/debian/gitian-builder/build"
|
curl -s https://api.github.com/repos/bitcoin/bitcoin/commits/${SHA} | jq -r '.[0].sha'
|
||||||
|
}
|
||||||
|
|
||||||
## run all necessary containers, detached
|
## run all necessary containers, detached
|
||||||
## setup proper volumes for input/output collection
|
## setup proper volumes for input/output collection
|
||||||
@ -66,7 +65,7 @@ function run_all() {
|
|||||||
rm -rf "$LDEST/${OS}" && \
|
rm -rf "$LDEST/${OS}" && \
|
||||||
mkdir -p "$LDEST/${OS}" || return $?
|
mkdir -p "$LDEST/${OS}" || return $?
|
||||||
done
|
done
|
||||||
mkdir -p "$LSIGS/${MOSTRECENT}/${SIGNER}" && \
|
mkdir -p "$LSIGS" && \
|
||||||
mkdir -p "$LSOURCE" && \
|
mkdir -p "$LSOURCE" && \
|
||||||
mkdir -p "$LRESULT" && \
|
mkdir -p "$LRESULT" && \
|
||||||
chown -R 1000.1000 "$LDEST" "$LSOURCE" "$LSIGS" "$LRESULT" || return $?
|
chown -R 1000.1000 "$LDEST" "$LSOURCE" "$LSIGS" "$LRESULT" || return $?
|
||||||
@ -104,28 +103,67 @@ function build_all() {
|
|||||||
I=0
|
I=0
|
||||||
for CID in "${CREATED[@]}"; do
|
for CID in "${CREATED[@]}"; do
|
||||||
OS=${OSES[$I]}
|
OS=${OSES[$I]}
|
||||||
|
local OS_LOG_FILE="$LLOGS/build-${OS}.log"
|
||||||
|
echo "Execution log for ${OS} ({$HCOMMIT}) --> $OS_LOG_FILE" 1>&2
|
||||||
|
|
||||||
## first, fix rights of mounted volumes
|
echo -n "docker exec $CID su -c 'cd /home/debian && source .bash_profile && ./build-bitcoin.sh $COMMIT ${OS} && " && \
|
||||||
# echo -n "docker exec $CID chown -R debian.debian '$CSOURCE' '$CDEST' && " && \
|
echo -n "cd gitian-builder && ./bin/gasserts --signer $SIGNER --release ${HCOMMIT} --destination ../gitian.sigs/ ../bitcoin/contrib/gitian-descriptors/gitian-${OS}.yml' debian " && \
|
||||||
echo -n "docker exec $CID su -c 'cd /home/debian && source .bash_profile && ./build-bitcoin.sh $MOSTRECENT ${OS} && " && \
|
echo " >> $OS_LOG_FILE 2>&1"
|
||||||
echo "cd gitian-builder && ./bin/gasserts --signer $SIGNER --release ${MOSTRECENT} --destination ../gitian.sigs/ ../bitcoin/contrib/gitian-descriptors/gitian-${OS}.yml' debian"
|
|
||||||
let I+=1
|
let I+=1
|
||||||
done | $PARALLEL
|
done | $PARALLEL
|
||||||
}
|
}
|
||||||
|
|
||||||
|
set -o pipefail || exit $?
|
||||||
|
|
||||||
|
## always get latest release/rc if no commit environment was specified
|
||||||
|
if [ ! -z "$COMMIT" ]; then
|
||||||
|
HCOMMIT="$COMMIT"
|
||||||
|
else
|
||||||
|
HCOMMIT="$(curl -s https://api.github.com/repos/bitcoin/bitcoin/tags | jq -r '.[0].name' | awk '{ print substr($0, 2) }')" || exit $?
|
||||||
|
fi
|
||||||
|
|
||||||
|
## get commit short hash
|
||||||
|
## NOTE: this overwrites environment provided by user
|
||||||
|
COMMIT=$(read_commit "$HCOMMIT") || exit $?
|
||||||
|
|
||||||
|
###
|
||||||
|
### declarations for input/output data volumes
|
||||||
|
###
|
||||||
|
|
||||||
|
## always add human readable commit and commit to volume path variables
|
||||||
|
REL_OD="$OUTPUTDIR/${HCOMMIT}-${COMMIT}"
|
||||||
|
LRESULT="${REL_OD}/result-${HCOMMIT}-${COMMIT}"
|
||||||
|
LSIGS="${REL_OD}/sigs"
|
||||||
|
LDEST="${REL_OD}/built"
|
||||||
|
LLOGS="${REL_OD}"
|
||||||
|
## depends-cache does not sport human readable prefix, being the only input volume for containers
|
||||||
|
LSOURCE="${OUTPUTDIR}/${COMMIT}/depends-cache"
|
||||||
|
|
||||||
|
## path of above volumes inside the containers
|
||||||
|
CRESULT="/home/debian/gitian-builder/result"
|
||||||
|
CSIGS="/home/debian/gitian.sigs"
|
||||||
|
CSOURCE="/home/debian/gitian-builder/cache"
|
||||||
|
CDEST="/home/debian/gitian-builder/build"
|
||||||
|
|
||||||
|
## ---------------- main -------------------- ##
|
||||||
|
|
||||||
CREATED="$(run_all $@ | tr '\n' ' ')" && \
|
CREATED="$(run_all $@ | tr '\n' ' ')" && \
|
||||||
echo "Building bitcoin v$MOSTRECENT for $@" && \
|
echo "Building bitcoin (${HCOMMIT}) for $@" && \
|
||||||
build_all ${CREATED[@]} $@ && \
|
build_all ${CREATED[@]} $@
|
||||||
echo "Build results are available in '$SCRIPTS/built/'"
|
|
||||||
RV=$?
|
RV=$?
|
||||||
|
|
||||||
## cleanup
|
## cleanup
|
||||||
echo "Cleaning up created containers..."
|
#echo "Cleaning up created containers..."
|
||||||
for CID in $CREATED; do
|
for CID in $CREATED; do
|
||||||
# docker stop $CID
|
docker stop $CID
|
||||||
# docker rm $CID
|
docker rm $CID
|
||||||
docker pause $CID
|
|
||||||
done
|
done
|
||||||
|
|
||||||
## return build exit code
|
## return build exit code
|
||||||
|
if [ $RV -eq 0 ]; then
|
||||||
|
echo -n "Completed successfully "
|
||||||
|
else
|
||||||
|
echo -n "Failed "
|
||||||
|
fi
|
||||||
|
echo "with exit code = $RV"
|
||||||
exit $RV
|
exit $RV
|
||||||
|
Loading…
Reference in New Issue
Block a user