2016-09-19 18:54:19 +02:00
# Copyright (c) 2016 The Bitcoin Core developers
# Distributed under the MIT software license, see the accompanying
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
2016-08-30 13:37:28 +02:00
# What to do
sign = false
verify = false
build = false
setupenv = false
# Systems to build
linux = true
windows = true
osx = true
# Other Basic variables
SIGNER =
VERSION =
commit = false
2018-01-09 12:43:36 +01:00
url = https://github.com/dashpay/dash
2016-08-30 13:37:28 +02:00
proc = 2
mem = 2000
lxc = true
2018-05-30 12:48:30 +02:00
docker = false
2016-08-30 13:37:28 +02:00
osslTarUrl = http://downloads.sourceforge.net/project/osslsigncode/osslsigncode/osslsigncode-1.7.1.tar.gz
osslPatchUrl = https://bitcoincore.org/cfields/osslsigncode-Backports-to-1.7.1.patch
scriptName = $( basename -- " $0 " )
signProg = "gpg --detach-sign"
commitFiles = true
2018-07-12 15:28:59 +02:00
SDK_URL = ${ SDK_URL :- https : //bitcoincore.org/depends-sources/sdks }
OSX_SDK = ${ OSX_SDK :- 10 .11 }
2016-08-30 13:37:28 +02:00
# Help Message
read -d '' usage <<- EOF
Usage: $scriptName [ -c| u| v| b| s| B| o| h| j| m| ] signer version
2018-01-09 12:43:36 +01:00
Run this script from the directory containing the dash, gitian-builder, gitian.sigs, and dash-detached-sigs.
2016-08-30 13:37:28 +02:00
Arguments:
signer GPG signer to sign each build assert file
version Version number, commit, or branch to build. If building a commit or branch, the -c option must be specified
Options:
-c| --commit Indicate that the version argument is for a commit or branch
2018-01-09 12:43:36 +01:00
-u| --url Specify the URL of the repository. Default is https://github.com/dashpay/dash
2016-08-30 13:37:28 +02:00
-v| --verify Verify the gitian build
2017-02-06 12:54:02 +01:00
-b| --build Do a gitian build
2016-08-30 13:37:28 +02:00
-s| --sign Make signed binaries for Windows and Mac OSX
-B| --buildsign Build both signed and unsigned binaries
-o| --os Specify which Operating Systems the build is for . Default is lwx. l for linux, w for windows, x for osx
-j Number of processes to use. Default 2
-m Memory to allocate in MiB. Default 2000
2018-05-30 12:48:30 +02:00
--kvm Use KVM
--lxc Use LXC
--docker Use Docker
--setup Setup the gitian building environment. Uses KVM. If you want to use lxc, use the --lxc option. If you want to use Docker, use --docker. Only works on Debian-based systems ( Ubuntu, Debian)
2016-08-30 13:37:28 +02:00
--detach-sign Create the assert file for detached signing. Will not commit anything.
--no-commit Do not commit anything to git
-h| --help Print this help message
EOF
# Get options and arguments
while :; do
case $1 in
# Verify
-v| --verify)
verify = true
; ;
# Build
-b| --build)
build = true
; ;
# Sign binaries
-s| --sign)
sign = true
; ;
# Build then Sign
-B| --buildsign)
sign = true
build = true
; ;
# PGP Signer
-S| --signer)
if [ -n " $2 " ]
then
2018-05-30 12:48:30 +02:00
SIGNER = " $2 "
2016-08-30 13:37:28 +02:00
shift
else
echo 'Error: "--signer" requires a non-empty argument.'
exit 1
fi
; ;
# Operating Systems
-o| --os)
if [ -n " $2 " ]
then
linux = false
windows = false
osx = false
if [ [ " $2 " = *"l" * ] ]
then
linux = true
fi
if [ [ " $2 " = *"w" * ] ]
then
windows = true
fi
if [ [ " $2 " = *"x" * ] ]
then
osx = true
fi
shift
else
echo 'Error: "--os" requires an argument containing an l (for linux), w (for windows), or x (for Mac OSX)\n'
exit 1
fi
; ;
# Help message
-h| --help)
echo " $usage "
exit 0
; ;
# Commit or branch
-c| --commit)
commit = true
; ;
# Number of Processes
-j)
if [ -n " $2 " ]
then
proc = $2
shift
else
echo 'Error: "-j" requires an argument'
exit 1
fi
; ;
# Memory to allocate
-m)
if [ -n " $2 " ]
then
mem = $2
shift
else
echo 'Error: "-m" requires an argument'
exit 1
fi
; ;
# URL
-u)
if [ -n " $2 " ]
then
url = $2
shift
else
echo 'Error: "-u" requires an argument'
exit 1
fi
; ;
# kvm
2018-05-30 12:48:30 +02:00
--lxc)
lxc = true
docker = false
; ;
# kvm
2016-08-30 13:37:28 +02:00
--kvm)
lxc = false
2018-05-30 12:48:30 +02:00
docker = false
; ;
# docker
--docker)
lxc = false
docker = true
2016-08-30 13:37:28 +02:00
; ;
# Detach sign
--detach-sign)
signProg = "true"
commitFiles = false
; ;
# Commit files
--no-commit)
commitFiles = false
; ;
# Setup
--setup)
setup = true
; ;
*) # Default case: If no more options then break out of the loop.
break
esac
shift
done
# Set up LXC
if [ [ $lxc = true ] ]
then
export USE_LXC = 1
export LXC_BRIDGE = lxcbr0
2018-05-26 20:04:07 +02:00
sudo ifconfig lxcbr0 up 10.0.3.2
2018-05-30 12:48:30 +02:00
elif [ [ $docker = true ] ]
then
export USE_DOCKER = 1
2016-08-30 13:37:28 +02:00
fi
# Check for OSX SDK
if [ [ ! -e "gitian-builder/inputs/MacOSX10.11.sdk.tar.gz" && $osx = = true ] ]
then
echo "Cannot build for OSX, SDK does not exist. Will build for other OSes"
osx = false
fi
# Get signer
if [ [ -n" $1 " ] ]
then
2018-05-30 12:48:30 +02:00
SIGNER = " $1 "
2016-08-30 13:37:28 +02:00
shift
fi
# Get version
if [ [ -n " $1 " ] ]
then
VERSION = $1
COMMIT = $VERSION
shift
fi
# Check that a signer is specified
2018-05-30 12:48:30 +02:00
if [ [ " $SIGNER " = = "" ] ]
2016-08-30 13:37:28 +02:00
then
echo " $scriptName : Missing signer. "
echo " Try $scriptName --help for more information "
exit 1
fi
# Check that a version is specified
if [ [ $VERSION = = "" ] ]
then
echo " $scriptName : Missing version. "
echo " Try $scriptName --help for more information "
exit 1
fi
# Add a "v" if no -c
if [ [ $commit = false ] ]
then
COMMIT = " v ${ VERSION } "
fi
echo ${ COMMIT }
# Setup build environment
if [ [ $setup = true ] ]
then
sudo apt-get install ruby apache2 git apt-cacher-ng python-vm-builder qemu-kvm qemu-utils
2018-01-09 12:43:36 +01:00
git clone https://github.com/dashpay/gitian.sigs.git
git clone https://github.com/dashpay/dash-detached-sigs.git
2016-08-30 13:37:28 +02:00
git clone https://github.com/devrandom/gitian-builder.git
pushd ./gitian-builder
if [ [ -n " $USE_LXC " ] ]
then
sudo apt-get install lxc
2018-08-13 22:21:42 +02:00
bin/make-base-vm --suite bionic --arch amd64 --lxc
2018-05-30 12:48:30 +02:00
elif [ [ -n " $USE_DOCKER " ] ]
then
sudo apt-get install docker-ce
2018-08-13 22:21:42 +02:00
bin/make-base-vm --suite bionic --arch amd64 --docker
2016-08-30 13:37:28 +02:00
else
2018-08-13 22:21:42 +02:00
bin/make-base-vm --suite bionic --arch amd64
2016-08-30 13:37:28 +02:00
fi
popd
fi
# Set up build
2018-01-09 12:43:36 +01:00
pushd ./dash
2016-08-30 13:37:28 +02:00
git fetch
git checkout ${ COMMIT }
popd
# Build
if [ [ $build = true ] ]
then
# Make output folder
2018-05-31 17:31:00 +02:00
mkdir -p ./dashcore-binaries/${ VERSION }
2016-08-30 13:37:28 +02:00
# Build Dependencies
echo ""
echo "Building Dependencies"
echo ""
pushd ./gitian-builder
mkdir -p inputs
wget -N -P inputs $osslPatchUrl
wget -N -P inputs $osslTarUrl
2018-01-09 12:43:36 +01:00
make -C ../dash/depends download SOURCES_PATH = ` pwd ` /cache/common
2016-08-30 13:37:28 +02:00
# Linux
if [ [ $linux = true ] ]
then
echo ""
echo " Compiling ${ VERSION } Linux "
echo ""
2018-01-09 12:43:36 +01:00
./bin/gbuild -j ${ proc } -m ${ mem } --commit dash = ${ COMMIT } --url dash = ${ url } ../dash/contrib/gitian-descriptors/gitian-linux.yml
2018-05-30 12:48:30 +02:00
./bin/gsign -p " $signProg " --signer " $SIGNER " --release ${ VERSION } -linux --destination ../gitian.sigs/ ../dash/contrib/gitian-descriptors/gitian-linux.yml
2018-05-31 17:31:00 +02:00
mv build/out/dashcore-*.tar.gz build/out/src/dashcore-*.tar.gz ../dashcore-binaries/${ VERSION }
2016-08-30 13:37:28 +02:00
fi
# Windows
if [ [ $windows = true ] ]
then
echo ""
echo " Compiling ${ VERSION } Windows "
echo ""
2018-01-09 12:43:36 +01:00
./bin/gbuild -j ${ proc } -m ${ mem } --commit dash = ${ COMMIT } --url dash = ${ url } ../dash/contrib/gitian-descriptors/gitian-win.yml
2018-05-30 12:48:30 +02:00
./bin/gsign -p " $signProg " --signer " $SIGNER " --release ${ VERSION } -win-unsigned --destination ../gitian.sigs/ ../dash/contrib/gitian-descriptors/gitian-win.yml
2018-05-31 17:31:00 +02:00
mv build/out/dashcore-*-win-unsigned.tar.gz inputs/dashcore-win-unsigned.tar.gz
mv build/out/dashcore-*.zip build/out/dashcore-*.exe ../dashcore-binaries/${ VERSION }
2016-08-30 13:37:28 +02:00
fi
# Mac OSX
if [ [ $osx = true ] ]
then
echo ""
echo " Compiling ${ VERSION } Mac OSX "
echo ""
2018-07-12 15:28:59 +02:00
if [ -n " $OSX_SDK " ] ; then
if [ ! -f inputs/MacOSX${ OSX_SDK } .sdk.tar.gz ] ; then
curl --location --fail $SDK_URL /MacOSX${ OSX_SDK } .sdk.tar.gz -o inputs/MacOSX${ OSX_SDK } .sdk.tar.gz
fi
fi
2018-01-09 12:43:36 +01:00
./bin/gbuild -j ${ proc } -m ${ mem } --commit dash = ${ COMMIT } --url dash = ${ url } ../dash/contrib/gitian-descriptors/gitian-osx.yml
2018-05-30 12:48:30 +02:00
./bin/gsign -p " $signProg " --signer " $SIGNER " --release ${ VERSION } -osx-unsigned --destination ../gitian.sigs/ ../dash/contrib/gitian-descriptors/gitian-osx.yml
2018-05-31 17:31:00 +02:00
mv build/out/dashcore-*-osx-unsigned.tar.gz inputs/dashcore-osx-unsigned.tar.gz
mv build/out/dashcore-*.tar.gz build/out/dashcore-*.dmg ../dashcore-binaries/${ VERSION }
2016-08-30 13:37:28 +02:00
fi
popd
if [ [ $commitFiles = true ] ]
then
# Commit to gitian.sigs repo
echo ""
echo " Committing ${ VERSION } Unsigned Sigs "
echo ""
pushd gitian.sigs
2018-05-30 12:48:30 +02:00
git add ${ VERSION } -linux/" ${ SIGNER } "
git add ${ VERSION } -win-unsigned/" ${ SIGNER } "
git add ${ VERSION } -osx-unsigned/" ${ SIGNER } "
2016-08-30 13:37:28 +02:00
git commit -a -m " Add ${ VERSION } unsigned sigs for ${ SIGNER } "
popd
fi
fi
# Verify the build
if [ [ $verify = true ] ]
then
# Linux
pushd ./gitian-builder
echo ""
echo " Verifying v ${ VERSION } Linux "
echo ""
2018-01-09 12:43:36 +01:00
./bin/gverify -v -d ../gitian.sigs/ -r ${ VERSION } -linux ../dash/contrib/gitian-descriptors/gitian-linux.yml
2016-08-30 13:37:28 +02:00
# Windows
echo ""
echo " Verifying v ${ VERSION } Windows "
echo ""
2018-01-09 12:43:36 +01:00
./bin/gverify -v -d ../gitian.sigs/ -r ${ VERSION } -win-unsigned ../dash/contrib/gitian-descriptors/gitian-win.yml
2016-08-30 13:37:28 +02:00
# Mac OSX
echo ""
echo " Verifying v ${ VERSION } Mac OSX "
echo ""
2018-01-09 12:43:36 +01:00
./bin/gverify -v -d ../gitian.sigs/ -r ${ VERSION } -osx-unsigned ../dash/contrib/gitian-descriptors/gitian-osx.yml
2016-08-30 13:37:28 +02:00
# Signed Windows
echo ""
echo " Verifying v ${ VERSION } Signed Windows "
echo ""
2018-01-09 12:43:36 +01:00
./bin/gverify -v -d ../gitian.sigs/ -r ${ VERSION } -osx-signed ../dash/contrib/gitian-descriptors/gitian-osx-signer.yml
2016-08-30 13:37:28 +02:00
# Signed Mac OSX
echo ""
echo " Verifying v ${ VERSION } Signed Mac OSX "
echo ""
2018-01-09 12:43:36 +01:00
./bin/gverify -v -d ../gitian.sigs/ -r ${ VERSION } -osx-signed ../dash/contrib/gitian-descriptors/gitian-osx-signer.yml
2016-08-30 13:37:28 +02:00
popd
fi
# Sign binaries
if [ [ $sign = true ] ]
then
pushd ./gitian-builder
# Sign Windows
if [ [ $windows = true ] ]
then
echo ""
echo " Signing ${ VERSION } Windows "
echo ""
2018-01-09 12:43:36 +01:00
./bin/gbuild -i --commit signature = ${ COMMIT } ../dash/contrib/gitian-descriptors/gitian-win-signer.yml
2018-05-30 12:48:30 +02:00
./bin/gsign -p " $signProg " --signer " $SIGNER " --release ${ VERSION } -win-signed --destination ../gitian.sigs/ ../dash/contrib/gitian-descriptors/gitian-win-signer.yml
2018-05-31 17:31:00 +02:00
mv build/out/dashcore-*win64-setup.exe ../dashcore-binaries/${ VERSION }
mv build/out/dashcore-*win32-setup.exe ../dashcore-binaries/${ VERSION }
2016-08-30 13:37:28 +02:00
fi
# Sign Mac OSX
if [ [ $osx = true ] ]
then
echo ""
echo " Signing ${ VERSION } Mac OSX "
echo ""
2018-01-09 12:43:36 +01:00
./bin/gbuild -i --commit signature = ${ COMMIT } ../dash/contrib/gitian-descriptors/gitian-osx-signer.yml
2018-05-30 12:48:30 +02:00
./bin/gsign -p " $signProg " --signer " $SIGNER " --release ${ VERSION } -osx-signed --destination ../gitian.sigs/ ../dash/contrib/gitian-descriptors/gitian-osx-signer.yml
2018-05-31 17:31:00 +02:00
mv build/out/dashcore-osx-signed.dmg ../dashcore-binaries/${ VERSION } /dashcore-${ VERSION } -osx.dmg
2016-08-30 13:37:28 +02:00
fi
popd
if [ [ $commitFiles = true ] ]
then
# Commit Sigs
pushd gitian.sigs
echo ""
echo " Committing ${ VERSION } Signed Sigs "
echo ""
2018-05-30 12:48:30 +02:00
git add ${ VERSION } -win-signed/" ${ SIGNER } "
git add ${ VERSION } -osx-signed/" ${ SIGNER } "
2016-08-30 13:37:28 +02:00
git commit -a -m " Add ${ VERSION } signed binary sigs for ${ SIGNER } "
popd
fi
fi