altos: Add EasyMega v2.0 to default build
[fw/altos] / altosui / altos-windows.nsi.in
1 !addplugindir Instdrv/NSIS/Plugins
2 !addincludedir Instdrv/NSIS/Includes
3 !include x64.nsh
4 !include java.nsh
5 !include refresh-sh.nsh
6
7 !define REG_NAME        "Altus Metrum"
8 !define PROG_ID_TELEM   "altusmetrum.altosui.telem.1"
9 !define PROG_ID_EEPROM  "altusmetrum.altosui.eeprom.1"
10 !define FAT_NAME        "altosui-fat.jar"
11 !define WIN_APP_ICON    "altusmetrum-altosui.ico"
12 !define WIN_APP_EXE     "altusmetrum-altosui.exe"
13 !define WIN_TELEM_EXE   "application-vnd.altusmetrum.telemetry.exe"
14 !define WIN_EEPROM_EXE  "application-vnd.altusmetrum.eeprom.exe"
15
16 Name "${REG_NAME} Installer"
17
18 ; Default install directory
19 InstallDir "$PROGRAMFILES\AltusMetrum"
20
21 ; Tell the installer where to re-install a new version
22 InstallDirRegKey HKLM "Software\${REG_NAME}" "Install_Dir"
23
24 LicenseText "GNU General Public License Version 2"
25 LicenseData "../COPYING"
26
27 ; Need admin privs for Vista or Win7
28 RequestExecutionLevel admin
29
30 ShowInstDetails Show
31
32 ComponentText "${REG_NAME} Software and Driver Installer"
33
34 Function .onInit
35         DetailPrint "Checking host operating system"
36         ${If} ${RunningX64}
37                 DetailPrint "Installer running on 64-bit host"
38                 SetRegView 64
39                 StrCpy $INSTDIR "$PROGRAMFILES64\AltusMetrum"
40                 ${DisableX64FSRedirection}
41         ${EndIf}
42 FunctionEnd
43
44 Function un.onInit
45         DetailPrint "Checking host operating system"
46         ${If} ${RunningX64}
47                 DetailPrint "Installer running on 64-bit host"
48                 SetRegView 64
49                 StrCpy $INSTDIR "$PROGRAMFILES64\AltusMetrum"
50                 ${DisableX64FSRedirection}
51         ${EndIf}
52 FunctionEnd
53
54 ; Pages to present
55
56 Page license
57 Page components
58 Page directory
59 Page instfiles
60
61 UninstPage uninstConfirm
62 UninstPage instfiles
63
64 ; And the stuff to install
65
66 Section "Install Driver" InstDriver
67
68         InstDrv::InitDriverSetup /NOUNLOAD {4D36E96D-E325-11CE-BFC1-08002BE10318} AltusMetrumSerial
69         Pop $0
70         DetailPrint "InitDriverSetup: $0"
71         InstDrv::DeleteOemInfFiles /NOUNLOAD
72         InstDrv::CreateDevice /NOUNLOAD
73
74         SetOutPath $INSTDIR
75         File "../altusmetrum.inf"
76         File "../altusmetrum.cat"
77
78         ${DisableX64FSRedirection}
79         IfFileExists $WINDIR\System32\PnPutil.exe 0 nopnp
80                 ${DisableX64FSRedirection}
81                 nsExec::ExecToLog '"$WINDIR\System32\PnPutil.exe" -i -a "$INSTDIR\altusmetrum.inf"'
82                 Goto done
83 nopnp:
84                 InstDrv::InstallDriver /NOUNLOAD "$INSTDIR\altusmetrum.inf"
85 done:
86
87 SectionEnd
88
89 Section "${REG_NAME} Application"
90         Call DetectJRE
91
92         SetOutPath $INSTDIR
93
94         File "${FAT_NAME}"
95         File "altoslib_@ALTOSLIB_VERSION@.jar"
96         File "altosuilib_@ALTOSUILIB_VERSION@.jar"
97         File "cmudict04.jar"
98         File "cmulex.jar"
99         File "cmu_time_awb.jar"
100         File "cmutimelex.jar"
101         File "cmu_us_kal.jar"
102         File "en_us.jar"
103         File "freetts.jar"
104         File "jfreechart.jar"
105         File "jcommon.jar"
106         File "../icon/${WIN_APP_EXE}"
107
108         File "*.dll"
109
110         File "../icon/${WIN_APP_ICON}"
111
112         CreateShortCut "$SMPROGRAMS\${REG_NAME}.lnk" "$INSTDIR\${WIN_APP_EXE}" "" "$INSTDIR\${WIN_APP_ICON}"
113 SectionEnd
114
115 Section "${REG_NAME} Desktop Shortcut"
116         CreateShortCut "$DESKTOP\${REG_NAME}.lnk" "$INSTDIR\${WIN_APP_EXE}"  "" "$INSTDIR\${WIN_APP_ICON}"
117 SectionEnd
118
119 Section "Firmware"
120
121         SetOutPath $INSTDIR
122
123         File "../src/telemetrum-v2.0/telemetrum-v2.0-${VERSION}.ihx"
124 ;       File "../src/telemetrum-v3.0/telemetrum-v3.0-${VERSION}.ihx"
125         File "../src/telemini-v3.0/telemini-v3.0-${VERSION}.ihx"
126         File "../src/telegps-v1.0/telegps-v1.0-${VERSION}.ihx"
127         File "../src/telegps-v2.0/telegps-v2.0-${VERSION}.ihx"
128         File "../src/teledongle-v3.0/teledongle-v3.0-${VERSION}.ihx"
129         File "../src/telebt-v3.0/telebt-v3.0-${VERSION}.ihx"
130         File "../src/telebt-v4.0/telebt-v4.0-${VERSION}.ihx"
131         File "../src/telemega-v1.0/telemega-v1.0-${VERSION}.ihx"
132         File "../src/telemega-v2.0/telemega-v2.0-${VERSION}.ihx"
133         File "../src/telemega-v3.0/telemega-v3.0-${VERSION}.ihx"
134         File "../src/easymini-v1.0/easymini-v1.0-${VERSION}.ihx"
135         File "../src/easymini-v2.0/easymini-v2.0-${VERSION}.ihx"
136         File "../src/easymega-v1.0/easymega-v1.0-${VERSION}.ihx"
137
138 SectionEnd
139
140 Section "Documentation"
141
142         SetOutPath $INSTDIR
143
144         File "../doc/altusmetrum.pdf"
145         File "../doc/altos.pdf"
146         File "../doc/telemetry.pdf"
147         File "../doc/telemetrum-outline.pdf"
148         File "../doc/telemega-outline.pdf"
149         File "../doc/easymini-outline.pdf"
150         File "../doc/telemini-v1-outline.pdf"
151         File "../doc/telemini-v3-outline.pdf"
152 SectionEnd
153
154 Section "File Associations"
155
156         ${DisableX64FSRedirection}
157
158         SetOutPath $INSTDIR
159
160         File "../icon/${WIN_TELEM_EXE}"
161         File "../icon/${WIN_EEPROM_EXE}"
162
163         DeleteRegKey HKCR "${PROG_ID_TELEM}"
164         DeleteRegKey HKCR "${PROG_ID_EEPROM}"
165
166         DeleteRegKey   HKCR ".eeprom\${PROG_ID_EEPROM}"
167         DeleteRegValue HKCR ".eeprom\OpenWithProgids" "${PROG_ID_EEPROM}"
168         DeleteRegKey   HKCR ".telem\${PROG_ID_EEPROM}"
169         DeleteRegValue HKCR ".telem\OpenWithProgids" "${PROG_ID_EEPROM}"
170
171         ; .eeprom elements
172
173         WriteRegStr HKCR "${PROG_ID_EEPROM}"            ""                              "Altus Metrum Log File"
174         WriteRegStr HKCR "${PROG_ID_EEPROM}"            "FriendlyTypeName"              "Altus Metrum Log File"
175         WriteRegStr HKCR "${PROG_ID_EEPROM}\CurVer"     ""                              "${PROG_ID_EEPROM}"
176         WriteRegStr HKCR "${PROG_ID_EEPROM}\DefaultIcon" ""                             '"$INSTDIR\${WIN_EEPROM_EXE}",-101'
177   WriteRegExpandStr HKCR "${PROG_ID_EEPROM}\shell\open\command" ""                      '"$INSTDIR\${WIN_APP_EXE}" "%1"'
178
179         WriteRegStr HKCR ".eeprom"                      ""                              "${PROG_ID_EEPROM}"
180         WriteRegStr HKCR ".eeprom"                      "PerceivedType"                 "Altus Metrum Log File"
181         WriteRegStr HKCR ".eeprom"                      "Content Type"                  "application/vnd.altusmetrum.eeprom"
182
183         WriteRegStr HKCR ".eeprom\OpenWithProgids"      "${PROG_ID_EEPROM}"             ""
184         WriteRegStr HKCR ".eeprom\${PROG_ID_EEPROM}"    ""                              "${REG_NAME}"
185         
186         ; .telem elements
187         
188         WriteRegStr HKCR "${PROG_ID_TELEM}"             ""                              "Altus Metrum Telemetry File"
189         WriteRegStr HKCR "${PROG_ID_TELEM}"             "FriendlyTypeName"              "Altus Metrum Telemetry File"
190         WriteRegStr HKCR "${PROG_ID_TELEM}\CurVer"      ""                              "${PROG_ID_TELEM}"
191         WriteRegStr HKCR "${PROG_ID_TELEM}\DefaultIcon" ""                              '"$INSTDIR\${WIN_TELEM_EXE}",-101'
192   WriteRegExpandStr HKCR "${PROG_ID_TELEM}\shell\open\command" ""                       '"$INSTDIR\${WIN_APP_EXE}" "%1"'
193
194         WriteRegStr HKCR ".telem"                       ""                              "${PROG_ID_TELEM}"
195         WriteRegStr HKCR ".telem"                       "PerceivedType"                 "Altus Metrum Telemetry File"
196         WriteRegStr HKCR ".telem"                       "Content Type"                  "application/vnd.altusmetrum.telemetry"
197
198         WriteRegStr HKCR ".telem\OpenWithProgids"       "${PROG_ID_TELEM}"              ""
199         WriteRegStr HKCR ".telem\${PROG_ID_TELEM}"      ""                              "${REG_NAME}"
200
201         Call RefreshShellIcons
202 SectionEnd
203         
204 Section "Uninstaller"
205
206         ; Deal with the uninstaller
207
208         ${DisableX64FSRedirection}
209         SetOutPath $INSTDIR
210
211         ; Write the install path to the registry
212         WriteRegStr HKLM "SOFTWARE\${REG_NAME}" "Install_Dir" "$INSTDIR"
213
214         ; Write the uninstall keys for windows
215         WriteRegStr HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\${REG_NAME}" "DisplayName" "${REG_NAME}"
216         WriteRegStr HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\${REG_NAME}" "UninstallString" '"$INSTDIR\uninstall-${REG_NAME}.exe"'
217         WriteRegStr HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\${REG_NAME}" "NoModify" "1"
218         WriteRegStr HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\${REG_NAME}" "NoRepair" "1"
219
220         WriteUninstaller "uninstall-${REG_NAME}.exe"
221 SectionEnd
222
223 Section "Uninstall"
224
225         ${DisableX64FSRedirection}
226
227         DeleteRegKey   HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\${REG_NAME}"
228         DeleteRegKey   HKLM "SOFTWARE\${REG_NAME}"
229
230         DetailPrint "Delete uninstall reg entries"
231
232         DeleteRegKey   HKCR "${PROG_ID_EEPROM}"
233         DeleteRegKey   HKCR "${PROG_ID_TELEM}"
234
235         DeleteRegKey   HKCR ".eeprom\${PROG_ID_EEPROM}"
236         DeleteRegValue HKCR ".eeprom\OpenWithProgids" "${PROG_ID_EEPROM}"
237
238         DeleteRegKey   HKCR ".telem\${PROG_ID_TELEM}"
239         DeleteRegValue HKCR ".telem\OpenWithProgids" "${PROG_ID_TELEM}"
240
241         DetailPrint "Delete file association reg entries"
242
243         Delete "$INSTDIR\${FAT_NAME}"
244         Delete "$INSTDIR\uninstall-${REG_NAME}.exe"
245
246         Delete "$INSTDIR\${WIN_APP_ICON}"
247         Delete "$INSTDIR\${WIN_APP_EXE}"
248
249         ; Remove shortcuts, if any
250         Delete "$SMPROGRAMS\${REG_NAME}.lnk"
251         Delete "$DESKTOP\${REG_NAME}.lnk"
252         
253         Call un.RefreshShellIcons
254 SectionEnd