Linux/Wine based build scripts for Windows executables and installer
[electrum-nvc.git] / contrib / build-wine / build-wine.sh
1 #!/bin/bash
2
3 # call "./build-wine.sh" to build everything from scratch
4 # call "./build-wine.sh update" to skip building full environment (it re-download only Electrum)
5
6 # You probably need to update only this link
7 ELECTRUM_URL=https://github.com/downloads/spesmilo/electrum/Electrum-1.5.6.tar.gz
8 NAME_ROOT=electrum-1.5.6
9
10 # Please update these links carefully, some versions won't work under Wine
11 PYTHON_URL=http://www.python.org/ftp/python/2.6.6/python-2.6.6.msi
12 PYQT4_URL=http://sourceforge.net/projects/pyqt/files/PyQt4/PyQt-4.9.5/PyQt-Py2.6-x86-gpl-4.9.5-1.exe
13 PYWIN32_URL=http://sourceforge.net/projects/pywin32/files/pywin32/Build%20218/pywin32-218.win32-py2.6.exe/download
14 PYINSTALLER_URL=https://github.com/downloads/pyinstaller/pyinstaller/pyinstaller-2.0.zip
15 NSIS_URL=http://prdownloads.sourceforge.net/nsis/nsis-2.46-setup.exe?download
16 #ZBAR_URL=http://sourceforge.net/projects/zbar/files/zbar/0.10/zbar-0.10-setup.exe/download
17
18 # These settings probably don't need change
19 export WINEPREFIX=~/.wine-electrum
20 PYHOME=c:/python26
21 PYTHON="wine $PYHOME/python.exe -OO -B"
22
23 # Let's begin!
24 cd `dirname $0`
25 set -e
26
27 if [ "x$1" != "xupdate" ]; then
28
29     # Clean Wine environment
30     echo "Cleaning $WINEPREFIX"
31     rm -rf $WINEPREFIX
32     echo "done"
33
34     echo "Cleaning tmp"
35     rm -rf tmp
36     mkdir -p tmp
37     echo "done"
38
39     cd tmp
40
41     # Install Python
42     wget -O python.msi "$PYTHON_URL"
43     msiexec /q /i python.msi
44
45     # Install PyWin32
46     wget -O pywin32.exe "$PYWIN32_URL"
47     wine pywin32.exe
48
49     # Install PyQt4
50     wget -O PyQt.exe "$PYQT4_URL"
51     wine PyQt.exe
52
53     #cp -r /electrum-wine/pyinstaller $WINEPREFIX/drive_c/
54     # Install pyinstaller
55     wget -O pyinstaller.zip "$PYINSTALLER_URL"
56     unzip pyinstaller.zip
57     mv pyinstaller-2.0 $WINEPREFIX/drive_c/pyinstaller
58
59     # Patch pyinstaller's DummyZlib
60     patch $WINEPREFIX/drive_c/pyinstaller/PyInstaller/loader/archive.py < ../archive.patch
61
62     # Install ZBar
63     #wget -q -O zbar.exe "http://sourceforge.net/projects/zbar/files/zbar/0.10/zbar-0.10-setup.exe/download"
64     #wine zbar.exe
65
66     # Install dependencies
67     wget -q -O - "http://python-distribute.org/distribute_setup.py" | $PYTHON
68     wine "$PYHOME\\Scripts\\easy_install.exe" ecdsa slowaes #zbar
69
70     # Install NSIS installer
71     wget -q -O nsis.exe "http://prdownloads.sourceforge.net/nsis/nsis-2.46-setup.exe?download"
72     wine nsis.exe
73
74     # Install UPX
75     #wget -O upx.zip "http://upx.sourceforge.net/download/upx308w.zip"
76     #unzip -o upx.zip
77     #cp upx*/upx.exe .
78  
79     cd ..
80 fi
81
82 cd tmp
83
84 # Download and unpack Electrum
85 wget -O electrum.tgz "$ELECTRUM_URL"
86 tar xf electrum.tgz
87 mv Electrum-* electrum
88 rm -rf $WINEPREFIX/drive_c/electrum
89 mv electrum $WINEPREFIX/drive_c
90
91 # Copy ZBar libraries to electrum    
92 #cp "$WINEPREFIX/drive_c/Program Files (x86)/ZBar/bin/"*.dll "$WINEPREFIX/drive_c/electrum/"
93
94 cd ..
95
96 rm -rf dist/$NAME_ROOT
97 rm -f dist/$NAME_ROOT.zip
98 rm -f dist/$NAME_ROOT.exe
99 rm -f dist/$NAME_ROOT-setup.exe
100
101 # For building standalone compressed EXE, run:
102 $PYTHON "C:/pyinstaller/pyinstaller.py" --noconfirm --ascii -w --onefile "C:/electrum/electrum"
103
104 # For building uncompressed directory of dependencies, run:
105 $PYTHON "C:/pyinstaller/pyinstaller.py" --noconfirm --ascii -w deterministic.spec
106
107 # For building NSIS installer, run:
108 wine "$WINEPREFIX/drive_c/Program Files (x86)/NSIS/makensis.exe" electrum.nsis
109 #wine $WINEPREFIX/drive_c/Program\ Files\ \(x86\)/NSIS/makensis.exe electrum.nsis
110
111 cd dist
112 mv electrum.exe $NAME_ROOT.exe
113 mv electrum $NAME_ROOT
114 mv electrum-setup.exe $NAME_ROOT-setup.exe
115 zip -r $NAME_ROOT.zip $NAME_ROOT