1 # Copyright (c) 2016 The Bitcoin Core developers
2 # Distributed under the MIT software license, see the accompanying
3 # file COPYING or http://www.opensource.org/licenses/mit-license.php.
15 # Other Basic variables
19 url
=https
://github.com
/bitcoin
/bitcoin
23 osslTarUrl
=http
://downloads.sourceforge.net
/project
/osslsigncode
/osslsigncode
/osslsigncode-1.7
.1.
tar.gz
24 osslPatchUrl
=https
://bitcoincore.org
/cfields
/osslsigncode-Backports-to-1.7
.1.
patch
25 scriptName
=$
(basename -- "$0")
26 signProg
="gpg --detach-sign"
30 read -d '' usage
<<- EOF
31 Usage: $scriptName [-c|u|v|b|s|B|o|h|j|m|] signer version
33 Run this script from the directory containing the bitcoin, gitian-builder, gitian.sigs, and bitcoin-detached-sigs.
36 signer GPG signer to sign each build assert file
37 version Version number, commit, or branch to build. If building a commit or branch, the -c option must be specified
40 -c|--commit Indicate that the version argument is for a commit or branch
41 -u|--url Specify the URL of the repository. Default is https://github.com/bitcoin/bitcoin
42 -v|--verify Verify the Gitian build
43 -b|--build Do a Gitian build
44 -s|--sign Make signed binaries for Windows and Mac OSX
45 -B|--buildsign Build both signed and unsigned binaries
46 -o|--os Specify which Operating Systems the build is for. Default is lwx. l for linux, w for windows, x for osx
47 -j Number of processes to use. Default 2
48 -m Memory to allocate in MiB. Default 2000
49 --kvm Use KVM instead of LXC
50 --setup Set up the Gitian building environment. Uses KVM. If you want to use lxc, use the --lxc option. Only works on Debian-based systems (Ubuntu, Debian)
51 --detach-sign Create the assert file for detached signing. Will not commit anything.
52 --no-commit Do not commit anything to git
53 -h|--help Print this help message
56 # Get options and arguments
83 echo 'Error: "--signer" requires a non-empty argument.'
102 if [[ "$2" = *"x"* ]]
108 echo 'Error: "--os" requires an argument containing an l (for linux), w (for windows), or x (for Mac OSX)'
121 # Number of Processes
128 echo 'Error: "-j" requires an argument'
139 echo 'Error: "-m" requires an argument'
150 echo 'Error: "-u" requires an argument'
171 *) # Default case: If no more options then break out of the loop.
184 if [[ ! -e "gitian-builder/inputs/MacOSX10.11.sdk.tar.gz" && $osx == true
]]
186 echo "Cannot build for OSX, SDK does not exist. Will build for other OSes"
205 # Check that a signer is specified
206 if [[ $SIGNER == "" ]]
208 echo "$scriptName: Missing signer."
209 echo "Try $scriptName --help for more information"
213 # Check that a version is specified
214 if [[ $VERSION == "" ]]
216 echo "$scriptName: Missing version."
217 echo "Try $scriptName --help for more information"
222 if [[ $commit = false
]]
228 # Setup build environment
229 if [[ $setup = true
]]
231 sudo apt-get
install ruby apache2 git apt-cacher-ng python-vm-builder qemu-kvm qemu-utils
232 git clone https
://github.com
/bitcoin-core
/gitian.sigs.git
233 git clone https
://github.com
/bitcoin-core
/bitcoin-detached-sigs.git
234 git clone https
://github.com
/devrandom
/gitian-builder.git
235 pushd .
/gitian-builder
236 if [[ -n "$USE_LXC" ]]
238 sudo apt-get
install lxc
239 bin
/make-base-vm
--suite trusty
--arch amd64
--lxc
241 bin
/make-base-vm
--suite trusty
--arch amd64
249 git checkout
${COMMIT}
253 if [[ $build = true
]]
256 mkdir
-p .
/bitcoin-binaries
/${VERSION}
260 echo "Building Dependencies"
262 pushd .
/gitian-builder
264 wget
-N -P inputs
$osslPatchUrl
265 wget
-N -P inputs
$osslTarUrl
266 make -C ..
/bitcoin
/depends download SOURCES_PATH
=`pwd`/cache
/common
269 if [[ $linux = true
]]
272 echo "Compiling ${VERSION} Linux"
274 .
/bin
/gbuild
-j ${proc} -m ${mem} --commit bitcoin=${COMMIT} --url bitcoin=${url} ..
/bitcoin
/contrib
/gitian-descriptors
/gitian-linux.yml
275 .
/bin
/gsign
-p $signProg --signer $SIGNER --release ${VERSION}-linux --destination ..
/gitian.sigs
/ ..
/bitcoin
/contrib
/gitian-descriptors
/gitian-linux.yml
276 mv build
/out
/bitcoin-
*.
tar.gz build
/out
/src
/bitcoin-
*.
tar.gz ..
/bitcoin-binaries
/${VERSION}
279 if [[ $windows = true
]]
282 echo "Compiling ${VERSION} Windows"
284 .
/bin
/gbuild
-j ${proc} -m ${mem} --commit bitcoin=${COMMIT} --url bitcoin=${url} ..
/bitcoin
/contrib
/gitian-descriptors
/gitian-win.yml
285 .
/bin
/gsign
-p $signProg --signer $SIGNER --release ${VERSION}-win-unsigned --destination ..
/gitian.sigs
/ ..
/bitcoin
/contrib
/gitian-descriptors
/gitian-win.yml
286 mv build
/out
/bitcoin-
*-win-unsigned.
tar.gz inputs
/bitcoin-win-unsigned.
tar.gz
287 mv build
/out
/bitcoin-
*.
zip build
/out
/bitcoin-
*.exe ..
/bitcoin-binaries
/${VERSION}
293 echo "Compiling ${VERSION} Mac OSX"
295 .
/bin
/gbuild
-j ${proc} -m ${mem} --commit bitcoin=${COMMIT} --url bitcoin=${url} ..
/bitcoin
/contrib
/gitian-descriptors
/gitian-osx.yml
296 .
/bin
/gsign
-p $signProg --signer $SIGNER --release ${VERSION}-osx-unsigned --destination ..
/gitian.sigs
/ ..
/bitcoin
/contrib
/gitian-descriptors
/gitian-osx.yml
297 mv build
/out
/bitcoin-
*-osx-unsigned.
tar.gz inputs
/bitcoin-osx-unsigned.
tar.gz
298 mv build
/out
/bitcoin-
*.
tar.gz build
/out
/bitcoin-
*.dmg ..
/bitcoin-binaries
/${VERSION}
302 if [[ $commitFiles = true
]]
304 # Commit to gitian.sigs repo
306 echo "Committing ${VERSION} Unsigned Sigs"
309 git add
${VERSION}-linux/${SIGNER}
310 git add
${VERSION}-win-unsigned/${SIGNER}
311 git add
${VERSION}-osx-unsigned/${SIGNER}
312 git commit
-a -m "Add ${VERSION} unsigned sigs for ${SIGNER}"
318 if [[ $verify = true
]]
321 pushd .
/gitian-builder
323 echo "Verifying v${VERSION} Linux"
325 .
/bin
/gverify
-v -d ..
/gitian.sigs
/ -r ${VERSION}-linux ..
/bitcoin
/contrib
/gitian-descriptors
/gitian-linux.yml
328 echo "Verifying v${VERSION} Windows"
330 .
/bin
/gverify
-v -d ..
/gitian.sigs
/ -r ${VERSION}-win-unsigned ..
/bitcoin
/contrib
/gitian-descriptors
/gitian-win.yml
333 echo "Verifying v${VERSION} Mac OSX"
335 .
/bin
/gverify
-v -d ..
/gitian.sigs
/ -r ${VERSION}-osx-unsigned ..
/bitcoin
/contrib
/gitian-descriptors
/gitian-osx.yml
338 echo "Verifying v${VERSION} Signed Windows"
340 .
/bin
/gverify
-v -d ..
/gitian.sigs
/ -r ${VERSION}-osx-signed ..
/bitcoin
/contrib
/gitian-descriptors
/gitian-osx-signer.yml
343 echo "Verifying v${VERSION} Signed Mac OSX"
345 .
/bin
/gverify
-v -d ..
/gitian.sigs
/ -r ${VERSION}-osx-signed ..
/bitcoin
/contrib
/gitian-descriptors
/gitian-osx-signer.yml
350 if [[ $sign = true
]]
353 pushd .
/gitian-builder
355 if [[ $windows = true
]]
358 echo "Signing ${VERSION} Windows"
360 .
/bin
/gbuild
-i --commit signature
=${COMMIT} ..
/bitcoin
/contrib
/gitian-descriptors
/gitian-win-signer.yml
361 .
/bin
/gsign
-p $signProg --signer $SIGNER --release ${VERSION}-win-signed --destination ..
/gitian.sigs
/ ..
/bitcoin
/contrib
/gitian-descriptors
/gitian-win-signer.yml
362 mv build
/out
/bitcoin-
*win64-setup.exe ..
/bitcoin-binaries
/${VERSION}
363 mv build
/out
/bitcoin-
*win32-setup.exe ..
/bitcoin-binaries
/${VERSION}
369 echo "Signing ${VERSION} Mac OSX"
371 .
/bin
/gbuild
-i --commit signature
=${COMMIT} ..
/bitcoin
/contrib
/gitian-descriptors
/gitian-osx-signer.yml
372 .
/bin
/gsign
-p $signProg --signer $SIGNER --release ${VERSION}-osx-signed --destination ..
/gitian.sigs
/ ..
/bitcoin
/contrib
/gitian-descriptors
/gitian-osx-signer.yml
373 mv build
/out
/bitcoin-osx-signed.dmg ..
/bitcoin-binaries
/${VERSION}/bitcoin-
${VERSION}-osx.dmg
377 if [[ $commitFiles = true
]]
382 echo "Committing ${VERSION} Signed Sigs"
384 git add
${VERSION}-win-signed/${SIGNER}
385 git add
${VERSION}-osx-signed/${SIGNER}
386 git commit
-a -m "Add ${VERSION} signed binary sigs for ${SIGNER}"