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.
16 # Other Basic variables
20 url
=https
://github.com
/bitcoin
/bitcoin
24 osslTarUrl
=http
://downloads.sourceforge.net
/project
/osslsigncode
/osslsigncode
/osslsigncode-1.7
.1.
tar.gz
25 osslPatchUrl
=https
://bitcoincore.org
/cfields
/osslsigncode-Backports-to-1.7
.1.
patch
26 scriptName
=$
(basename -- "$0")
27 signProg
="gpg --detach-sign"
31 read -d '' usage
<<- EOF
32 Usage: $scriptName [-c|u|v|b|s|B|o|h|j|m|] signer version
34 Run this script from the directory containing the bitcoin, gitian-builder, gitian.sigs, and bitcoin-detached-sigs.
37 signer GPG signer to sign each build assert file
38 version Version number, commit, or branch to build. If building a commit or branch, the -c option must be specified
41 -c|--commit Indicate that the version argument is for a commit or branch
42 -u|--url Specify the URL of the repository. Default is https://github.com/bitcoin/bitcoin
43 -v|--verify Verify the Gitian build
44 -b|--build Do a Gitian build
45 -s|--sign Make signed binaries for Windows and Mac OSX
46 -B|--buildsign Build both signed and unsigned binaries
47 -o|--os Specify which Operating Systems the build is for. Default is lwx. l for linux, w for windows, x for osx
48 -j Number of processes to use. Default 2
49 -m Memory to allocate in MiB. Default 2000
50 --kvm Use KVM instead of LXC
51 --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)
52 --detach-sign Create the assert file for detached signing. Will not commit anything.
53 --no-commit Do not commit anything to git
54 -h|--help Print this help message
57 # Get options and arguments
84 echo 'Error: "--signer" requires a non-empty argument.'
103 if [[ "$2" = *"x"* ]]
109 echo 'Error: "--os" requires an argument containing an l (for linux), w (for windows), or x (for Mac OSX)\n'
122 # Number of Processes
129 echo 'Error: "-j" requires an argument'
140 echo 'Error: "-m" requires an argument'
151 echo 'Error: "-u" requires an argument'
172 *) # Default case: If no more options then break out of the loop.
185 if [[ ! -e "gitian-builder/inputs/MacOSX10.11.sdk.tar.gz" && $osx == true
]]
187 echo "Cannot build for OSX, SDK does not exist. Will build for other OSes"
206 # Check that a signer is specified
207 if [[ $SIGNER == "" ]]
209 echo "$scriptName: Missing signer."
210 echo "Try $scriptName --help for more information"
214 # Check that a version is specified
215 if [[ $VERSION == "" ]]
217 echo "$scriptName: Missing version."
218 echo "Try $scriptName --help for more information"
223 if [[ $commit = false
]]
229 # Setup build environment
230 if [[ $setup = true
]]
232 sudo apt-get
install ruby apache2 git apt-cacher-ng python-vm-builder qemu-kvm qemu-utils
233 git clone https
://github.com
/bitcoin-core
/gitian.sigs.git
234 git clone https
://github.com
/bitcoin-core
/bitcoin-detached-sigs.git
235 git clone https
://github.com
/devrandom
/gitian-builder.git
236 pushd .
/gitian-builder
237 if [[ -n "$USE_LXC" ]]
239 sudo apt-get
install lxc
240 bin
/make-base-vm
--suite trusty
--arch amd64
--lxc
242 bin
/make-base-vm
--suite trusty
--arch amd64
250 git checkout
${COMMIT}
254 if [[ $build = true
]]
257 mkdir
-p .
/bitcoin-binaries
/${VERSION}
261 echo "Building Dependencies"
263 pushd .
/gitian-builder
265 wget
-N -P inputs
$osslPatchUrl
266 wget
-N -P inputs
$osslTarUrl
267 make -C ..
/bitcoin
/depends download SOURCES_PATH
=`pwd`/cache
/common
270 if [[ $linux = true
]]
273 echo "Compiling ${VERSION} Linux"
275 .
/bin
/gbuild
-j ${proc} -m ${mem} --commit bitcoin=${COMMIT} --url bitcoin=${url} ..
/bitcoin
/contrib
/gitian-descriptors
/gitian-linux.yml
276 .
/bin
/gsign
-p $signProg --signer $SIGNER --release ${VERSION}-linux --destination ..
/gitian.sigs
/ ..
/bitcoin
/contrib
/gitian-descriptors
/gitian-linux.yml
277 mv build
/out
/bitcoin-
*.
tar.gz build
/out
/src
/bitcoin-
*.
tar.gz ..
/bitcoin-binaries
/${VERSION}
280 if [[ $windows = true
]]
283 echo "Compiling ${VERSION} Windows"
285 .
/bin
/gbuild
-j ${proc} -m ${mem} --commit bitcoin=${COMMIT} --url bitcoin=${url} ..
/bitcoin
/contrib
/gitian-descriptors
/gitian-win.yml
286 .
/bin
/gsign
-p $signProg --signer $SIGNER --release ${VERSION}-win-unsigned --destination ..
/gitian.sigs
/ ..
/bitcoin
/contrib
/gitian-descriptors
/gitian-win.yml
287 mv build
/out
/bitcoin-
*-win-unsigned.
tar.gz inputs
/bitcoin-win-unsigned.
tar.gz
288 mv build
/out
/bitcoin-
*.
zip build
/out
/bitcoin-
*.exe ..
/bitcoin-binaries
/${VERSION}
294 echo "Compiling ${VERSION} Mac OSX"
296 .
/bin
/gbuild
-j ${proc} -m ${mem} --commit bitcoin=${COMMIT} --url bitcoin=${url} ..
/bitcoin
/contrib
/gitian-descriptors
/gitian-osx.yml
297 .
/bin
/gsign
-p $signProg --signer $SIGNER --release ${VERSION}-osx-unsigned --destination ..
/gitian.sigs
/ ..
/bitcoin
/contrib
/gitian-descriptors
/gitian-osx.yml
298 mv build
/out
/bitcoin-
*-osx-unsigned.
tar.gz inputs
/bitcoin-osx-unsigned.
tar.gz
299 mv build
/out
/bitcoin-
*.
tar.gz build
/out
/bitcoin-
*.dmg ..
/bitcoin-binaries
/${VERSION}
303 if [[ $commitFiles = true
]]
305 # Commit to gitian.sigs repo
307 echo "Committing ${VERSION} Unsigned Sigs"
310 git add
${VERSION}-linux/${SIGNER}
311 git add
${VERSION}-win-unsigned/${SIGNER}
312 git add
${VERSION}-osx-unsigned/${SIGNER}
313 git commit
-a -m "Add ${VERSION} unsigned sigs for ${SIGNER}"
319 if [[ $verify = true
]]
322 pushd .
/gitian-builder
324 echo "Verifying v${VERSION} Linux"
326 .
/bin
/gverify
-v -d ..
/gitian.sigs
/ -r ${VERSION}-linux ..
/bitcoin
/contrib
/gitian-descriptors
/gitian-linux.yml
329 echo "Verifying v${VERSION} Windows"
331 .
/bin
/gverify
-v -d ..
/gitian.sigs
/ -r ${VERSION}-win-unsigned ..
/bitcoin
/contrib
/gitian-descriptors
/gitian-win.yml
334 echo "Verifying v${VERSION} Mac OSX"
336 .
/bin
/gverify
-v -d ..
/gitian.sigs
/ -r ${VERSION}-osx-unsigned ..
/bitcoin
/contrib
/gitian-descriptors
/gitian-osx.yml
339 echo "Verifying v${VERSION} Signed Windows"
341 .
/bin
/gverify
-v -d ..
/gitian.sigs
/ -r ${VERSION}-osx-signed ..
/bitcoin
/contrib
/gitian-descriptors
/gitian-osx-signer.yml
344 echo "Verifying v${VERSION} Signed Mac OSX"
346 .
/bin
/gverify
-v -d ..
/gitian.sigs
/ -r ${VERSION}-osx-signed ..
/bitcoin
/contrib
/gitian-descriptors
/gitian-osx-signer.yml
351 if [[ $sign = true
]]
354 pushd .
/gitian-builder
356 if [[ $windows = true
]]
359 echo "Signing ${VERSION} Windows"
361 .
/bin
/gbuild
-i --commit signature
=${COMMIT} ..
/bitcoin
/contrib
/gitian-descriptors
/gitian-win-signer.yml
362 .
/bin
/gsign
-p $signProg --signer $SIGNER --release ${VERSION}-win-signed --destination ..
/gitian.sigs
/ ..
/bitcoin
/contrib
/gitian-descriptors
/gitian-win-signer.yml
363 mv build
/out
/bitcoin-
*win64-setup.exe ..
/bitcoin-binaries
/${VERSION}
364 mv build
/out
/bitcoin-
*win32-setup.exe ..
/bitcoin-binaries
/${VERSION}
370 echo "Signing ${VERSION} Mac OSX"
372 .
/bin
/gbuild
-i --commit signature
=${COMMIT} ..
/bitcoin
/contrib
/gitian-descriptors
/gitian-osx-signer.yml
373 .
/bin
/gsign
-p $signProg --signer $SIGNER --release ${VERSION}-osx-signed --destination ..
/gitian.sigs
/ ..
/bitcoin
/contrib
/gitian-descriptors
/gitian-osx-signer.yml
374 mv build
/out
/bitcoin-osx-signed.dmg ..
/bitcoin-binaries
/${VERSION}/bitcoin-
${VERSION}-osx.dmg
378 if [[ $commitFiles = true
]]
383 echo "Committing ${VERSION} Signed Sigs"
385 git add
${VERSION}-win-signed/${SIGNER}
386 git add
${VERSION}-osx-signed/${SIGNER}
387 git commit
-a -m "Add ${VERSION} signed binary sigs for ${SIGNER}"