Skip to content

Commit 2129ee4

Browse files
codablockUdjinM6
authored andcommitted
Add docker support when doing Gitian builds (#2084)
* gitian-build.sh: fix signProg being recognized as two parameters * Support docker based Gitian builds Requires a gitian-builder version with devrandom/gitian-builder#181 This will also switch to use Docker by default. * Switch back to using lxc as default until upstream gitian-builder is ready
1 parent 6a1456e commit 2129ee4

1 file changed

Lines changed: 36 additions & 15 deletions

File tree

contrib/gitian-build.sh

Lines changed: 36 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ url=https://github.com/dashpay/dash
2121
proc=2
2222
mem=2000
2323
lxc=true
24+
docker=false
2425
osslTarUrl=http://downloads.sourceforge.net/project/osslsigncode/osslsigncode/osslsigncode-1.7.1.tar.gz
2526
osslPatchUrl=https://bitcoincore.org/cfields/osslsigncode-Backports-to-1.7.1.patch
2627
scriptName=$(basename -- "$0")
@@ -47,8 +48,10 @@ Options:
4748
-o|--os Specify which Operating Systems the build is for. Default is lwx. l for linux, w for windows, x for osx
4849
-j Number of processes to use. Default 2
4950
-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)
51+
--kvm Use KVM
52+
--lxc Use LXC
53+
--docker Use Docker
54+
--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)
5255
--detach-sign Create the assert file for detached signing. Will not commit anything.
5356
--no-commit Do not commit anything to git
5457
-h|--help Print this help message
@@ -78,7 +81,7 @@ while :; do
7881
-S|--signer)
7982
if [ -n "$2" ]
8083
then
81-
SIGNER=$2
84+
SIGNER="$2"
8285
shift
8386
else
8487
echo 'Error: "--signer" requires a non-empty argument.'
@@ -153,8 +156,19 @@ while :; do
153156
fi
154157
;;
155158
# kvm
159+
--lxc)
160+
lxc=true
161+
docker=false
162+
;;
163+
# kvm
156164
--kvm)
157165
lxc=false
166+
docker=false
167+
;;
168+
# docker
169+
--docker)
170+
lxc=false
171+
docker=true
158172
;;
159173
# Detach sign
160174
--detach-sign)
@@ -181,6 +195,9 @@ then
181195
export USE_LXC=1
182196
export LXC_BRIDGE=lxcbr0
183197
sudo ifconfig lxcbr0 up 10.0.3.2
198+
elif [[ $docker = true ]]
199+
then
200+
export USE_DOCKER=1
184201
fi
185202

186203
# Check for OSX SDK
@@ -193,7 +210,7 @@ fi
193210
# Get signer
194211
if [[ -n"$1" ]]
195212
then
196-
SIGNER=$1
213+
SIGNER="$1"
197214
shift
198215
fi
199216

@@ -206,7 +223,7 @@ then
206223
fi
207224

208225
# Check that a signer is specified
209-
if [[ $SIGNER == "" ]]
226+
if [[ "$SIGNER" == "" ]]
210227
then
211228
echo "$scriptName: Missing signer."
212229
echo "Try $scriptName --help for more information"
@@ -240,6 +257,10 @@ then
240257
then
241258
sudo apt-get install lxc
242259
bin/make-base-vm --suite trusty --arch amd64 --lxc
260+
elif [[ -n "$USE_DOCKER" ]]
261+
then
262+
sudo apt-get install docker-ce
263+
bin/make-base-vm --suite trusty --arch amd64 --docker
243264
else
244265
bin/make-base-vm --suite trusty --arch amd64
245266
fi
@@ -275,7 +296,7 @@ then
275296
echo "Compiling ${VERSION} Linux"
276297
echo ""
277298
./bin/gbuild -j ${proc} -m ${mem} --commit dash=${COMMIT} --url dash=${url} ../dash/contrib/gitian-descriptors/gitian-linux.yml
278-
./bin/gsign -p $signProg --signer $SIGNER --release ${VERSION}-linux --destination ../gitian.sigs/ ../dash/contrib/gitian-descriptors/gitian-linux.yml
299+
./bin/gsign -p "$signProg" --signer "$SIGNER" --release ${VERSION}-linux --destination ../gitian.sigs/ ../dash/contrib/gitian-descriptors/gitian-linux.yml
279300
mv build/out/dash-*.tar.gz build/out/src/dash-*.tar.gz ../dash-binaries/${VERSION}
280301
fi
281302
# Windows
@@ -285,7 +306,7 @@ then
285306
echo "Compiling ${VERSION} Windows"
286307
echo ""
287308
./bin/gbuild -j ${proc} -m ${mem} --commit dash=${COMMIT} --url dash=${url} ../dash/contrib/gitian-descriptors/gitian-win.yml
288-
./bin/gsign -p $signProg --signer $SIGNER --release ${VERSION}-win-unsigned --destination ../gitian.sigs/ ../dash/contrib/gitian-descriptors/gitian-win.yml
309+
./bin/gsign -p "$signProg" --signer "$SIGNER" --release ${VERSION}-win-unsigned --destination ../gitian.sigs/ ../dash/contrib/gitian-descriptors/gitian-win.yml
289310
mv build/out/dash-*-win-unsigned.tar.gz inputs/dash-win-unsigned.tar.gz
290311
mv build/out/dash-*.zip build/out/dash-*.exe ../dash-binaries/${VERSION}
291312
fi
@@ -296,7 +317,7 @@ then
296317
echo "Compiling ${VERSION} Mac OSX"
297318
echo ""
298319
./bin/gbuild -j ${proc} -m ${mem} --commit dash=${COMMIT} --url dash=${url} ../dash/contrib/gitian-descriptors/gitian-osx.yml
299-
./bin/gsign -p $signProg --signer $SIGNER --release ${VERSION}-osx-unsigned --destination ../gitian.sigs/ ../dash/contrib/gitian-descriptors/gitian-osx.yml
320+
./bin/gsign -p "$signProg" --signer "$SIGNER" --release ${VERSION}-osx-unsigned --destination ../gitian.sigs/ ../dash/contrib/gitian-descriptors/gitian-osx.yml
300321
mv build/out/dash-*-osx-unsigned.tar.gz inputs/dash-osx-unsigned.tar.gz
301322
mv build/out/dash-*.tar.gz build/out/dash-*.dmg ../dash-binaries/${VERSION}
302323
fi
@@ -309,9 +330,9 @@ then
309330
echo "Committing ${VERSION} Unsigned Sigs"
310331
echo ""
311332
pushd gitian.sigs
312-
git add ${VERSION}-linux/${SIGNER}
313-
git add ${VERSION}-win-unsigned/${SIGNER}
314-
git add ${VERSION}-osx-unsigned/${SIGNER}
333+
git add ${VERSION}-linux/"${SIGNER}"
334+
git add ${VERSION}-win-unsigned/"${SIGNER}"
335+
git add ${VERSION}-osx-unsigned/"${SIGNER}"
315336
git commit -a -m "Add ${VERSION} unsigned sigs for ${SIGNER}"
316337
popd
317338
fi
@@ -361,7 +382,7 @@ then
361382
echo "Signing ${VERSION} Windows"
362383
echo ""
363384
./bin/gbuild -i --commit signature=${COMMIT} ../dash/contrib/gitian-descriptors/gitian-win-signer.yml
364-
./bin/gsign -p $signProg --signer $SIGNER --release ${VERSION}-win-signed --destination ../gitian.sigs/ ../dash/contrib/gitian-descriptors/gitian-win-signer.yml
385+
./bin/gsign -p "$signProg" --signer "$SIGNER" --release ${VERSION}-win-signed --destination ../gitian.sigs/ ../dash/contrib/gitian-descriptors/gitian-win-signer.yml
365386
mv build/out/dash-*win64-setup.exe ../dash-binaries/${VERSION}
366387
mv build/out/dash-*win32-setup.exe ../dash-binaries/${VERSION}
367388
fi
@@ -372,7 +393,7 @@ then
372393
echo "Signing ${VERSION} Mac OSX"
373394
echo ""
374395
./bin/gbuild -i --commit signature=${COMMIT} ../dash/contrib/gitian-descriptors/gitian-osx-signer.yml
375-
./bin/gsign -p $signProg --signer $SIGNER --release ${VERSION}-osx-signed --destination ../gitian.sigs/ ../dash/contrib/gitian-descriptors/gitian-osx-signer.yml
396+
./bin/gsign -p "$signProg" --signer "$SIGNER" --release ${VERSION}-osx-signed --destination ../gitian.sigs/ ../dash/contrib/gitian-descriptors/gitian-osx-signer.yml
376397
mv build/out/dash-osx-signed.dmg ../dash-binaries/${VERSION}/dash-${VERSION}-osx.dmg
377398
fi
378399
popd
@@ -384,8 +405,8 @@ then
384405
echo ""
385406
echo "Committing ${VERSION} Signed Sigs"
386407
echo ""
387-
git add ${VERSION}-win-signed/${SIGNER}
388-
git add ${VERSION}-osx-signed/${SIGNER}
408+
git add ${VERSION}-win-signed/"${SIGNER}"
409+
git add ${VERSION}-osx-signed/"${SIGNER}"
389410
git commit -a -m "Add ${VERSION} signed binary sigs for ${SIGNER}"
390411
popd
391412
fi

0 commit comments

Comments
 (0)