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 Setup 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.
182 export LXC_BRIDGE
=lxcbr0
183 sudo ifconfig lxcbr0 up
10.0.2.2
187 if [[ ! -e "gitian-builder/inputs/MacOSX10.11.sdk.tar.gz" && $osx == true
]]
189 echo "Cannot build for OSX, SDK does not exist. Will build for other OSes"
208 # Check that a signer is specified
209 if [[ $SIGNER == "" ]]
211 echo "$scriptName: Missing signer."
212 echo "Try $scriptName --help for more information"
216 # Check that a version is specified
217 if [[ $VERSION == "" ]]
219 echo "$scriptName: Missing version."
220 echo "Try $scriptName --help for more information"
225 if [[ $commit = false
]]
231 # Setup build environment
232 if [[ $setup = true
]]
234 sudo apt-get
install ruby apache2 git apt-cacher-ng python-vm-builder qemu-kvm qemu-utils
235 git clone https
://github.com
/bitcoin-core
/gitian.sigs.git
236 git clone https
://github.com
/bitcoin-core
/bitcoin-detached-sigs.git
237 git clone https
://github.com
/devrandom
/gitian-builder.git
238 pushd .
/gitian-builder
239 if [[ -n "$USE_LXC" ]]
241 sudo apt-get
install lxc
242 bin
/make-base-vm
--suite trusty
--arch amd64
--lxc
244 bin
/make-base-vm
--suite trusty
--arch amd64
252 git checkout
${COMMIT}
256 if [[ $build = true
]]
259 mkdir
-p .
/bitcoin-binaries
/${VERSION}
263 echo "Building Dependencies"
265 pushd .
/gitian-builder
267 wget
-N -P inputs
$osslPatchUrl
268 wget
-N -P inputs
$osslTarUrl
269 make -C ..
/bitcoin
/depends download SOURCES_PATH
=`pwd`/cache
/common
272 if [[ $linux = true
]]
275 echo "Compiling ${VERSION} Linux"
277 .
/bin
/gbuild
-j ${proc} -m ${mem} --commit bitcoin=${COMMIT} --url bitcoin=${url} ..
/bitcoin
/contrib
/gitian-descriptors
/gitian-linux.yml
278 .
/bin
/gsign
-p $signProg --signer $SIGNER --release ${VERSION}-linux --destination ..
/gitian.sigs
/ ..
/bitcoin
/contrib
/gitian-descriptors
/gitian-linux.yml
279 mv build
/out
/bitcoin-
*.
tar.gz build
/out
/src
/bitcoin-
*.
tar.gz ..
/bitcoin-binaries
/${VERSION}
282 if [[ $windows = true
]]
285 echo "Compiling ${VERSION} Windows"
287 .
/bin
/gbuild
-j ${proc} -m ${mem} --commit bitcoin=${COMMIT} --url bitcoin=${url} ..
/bitcoin
/contrib
/gitian-descriptors
/gitian-win.yml
288 .
/bin
/gsign
-p $signProg --signer $SIGNER --release ${VERSION}-win-unsigned --destination ..
/gitian.sigs
/ ..
/bitcoin
/contrib
/gitian-descriptors
/gitian-win.yml
289 mv build
/out
/bitcoin-
*-win-unsigned.
tar.gz inputs
/bitcoin-win-unsigned.
tar.gz
290 mv build
/out
/bitcoin-
*.
zip build
/out
/bitcoin-
*.exe ..
/bitcoin-binaries
/${VERSION}
296 echo "Compiling ${VERSION} Mac OSX"
298 .
/bin
/gbuild
-j ${proc} -m ${mem} --commit bitcoin=${COMMIT} --url bitcoin=${url} ..
/bitcoin
/contrib
/gitian-descriptors
/gitian-osx.yml
299 .
/bin
/gsign
-p $signProg --signer $SIGNER --release ${VERSION}-osx-unsigned --destination ..
/gitian.sigs
/ ..
/bitcoin
/contrib
/gitian-descriptors
/gitian-osx.yml
300 mv build
/out
/bitcoin-
*-osx-unsigned.
tar.gz inputs
/bitcoin-osx-unsigned.
tar.gz
301 mv build
/out
/bitcoin-
*.
tar.gz build
/out
/bitcoin-
*.dmg ..
/bitcoin-binaries
/${VERSION}
305 if [[ $commitFiles = true
]]
307 # Commit to gitian.sigs repo
309 echo "Committing ${VERSION} Unsigned Sigs"
312 git add
${VERSION}-linux/${SIGNER}
313 git add
${VERSION}-win-unsigned/${SIGNER}
314 git add
${VERSION}-osx-unsigned/${SIGNER}
315 git commit
-a -m "Add ${VERSION} unsigned sigs for ${SIGNER}"
321 if [[ $verify = true
]]
324 pushd .
/gitian-builder
326 echo "Verifying v${VERSION} Linux"
328 .
/bin
/gverify
-v -d ..
/gitian.sigs
/ -r ${VERSION}-linux ..
/bitcoin
/contrib
/gitian-descriptors
/gitian-linux.yml
331 echo "Verifying v${VERSION} Windows"
333 .
/bin
/gverify
-v -d ..
/gitian.sigs
/ -r ${VERSION}-win-unsigned ..
/bitcoin
/contrib
/gitian-descriptors
/gitian-win.yml
336 echo "Verifying v${VERSION} Mac OSX"
338 .
/bin
/gverify
-v -d ..
/gitian.sigs
/ -r ${VERSION}-osx-unsigned ..
/bitcoin
/contrib
/gitian-descriptors
/gitian-osx.yml
341 echo "Verifying v${VERSION} Signed Windows"
343 .
/bin
/gverify
-v -d ..
/gitian.sigs
/ -r ${VERSION}-osx-signed ..
/bitcoin
/contrib
/gitian-descriptors
/gitian-osx-signer.yml
346 echo "Verifying v${VERSION} Signed Mac OSX"
348 .
/bin
/gverify
-v -d ..
/gitian.sigs
/ -r ${VERSION}-osx-signed ..
/bitcoin
/contrib
/gitian-descriptors
/gitian-osx-signer.yml
353 if [[ $sign = true
]]
356 pushd .
/gitian-builder
358 if [[ $windows = true
]]
361 echo "Signing ${VERSION} Windows"
363 .
/bin
/gbuild
-i --commit signature
=${COMMIT} ..
/bitcoin
/contrib
/gitian-descriptors
/gitian-win-signer.yml
364 .
/bin
/gsign
-p $signProg --signer $SIGNER --release ${VERSION}-win-signed --destination ..
/gitian.sigs
/ ..
/bitcoin
/contrib
/gitian-descriptors
/gitian-win-signer.yml
365 mv build
/out
/bitcoin-
*win64-setup.exe ..
/bitcoin-binaries
/${VERSION}
366 mv build
/out
/bitcoin-
*win32-setup.exe ..
/bitcoin-binaries
/${VERSION}
372 echo "Signing ${VERSION} Mac OSX"
374 .
/bin
/gbuild
-i --commit signature
=${COMMIT} ..
/bitcoin
/contrib
/gitian-descriptors
/gitian-osx-signer.yml
375 .
/bin
/gsign
-p $signProg --signer $SIGNER --release ${VERSION}-osx-signed --destination ..
/gitian.sigs
/ ..
/bitcoin
/contrib
/gitian-descriptors
/gitian-osx-signer.yml
376 mv build
/out
/bitcoin-osx-signed.dmg ..
/bitcoin-binaries
/${VERSION}/bitcoin-
${VERSION}-osx.dmg
380 if [[ $commitFiles = true
]]
385 echo "Committing ${VERSION} Signed Sigs"
387 git add
${VERSION}-win-signed/${SIGNER}
388 git add
${VERSION}-osx-signed/${SIGNER}
389 git commit
-a -m "Add ${VERSION} signed binary sigs for ${SIGNER}"