12 # Other Basic variables
16 url
=https
://github.com
/bitcoin
/bitcoin
20 osslTarUrl
=http
://downloads.sourceforge.net
/project
/osslsigncode
/osslsigncode
/osslsigncode-1.7
.1.
tar.gz
21 osslPatchUrl
=https
://bitcoincore.org
/cfields
/osslsigncode-Backports-to-1.7
.1.
patch
22 scriptName
=$
(basename -- "$0")
23 signProg
="gpg --detach-sign"
27 read -d '' usage
<<- EOF
28 Usage: $scriptName [-c|u|v|b|s|B|o|h|j|m|] signer version
30 Run this script from the directory containing the bitcoin, gitian-builder, gitian.sigs, and bitcoin-detached-sigs.
33 signer GPG signer to sign each build assert file
34 version Version number, commit, or branch to build. If building a commit or branch, the -c option must be specified
37 -c|--commit Indicate that the version argument is for a commit or branch
38 -u|--url Specify the URL of the repository. Default is https://github.com/bitcoin/bitcoin
39 -v|--verify Verify the gitian build
40 -b|--build Do a gitiain build
41 -s|--sign Make signed binaries for Windows and Mac OSX
42 -B|--buildsign Build both signed and unsigned binaries
43 -o|--os Specify which Operating Systems the build is for. Default is lwx. l for linux, w for windows, x for osx
44 -j Number of processes to use. Default 2
45 -m Memory to allocate in MiB. Default 2000
46 --kvm Use KVM instead of LXC
47 --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)
48 --detach-sign Create the assert file for detached signing. Will not commit anything.
49 --no-commit Do not commit anything to git
50 -h|--help Print this help message
53 # Get options and arguments
80 echo 'Error: "--signer" requires a non-empty argument.'
105 echo 'Error: "--os" requires an argument containing an l (for linux), w (for windows), or x (for Mac OSX)\n'
118 # Number of Processes
125 echo 'Error: "-j" requires an argument'
136 echo 'Error: "-m" requires an argument'
147 echo 'Error: "-u" requires an argument'
168 *) # Default case: If no more options then break out of the loop.
178 export LXC_BRIDGE
=lxcbr0
179 sudo ifconfig lxcbr0 up
10.0.2.2
183 if [[ ! -e "gitian-builder/inputs/MacOSX10.11.sdk.tar.gz" && $osx == true
]]
185 echo "Cannot build for OSX, SDK does not exist. Will build for other OSes"
204 # Check that a signer is specified
205 if [[ $SIGNER == "" ]]
207 echo "$scriptName: Missing signer."
208 echo "Try $scriptName --help for more information"
212 # Check that a version is specified
213 if [[ $VERSION == "" ]]
215 echo "$scriptName: Missing version."
216 echo "Try $scriptName --help for more information"
221 if [[ $commit = false
]]
227 # Setup build environment
228 if [[ $setup = true
]]
230 sudo apt-get
install ruby apache2 git apt-cacher-ng python-vm-builder qemu-kvm qemu-utils
231 git clone https
://github.com
/bitcoin-core
/gitian.sigs.git
232 git clone https
://github.com
/bitcoin-core
/bitcoin-detached-sigs.git
233 git clone https
://github.com
/devrandom
/gitian-builder.git
234 pushd .
/gitian-builder
235 if [[ -n "$USE_LXC" ]]
237 sudo apt-get
install lxc
238 bin
/make-base-vm
--suite trusty
--arch amd64
--lxc
240 bin
/make-base-vm
--suite trusty
--arch amd64
248 git checkout
${COMMIT}
252 if [[ $build = true
]]
255 mkdir
-p .
/bitcoin-binaries
/${VERSION}
259 echo "Building Dependencies"
261 pushd .
/gitian-builder
263 wget
-N -P inputs
$osslPatchUrl
264 wget
-N -P inputs
$osslTarUrl
265 make -C ..
/bitcoin
/depends download SOURCES_PATH
=`pwd`/cache
/common
268 if [[ $linux = true
]]
271 echo "Compiling ${VERSION} Linux"
273 .
/bin
/gbuild
-j ${proc} -m ${mem} --commit bitcoin=${COMMIT} --url bitcoin=${url} ..
/bitcoin
/contrib
/gitian-descriptors
/gitian-linux.yml
274 .
/bin
/gsign
-p $signProg --signer $SIGNER --release ${VERSION}-linux --destination ..
/gitian.sigs
/ ..
/bitcoin
/contrib
/gitian-descriptors
/gitian-linux.yml
275 mv build
/out
/bitcoin-
*.
tar.gz build
/out
/src
/bitcoin-
*.
tar.gz ..
/bitcoin-binaries
/${VERSION}
278 if [[ $windows = true
]]
281 echo "Compiling ${VERSION} Windows"
283 .
/bin
/gbuild
-j ${proc} -m ${mem} --commit bitcoin=${COMMIT} --url bitcoin=${url} ..
/bitcoin
/contrib
/gitian-descriptors
/gitian-win.yml
284 .
/bin
/gsign
-p $signProg --signer $SIGNER --release ${VERSION}-win-unsigned --destination ..
/gitian.sigs
/ ..
/bitcoin
/contrib
/gitian-descriptors
/gitian-win.yml
285 mv build
/out
/bitcoin-
*-win-unsigned.
tar.gz inputs
/bitcoin-win-unsigned.
tar.gz
286 mv build
/out
/bitcoin-
*.
zip build
/out
/bitcoin-
*.exe ..
/bitcoin-binaries
/${VERSION}
292 echo "Compiling ${VERSION} Mac OSX"
294 .
/bin
/gbuild
-j ${proc} -m ${mem} --commit bitcoin=${COMMIT} --url bitcoin=${url} ..
/bitcoin
/contrib
/gitian-descriptors
/gitian-osx.yml
295 .
/bin
/gsign
-p $signProg --signer $SIGNER --release ${VERSION}-osx-unsigned --destination ..
/gitian.sigs
/ ..
/bitcoin
/contrib
/gitian-descriptors
/gitian-osx.yml
296 mv build
/out
/bitcoin-
*-osx-unsigned.
tar.gz inputs
/bitcoin-osx-unsigned.
tar.gz
297 mv build
/out
/bitcoin-
*.
tar.gz build
/out
/bitcoin-
*.dmg ..
/bitcoin-binaries
/${VERSION}
301 if [[ $commitFiles = true
]]
303 # Commit to gitian.sigs repo
305 echo "Committing ${VERSION} Unsigned Sigs"
308 git add
${VERSION}-linux/${SIGNER}
309 git add
${VERSION}-win-unsigned/${SIGNER}
310 git add
${VERSION}-osx-unsigned/${SIGNER}
311 git commit
-a -m "Add ${VERSION} unsigned sigs for ${SIGNER}"
317 if [[ $verify = true
]]
320 pushd .
/gitian-builder
322 echo "Verifying v${VERSION} Linux"
324 .
/bin
/gverify
-v -d ..
/gitian.sigs
/ -r ${VERSION}-linux ..
/bitcoin
/contrib
/gitian-descriptors
/gitian-linux.yml
327 echo "Verifying v${VERSION} Windows"
329 .
/bin
/gverify
-v -d ..
/gitian.sigs
/ -r ${VERSION}-win-unsigned ..
/bitcoin
/contrib
/gitian-descriptors
/gitian-win.yml
332 echo "Verifying v${VERSION} Mac OSX"
334 .
/bin
/gverify
-v -d ..
/gitian.sigs
/ -r ${VERSION}-osx-unsigned ..
/bitcoin
/contrib
/gitian-descriptors
/gitian-osx.yml
337 echo "Verifying v${VERSION} Signed Windows"
339 .
/bin
/gverify
-v -d ..
/gitian.sigs
/ -r ${VERSION}-osx-signed ..
/bitcoin
/contrib
/gitian-descriptors
/gitian-osx-signer.yml
342 echo "Verifying v${VERSION} Signed Mac OSX"
344 .
/bin
/gverify
-v -d ..
/gitian.sigs
/ -r ${VERSION}-osx-signed ..
/bitcoin
/contrib
/gitian-descriptors
/gitian-osx-signer.yml
349 if [[ $sign = true
]]
352 pushd .
/gitian-builder
354 if [[ $windows = true
]]
357 echo "Signing ${VERSION} Windows"
359 .
/bin
/gbuild
-i --commit signature
=${COMMIT} ..
/bitcoin
/contrib
/gitian-descriptors
/gitian-win-signer.yml
360 .
/bin
/gsign
-p $signProg --signer $SIGNER --release ${VERSION}-win-signed --destination ..
/gitian.sigs
/ ..
/bitcoin
/contrib
/gitian-descriptors
/gitian-win-signer.yml
361 mv build
/out
/bitcoin-
*win64-setup.exe ..
/bitcoin-binaries
/${VERSION}
362 mv build
/out
/bitcoin-
*win32-setup.exe ..
/bitcoin-binaries
/${VERSION}
368 echo "Signing ${VERSION} Mac OSX"
370 .
/bin
/gbuild
-i --commit signature
=${COMMIT} ..
/bitcoin
/contrib
/gitian-descriptors
/gitian-osx-signer.yml
371 .
/bin
/gsign
-p $signProg --signer $SIGNER --release ${VERSION}-osx-signed --destination ..
/gitian.sigs
/ ..
/bitcoin
/contrib
/gitian-descriptors
/gitian-osx-signer.yml
372 mv build
/out
/bitcoin-osx-signed.dmg ..
/bitcoin-binaries
/${VERSION}/bitcoin-
${VERSION}-osx.dmg
376 if [[ $commitFiles = true
]]
381 echo "Committing ${VERSION} Signed Sigs"
383 git add
${VERSION}-win-signed/${SIGNER}
384 git add
${VERSION}-osx-signed/${SIGNER}
385 git commit
-a -m "Add ${VERSION} signed binary sigs for ${SIGNER}"