forked from OpenBazaar/OpenBazaar-Installer
-
Notifications
You must be signed in to change notification settings - Fork 0
/
make_openbazaar.sh
executable file
·497 lines (393 loc) · 16.9 KB
/
make_openbazaar.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
#!/bin/sh
## Version 0.1.0
##
## Usage
## ./make_openbazaar.sh OS
##
## OS supported:
## win32 win64 linux osx
##
ELECTRONVER=1.4.15
NODEJSVER=5.1.1
PYTHONVER=2.7.11
UPXVER=391
OS="${1}"
# Get Version
PACKAGE_VERSION=$(cat package.json \
| grep version \
| head -1 \
| awk -F: '{ print $2 }' \
| sed 's/[",]//g' \
| tr -d '[[:space:]]')
echo "OpenBazaar Version: $PACKAGE_VERSION"
# Check if user specified repository to pull code from
clone_url_server="https://github.com/OpenBazaar/OpenBazaar-Server.git"
clone_url_client="https://github.com/OpenBazaar/OpenBazaar-Client.git"
command_exists () {
if ! [ -x "$(command -v $1)" ]; then
echo "$1 is not installed." >&2
fi
}
clone_command() {
if git clone ${clone_url_server} -b ${branch}; then
echo "Cloned OpenBazaar Server successfully"
else
echo "OpenBazaar encountered an error and could not be cloned"
exit 2
fi
}
clone_command_client() {
if git clone ${clone_url_client}; then
echo "Cloned OpenBazaar Client successfully"
else
echo "OpenBazaar encountered an error and could not be cloned"
exit 2
fi
}
if ! [ -d OpenBazaar-Client ]; then
echo "Cloning OpenBazaar-Client"
clone_command_client
else
cd OpenBazaar-Client
git pull
cd ..
fi
branch=master
if ! [ -d OpenBazaar-Server ]; then
echo "Cloning OpenBazaar-Server"
clone_command
else
cd OpenBazaar-Server
git pull
cd ..
fi
if [ -z "${dir}" ]; then
dir="."
fi
cd ${dir}
echo "Switched to ${PWD}"
if [ -d build-$OS ]; then
rm -rf build-$OS
fi
mkdir -p temp-$OS
mkdir -p build-$OS/OpenBazaar-Server
# Clean past builds in OpenBazaar-Server
rm -rf OpenBazaar-Server/dist/*
#command_exists grunt
command_exists npm
#command_exists wine
# Notes about windows: In windows we want to compile the application for both
# 32 bit and 64 bit versions even if the host operating system is 64 bit.
# To make it possible to run either 32 bit and 64 bit versions of python
# we need to install Python 2.7 32 bit, Python 2.7 64 bit and afterwards
# we need to install latest Python 3 in either 32 or 64 bits. This is needed
# becuase starting with Python 3.3 a launcher is installed that allows us
# to run any python version that is already installed
# by calling either `py.exe -2.7-x64 ` or `py.exe -2.7-32`
# Download OS specific installer files to package
case $OS in win32*)
export OB_OS=win32
command_exists py
echo 'Building Server Binary...'
cd OpenBazaar-Server
py.exe -2.7-32 -m pip install virtualenv
if [ -d env-$OS ]; then
rm -rf env-$OS
fi
if [ -d dist ]; then
rm -rf dist
fi
if [ -d build ]; then
rm -rf build
fi
py.exe -2.7-32 -m virtualenv env-$OS
. env-$OS/scripts/activate
pip install pyinstaller==3.1.1
pip install setuptools==19.2 --upgrade
pip install https://openbazaar.org/downloads/miniupnpc-1.9-cp27-none-win32.whl
pip install https://openbazaar.org/downloads/PyNaCl-0.3.0-cp27-none-win32.whl
pip install setuptools==19.2
pip install -r requirements.txt
pyinstaller --clean
pyinstaller --clean -i ../windows/icon.ico ../openbazaard.win32.spec --win-private-assemblies --noconfirm
cp -rf dist/openbazaard/* ../build-$OS/OpenBazaar-Server
cp ob.cfg ../build-$OS/OpenBazaar-Server
cd ..
echo 'Installing Node modules'
npm install [email protected]
cd OpenBazaar-Client
npm install
echo 'Building Client Binary...'
cd ../temp-$OS
../node_modules/.bin/electron-packager ../OpenBazaar-Client OpenBazaar --asar=true --protocol-name=OpenBazaar --version-string.ProductName=OpenBazaar --protocol=ob --platform=win32 --arch=ia32 --icon=../windows/icon.ico --version=${ELECTRONVER} --overwrite
cd ..
echo 'Copying server files into application folder(s)...'
cp -rf build-$OS/OpenBazaar-Server temp-$OS/OpenBazaar-win32-ia32/resources/
echo 'Copying gpg files into application folder...'
mkdir temp-$OS/OpenBazaar-win32-ia32/resources/gpg/
cd temp-$OS/OpenBazaar-win32-ia32/resources/gpg/
mkdir pub
cp '/c/Program files (x86)/gnu/GnuPG/pub/gpg.exe' pub
cp '/c/Program files (x86)/gnu/GnuPG/gpg2.exe' .
cp '/c/Program files (x86)/gnu/GnuPG/gpgconf.exe' .
cp '/c/Program files (x86)/gnu/GnuPG/libadns-1.dll' .
cp '/c/Program files (x86)/gnu/GnuPG/libassuan-0.dll' .
cp '/c/Program files (x86)/gnu/GnuPG/libgcrypt-20.dll' .
cp '/c/Program files (x86)/gnu/GnuPG/libgpg-error-0.dll' .
cp '/c/Program files (x86)/gnu/GnuPG/libiconv-2.dll' .
echo 'Building Installer...'
npm install -g grunt
npm install --save-dev grunt-electron-installer
# Build full version
grunt create-windows-installer --obversion=$PACKAGE_VERSION --appdir=temp-$OS/OpenBazaar-win32-ia32 --outdir=build-$OS
# Build client-only version
rm -rf build-$OS/OpenBazaar-Server
grunt create-windows-installer --obversion=$PACKAGE_VERSION --clientonly=Client --appdir=temp-$OS/OpenBazaar-win32-ia32 --outdir=build-$OS
cd ../../../../
mv build-$OS/OpenBazaarSetup.exe build-$OS/OpenBazaar-${PACKAGE_VERSION}_Setup_i386.exe
mv build-$OS/RELEASES build-$OS/RELEASES_WIN32
mv "build-$OS/OpenBazaar-$PACKAGE_VERSION-full.nupkg" "build-$OS/OpenBazaar-$PACKAGE_VERSION-i386-full.nupkg"
echo "Do not forget to sign the release before distributing..."
echo "signtool sign /t http://timestamp.digicert.com /a [filename]"
;;
win64*)
export OB_OS=win64
command_exists py
echo 'Building Server Binary...'
cd OpenBazaar-Server
if [ -d env-$OS ]; then
rm -rf env-$OS
fi
if [ -d dist ]; then
rm -rf dist
fi
if [ -d build ]; then
rm -rf build
fi
py.exe -2.7-x64 -m pip install virtualenv
py.exe -2.7-x64 -m virtualenv env-$OS
. env-$OS/scripts/activate
pip install pyinstaller==3.1.1
pip install setuptools==19.2 --upgrade
pip install https://openbazaar.org/downloads/miniupnpc-1.9-cp27-none-win_amd64.whl
pip install https://openbazaar.org/downloads/PyNaCl-0.3.0-cp27-none-win_amd64.whl
pip install -r requirements.txt
rm -rf dist build
pyinstaller --clean -i ../windows/icon.ico ../openbazaard.win.spec --win-private-assemblies --noconfirm
cp -rf dist/openbazaard/* ../build-$OS/OpenBazaar-Server
cp ob.cfg ../build-$OS/OpenBazaar-Server
cd ..
echo 'Installing Node modules'
npm install [email protected]
cd OpenBazaar-Client
npm install
echo 'Building Client Binary...'
cd ../temp-$OS
../node_modules/.bin/electron-packager ../OpenBazaar-Client OpenBazaar --asar=true --protocol-name=OpenBazaar --version-string.ProductName=OpenBazaar --protocol=ob --platform=win32 --arch=x64 --icon=../windows/icon.ico --version=${ELECTRONVER} --overwrite
cd ..
echo 'Copying server files into application folder(s)...'
cp -rf build-$OS/OpenBazaar-Server temp-$OS/OpenBazaar-win32-x64/resources/
echo 'Copying gpg files into application folder...'
mkdir temp-$OS/OpenBazaar-win32-x64/resources/gpg/
cd temp-$OS/OpenBazaar-win32-x64/resources/gpg/
mkdir pub
cp '/c/Program files (x86)/gnu/GnuPG/pub/gpg.exe' pub
cp '/c/Program files (x86)/gnu/GnuPG/gpg2.exe' .
cp '/c/Program files (x86)/gnu/GnuPG/gpgconf.exe' .
cp '/c/Program files (x86)/gnu/GnuPG/libadns-1.dll' .
cp '/c/Program files (x86)/gnu/GnuPG/libassuan-0.dll' .
cp '/c/Program files (x86)/gnu/GnuPG/libgcrypt-20.dll' .
cp '/c/Program files (x86)/gnu/GnuPG/libgpg-error-0.dll' .
cp '/c/Program files (x86)/gnu/GnuPG/libiconv-2.dll' .
echo 'Building Installer...'
npm install -g grunt
npm install --save-dev grunt-electron-installer
grunt create-windows-installer --obversion=$PACKAGE_VERSION --appdir=temp-$OS/OpenBazaar-win32-x64 --outdir=build-$OS
cd ../../../../
mv build-$OS/OpenBazaarSetup.exe "build-$OS/OpenBazaar-${PACKAGE_VERSION}_Setup_x64.exe"
echo "Do not forget to sign the release before distributing..."
echo "signtool sign /t http://timestamp.digicert.com /a [filename]"
;;
osx*)
echo 'Building OS X binary...'
echo 'Cleaning build directories...'
if [ -d build-$OS ]; then
rm -rf build-$OS/*
fi
if [ -d temp-$OS ]; then
rm -rf temp-$OS/*
fi
echo 'Installing node.js packages for installer...'
npm install electron-packager
npm install electron-installer-dmg
echo 'Installing node.js packages for OpenBazaar-Client...'
cd OpenBazaar-Client
npm install
cd ..
echo 'Creating virtualenv and building OpenBazaar-Server binary...'
cd OpenBazaar-Server
virtualenv env
. env/bin/activate
pip install --upgrade pip
pip install --ignore-installed -r requirements.txt
pip install --ignore-installed pyinstaller==3.1
pip install setuptools==19.1
env/bin/pyinstaller -F -n openbazaard -i ../osx/tent.icns --osx-bundle-identifier=com.openbazaar.openbazaard ../openbazaard.mac.spec
echo 'Completed building OpenBazaar-Server binary...'
echo 'Code-signing Daemon binaries...'
codesign --force --sign "$SIGNING_IDENTITY" dist/openbazaard
codesign --force --sign "$SIGNING_IDENTITY" ob.cfg
cd ..
echo 'Packaging Electron application...'
cd temp-$OS
../node_modules/.bin/electron-packager ../OpenBazaar-Client OpenBazaar --app-category-type=public.app-category.business --protocol-name=OpenBazaar --protocol=ob --platform=darwin --arch=x64 --icon=../osx/tent.icns --version=${ELECTRONVER} --overwrite --app-version=$PACKAGE_VERSION
../node_modules/.bin/electron-packager ../OpenBazaar-Client OpenBazaarClient --app-category-type=public.app-category.business --protocol-name=OpenBazaar --protocol=ob --platform=darwin --arch=x64 --icon=../osx/tent.icns --version=${ELECTRONVER} --overwrite --app-version=$PACKAGE_VERSION
cd ..
echo 'Moving .app to build directory...'
mv temp-$OS/OpenBazaar-darwin-x64/* build-$OS/
mv temp-$OS/OpenBazaarClient-darwin-x64/* build-$OS/
rm -rf build-$OS/OpenBazaar-darwin-x64
echo 'Create OpenBazaar-Server folder inside the .app...'
mkdir build-$OS/OpenBazaar.app/Contents/Resources/OpenBazaar-Server
cd OpenBazaar-Server
echo 'Copy binary files to .app folder...'
cp dist/openbazaard ../build-$OS/OpenBazaar.app/Contents/Resources/OpenBazaar-Server
cp ob.cfg ../build-$OS/OpenBazaar.app/Contents/Resources/OpenBazaar-Server
cd ..
echo 'Creating DMG installer from build...'
npm i electron-installer-dmg -g
codesign --force --deep --sign "$SIGNING_IDENTITY" ./build-$OS/OpenBazaar.app
electron-installer-dmg ./build-$OS/OpenBazaar.app OpenBazaar-$PACKAGE_VERSION --icon ./osx/tent.icns --out=./build-$OS --overwrite --background=./osx/finder_background.png --debug
codesign --force --deep --sign "$SIGNING_IDENTITY" ./build-$OS/OpenBazaarClient.app
electron-installer-dmg ./build-$OS/OpenBazaarClient.app OpenBazaarClient-$PACKAGE_VERSION --icon ./osx/tent.icns --out=./build-$OS --overwrite --background=./osx/finder_background.png --debug
echo 'Codesign the DMG and zip'
codesign --force --sign "$SIGNING_IDENTITY" ./build-$OS/OpenBazaar-$PACKAGE_VERSION.dmg
codesign --force --sign "$SIGNING_IDENTITY" ./build-$OS/OpenBazaarClient-$PACKAGE_VERSION.dmg
cd build-$OS
zip -r OpenBazaar-mac-$PACKAGE_VERSION.zip OpenBazaar.app
zip -r OpenBazaarClient-mac-$PACKAGE_VERSION.zip OpenBazaarClient.app
;;
linux32*)
echo "Building Linux binary (ia32)"
echo "Clean/empty build-$OS"
if [ -d build-$OS ]; then
rm -rf build-$OS/*
else
mkdir build-$OS
fi
echo "Create clean temp-$OS folder if necessary"
if ! [ -d temp-$OS ]; then
mkdir -p temp-$OS
else
rm -rf temp-$OS/*
fi
echo "Pull code from GitHub"
branch=master
if ! [ -d OpenBazaar-Server ]; then
echo "Cloning OpenBazaar-Server"
clone_command
else
cd OpenBazaar-Server
git pull
cd ..
fi
echo "Installing npm packages for installer"
sudo apt-get install npm python-pip python-virtualenv python-dev libffi-dev
npm install [email protected]
echo "Installing npm packages for the Client"
cd OpenBazaar-Client
npm install
cd ..
# Build OpenBazaar-Server Binary
echo "Building OpenBazaar-Server binary"
mkdir build-$OS/OpenBazaar-Server
cd OpenBazaar-Server
virtualenv env
. env/bin/activate
pip install -r requirements.txt
pip install pyinstaller==3.1
pip install cryptography
pyinstaller -D -F -n openbazaard ../openbazaard.linux.spec
echo "Copy openbazaard to build folder"
cp dist/openbazaard ../build-$OS/OpenBazaar-Server
cp ob.cfg ../build-$OS/OpenBazaar-Server
echo "Packaging Electron application"
cd ../temp-$OS
../node_modules/.bin/electron-packager ../OpenBazaar-Client openbazaar --platform=linux --arch=all --version=${ELECTRONVER} --overwrite --prune
cd ..
cp -rf build-$OS/OpenBazaar-Server temp-$OS/openbazaar-linux-ia32/resources
sudo npm install -g [email protected]
#npm install -g grunt-cli
#npm install -g grunt-electron-installer --save-dev
#npm install -g grunt-electron-installer-debian --save-dev
sudo npm install -g [email protected]
electron-installer-debian --config linux/config_ia32.json
# Client only install
cd temp-$OS
../node_modules/.bin/electron-packager ../OpenBazaar-Client openbazaarclient --platform=linux --arch=all --version=${ELECTRONVER} --overwrite --prune
cd ..
rm -rf build-$OS/OpenBazaar-Server temp-$OS/openbazaarclient-linux-ia32/resources/OpenBazaar-Server
electron-installer-debian --clientonly=Client --config linux/config_ia32.client.json
echo "Build done in build-$OS"
;;
linux64*)
echo "Building Linux binary (x64)"
echo "Clean/empty build-$OS"
if [ -d build-$OS ]; then
rm -rf build-$OS/*
else
mkdir build-$OS
fi
echo "Create clean temp-$OS folder if necessary"
if ! [ -d temp-$OS ]; then
mkdir -p temp-$OS
else
rm -rf temp-$OS/*
fi
echo "Pull code from GitHub"
branch=master
if ! [ -d OpenBazaar-Server ]; then
echo "Cloning OpenBazaar-Server"
clone_command
else
cd OpenBazaar-Server
git pull
cd ..
fi
echo "Installing npm packages for installer"
sudo apt-get install npm python-pip python-virtualenv python-dev libffi-dev
npm install [email protected]
echo "Installing npm packages for the Client"
cd OpenBazaar-Client
npm install
cd ..
# Build OpenBazaar-Server Binary
echo "Building OpenBazaar-Server binary"
mkdir build-$OS/OpenBazaar-Server
cd OpenBazaar-Server
virtualenv env
. env/bin/activate
pip install -r requirements.txt
pip install pyinstaller==3.1
pip install cryptography
pyinstaller -D -F -n openbazaard ../openbazaard.linux.spec
echo "Copy openbazaard to build folder"
cp dist/openbazaard ../build-$OS/OpenBazaar-Server
cp ob.cfg ../build-$OS/OpenBazaar-Server
echo "Packaging Electron application"
cd ../temp-$OS
../node_modules/.bin/electron-packager ../OpenBazaar-Client openbazaar --platform=linux --arch=all --version=${ELECTRONVER} --overwrite --prune
cd ..
# Copy server daemon and cfg into resources folder
cp -rf build-$OS/OpenBazaar-Server temp-$OS/openbazaar-linux-x64/resources
sudo npm install -g [email protected]
sudo npm install -g [email protected]
electron-installer-debian --config linux/config_amd64.json
# Client only install
cd temp-$OS
../node_modules/.bin/electron-packager ../OpenBazaar-Client openbazaarclient --platform=linux --arch=all --version=${ELECTRONVER} --overwrite --prune
cd ..
rm -rf build-$OS/OpenBazaar-Server temp-$OS/openbazaarclient-linux-x64/resources/OpenBazaar-Server
electron-installer-debian --clientonly=Client --config linux/config_amd64.client.json
echo "Build done in build-$OS"
esac