forked from Blazemeter/taurus
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build-windows-installer.sh
executable file
·170 lines (143 loc) · 3.57 KB
/
build-windows-installer.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
#!/bin/bash
set -euo pipefail
TAURUS_VERSION=$(python -c 'import bzt; print(bzt.VERSION)')
INSTALLER_NAME="TaurusInstaller_${TAURUS_VERSION}_x64.exe"
BUILD_DIR="$(dirname $0)/build/nsis"
ICON_RELPATH="../../site/img/taurus.ico" # must have this path relative to the build dir
rm -rf "$BUILD_DIR"
mkdir -p "$BUILD_DIR"
if [ "$#" -ne 1 ]
then
echo "Usage: $0 <build_file>"
exit 1
fi
if ! [ -e "$1" ]; then
echo "$1 not found" >&2
exit 1
fi
BUILD_FILE="$1"
BASE_BUILD_FILE=$(basename "$BUILD_FILE")
# create NSIS script
cat << EOF > "$BUILD_DIR/taurus.nsi"
[% extends "pyapp_installpy.nsi" %]
[% block install_commands %]
[[ super() ]]
; Install fresh pip
nsExec::ExecToLog 'py -m pip install --upgrade pip>=8.1.2'
Pop \$0
IntCmp \$0 0 InstalledPip CantInstallPip CantInstallPip
InstalledPip:
; Install Taurus
nsExec::ExecToLog 'py -m pip install --upgrade "\$INSTDIR\\${BASE_BUILD_FILE}"'
Pop \$0
IntCmp \$0 0 InstalledBzt CantInstallBzt CantInstallBzt
InstalledBzt:
; Move chrome-loader to resources
nsExec::ExecToLog 'py -c "from bzt.modules.proxy2jmx import inject_loader; inject_loader(\"\$INSTDIR\")"'
Goto EndInstall
CantInstallPip:
DetailPrint "Error: can't install pip"
Abort
Goto EndInstall
CantInstallBzt:
DetailPrint "Error: can't install Taurus"
Abort
Goto EndInstall
EndInstall:
[% endblock %]
[% block uninstall_commands %]
[[ super() ]]
; Remove chrome-loader
nsExec::ExecToLog 'py -c "from bzt.modules.proxy2jmx import remove_loader; remove_loader()"'
nsExec::ExecToLog 'py -m pip uninstall -y bzt'
[% endblock %]
[% block uninstall_files %]
[[ super() ]]
; Remove installation log
Delete "\$INSTDIR\install.log"
[% endblock %]
[% block sections %]
[[ super() ]]
Section
; Dump installation log
StrCpy \$0 "\$INSTDIR\install.log"
Push \$0
Call DumpLog
SectionEnd
!define LVM_GETITEMCOUNT 0x1004
!define LVM_GETITEMTEXT 0x102D
Function DumpLog
Exch \$5
Push \$0
Push \$1
Push \$2
Push \$3
Push \$4
Push \$6
FindWindow \$0 "#32770" "" \$HWNDPARENT
GetDlgItem \$0 \$0 1016
StrCmp \$0 0 exit
FileOpen \$5 \$5 "w"
StrCmp \$5 "" exit
SendMessage \$0 \${LVM_GETITEMCOUNT} 0 0 \$6
System::Alloc \${NSIS_MAX_STRLEN}
Pop \$3
StrCpy \$2 0
System::Call "*(i, i, i, i, i, i, i, i, i) i \
(0, 0, 0, 0, 0, r3, \${NSIS_MAX_STRLEN}) .r1"
loop: StrCmp \$2 \$6 done
System::Call "User32::SendMessageA(i, i, i, i) i \
(\$0, \${LVM_GETITEMTEXT}, \$2, r1)"
System::Call "*\$3(&t\${NSIS_MAX_STRLEN} .r4)"
FileWrite \$5 "\$4$\r\$\n"
IntOp \$2 \$2 + 1
Goto loop
done:
FileClose \$5
System::Free \$1
System::Free \$3
exit:
Pop \$6
Pop \$4
Pop \$3
Pop \$2
Pop \$1
Pop \$0
Exch \$5
FunctionEnd
[% endblock %]
EOF
cat << EOF > "$BUILD_DIR/bzt_win.py"
import os, sys
def main():
sys.exit(os.system("cmd /k bzt --help"))
EOF
# Create pynsist config
cat << EOF > "$BUILD_DIR/installer.cfg"
[Application]
name=Taurus
version=${TAURUS_VERSION}
entry_point=bzt_win:main
console=true
icon=${ICON_RELPATH}
[Command bzt]
entry_point=bzt.cli:main
[Command jmx2yaml]
entry_point=bzt.jmx2yaml:main
[Command soapui2yaml]
entry_point=bzt.soapui2yaml:main
[Python]
version=3.5.3
bitness=64
[Include]
files = tmp/chrome-loader.exe
../../${BUILD_FILE}
[Build]
nsi_template=taurus.nsi
directory=.
installer_name=${INSTALLER_NAME}
EOF
mkdir "$BUILD_DIR"/tmp
x86_64-w64-mingw32-gcc -std=c99 -o "$BUILD_DIR"/tmp/chrome-loader.exe bzt/resources/chrome-loader.c
pynsist "$BUILD_DIR/installer.cfg"
# Installer was saved to ${BUILD_DIR}/${INSTALLER_NAME}