Merge branch 'master' of ssh://git.gag.com/scm/git/fw/altos
[fw/altos] / telegps / telegps-windows.nsi.in
1 !addplugindir ../altosui/Instdrv/NSIS/Plugins
2 !addincludedir ../altosui/Instdrv/NSIS/Includes
3 !include x64.nsh
4 !include java.nsh
5 !include refresh-sh.nsh
6
7 !define REG_NAME        "TeleGPS"
8 !define PROG_ID_TELEM   "altusmetrum.telegps.telem.1"
9 !define PROG_ID_EEPROM  "altusmetrum.telegps.eeprom.1"
10 !define FAT_NAME        "telegps-fat.jar"
11 !define WIN_APP_ICON    "altusmetrum-telegps.ico"
12 !define WIN_APP_EXE     "altusmetrum-telegps.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
107         File "*.dll"
108
109         File "../icon/${WIN_APP_ICON}"
110
111         CreateShortCut "$SMPROGRAMS\${REG_NAME}.lnk" "$SYSDIR\javaw.exe" "-jar ${FAT_NAME}" "$INSTDIR\${WIN_APP_ICON}"
112 SectionEnd
113
114 Section "${REG_NAME} Desktop Shortcut"
115         CreateShortCut "$DESKTOP\${REG_NAME}.lnk" "$INSTDIR\${FAT_NAME}"  "" "$INSTDIR\${WIN_APP_ICON}"
116 SectionEnd
117
118 Section "TeleGPS, TeleDongle and TeleBT Firmware"
119
120         SetOutPath $INSTDIR
121
122         File "../src/telegps-v1.0/telegps-v1.0-${VERSION}.ihx"
123         File "../src/teledongle-v0.2/teledongle-v0.2-${VERSION}.ihx"
124         File "../src/telebt-v1.0/telebt-v1.0-${VERSION}.ihx"
125
126 SectionEnd
127
128 Section "Documentation"
129
130         SetOutPath $INSTDIR
131
132         File "../doc/telegps.pdf"
133         File "../doc/altos.pdf"
134         File "../doc/telemetry.pdf"
135 SectionEnd
136
137 Section "File Associations"
138
139         ${DisableX64FSRedirection}
140
141         SetOutPath $INSTDIR
142
143         File "../icon/${WIN_APP_EXE}"
144         File "../icon/${WIN_TELEM_EXE}"
145         File "../icon/${WIN_EEPROM_EXE}"
146
147         DeleteRegKey HKCR "${PROG_ID_TELEM}"
148         DeleteRegKey HKCR "${PROG_ID_EEPROM}"
149
150         DeleteRegKey   HKCR ".eeprom\${PROG_ID_EEPROM}"
151         DeleteRegValue HKCR ".eeprom\OpenWithProgids" "${PROG_ID_EEPROM}"
152         DeleteRegKey   HKCR ".telem\${PROG_ID_EEPROM}"
153         DeleteRegValue HKCR ".telem\OpenWithProgids" "${PROG_ID_EEPROM}"
154
155         ; .eeprom elements
156
157         WriteRegStr HKCR "${PROG_ID_EEPROM}"            ""                              "Altus Metrum Log File"
158         WriteRegStr HKCR "${PROG_ID_EEPROM}"            "FriendlyTypeName"              "Altus Metrum Log File"
159         WriteRegStr HKCR "${PROG_ID_EEPROM}\CurVer"     ""                              "${PROG_ID_EEPROM}"
160         WriteRegStr HKCR "${PROG_ID_EEPROM}\DefaultIcon" ""                             '"$INSTDIR\${WIN_EEPROM_EXE}",-101'
161   WriteRegExpandStr HKCR "${PROG_ID_EEPROM}\shell\open\command" ""                      '"%SYSTEMROOT%\System32\javaw.exe" -Djava.library.path="$INSTDIR" -jar "$INSTDIR\${FAT_NAME}" "%1"'
162
163         WriteRegStr HKCR ".eeprom"                      ""                              "${PROG_ID_EEPROM}"
164         WriteRegStr HKCR ".eeprom"                      "PerceivedType"                 "Altus Metrum Log File"
165         WriteRegStr HKCR ".eeprom"                      "Content Type"                  "application/vnd.altusmetrum.eeprom"
166
167         WriteRegStr HKCR ".eeprom\OpenWithProgids"      "${PROG_ID_EEPROM}"             ""
168         WriteRegStr HKCR ".eeprom\${PROG_ID_EEPROM}"    ""                              "${REG_NAME}"
169         
170         ; .telem elements
171         
172         WriteRegStr HKCR "${PROG_ID_TELEM}"             ""                              "Altus Metrum Telemetry File"
173         WriteRegStr HKCR "${PROG_ID_TELEM}"             "FriendlyTypeName"              "Altus Metrum Telemetry File"
174         WriteRegStr HKCR "${PROG_ID_TELEM}\CurVer"      ""                              "${PROG_ID_TELEM}"
175         WriteRegStr HKCR "${PROG_ID_TELEM}\DefaultIcon" ""                              '"$INSTDIR\${WIN_TELEM_EXE}",-101'
176   WriteRegExpandStr HKCR "${PROG_ID_TELEM}\shell\open\command" ""                       '"%SYSTEMROOT%\System32\javaw.exe" -Djava.library.path="$INSTDIR" -jar "$INSTDIR\${FAT_NAME}" "%1"'
177
178         WriteRegStr HKCR ".telem"                       ""                              "${PROG_ID_TELEM}"
179         WriteRegStr HKCR ".telem"                       "PerceivedType"                 "Altus Metrum Telemetry File"
180         WriteRegStr HKCR ".telem"                       "Content Type"                  "application/vnd.altusmetrum.telemetry"
181
182         WriteRegStr HKCR ".telem\OpenWithProgids"       "${PROG_ID_TELEM}"              ""
183         WriteRegStr HKCR ".telem\${PROG_ID_TELEM}"      ""                              "${REG_NAME}"
184
185         Call RefreshShellIcons
186 SectionEnd
187         
188 Section "Uninstaller"
189
190         ; Deal with the uninstaller
191
192         ${DisableX64FSRedirection}
193         SetOutPath $INSTDIR
194
195         ; Write the install path to the registry
196         WriteRegStr HKLM "SOFTWARE\${REG_NAME}" "Install_Dir" "$INSTDIR"
197
198         ; Write the uninstall keys for windows
199         WriteRegStr HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\${REG_NAME}" "DisplayName" "${REG_NAME}"
200         WriteRegStr HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\${REG_NAME}" "UninstallString" '"$INSTDIR\uninstall-${REG_NAME}.exe"'
201         WriteRegStr HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\${REG_NAME}" "NoModify" "1"
202         WriteRegStr HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\${REG_NAME}" "NoRepair" "1"
203
204         WriteUninstaller "uninstall-${REG_NAME}.exe"
205 SectionEnd
206
207 Section "Uninstall"
208
209         ${DisableX64FSRedirection}
210
211         DeleteRegKey   HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\${REG_NAME}"
212         DeleteRegKey   HKLM "SOFTWARE\${REG_NAME}"
213
214         DetailPrint "Delete uninstall reg entries"
215
216         DeleteRegKey   HKCR "${PROG_ID_EEPROM}"
217         DeleteRegKey   HKCR "${PROG_ID_TELEM}"
218
219         DeleteRegKey   HKCR ".eeprom\${PROG_ID_EEPROM}"
220         DeleteRegValue HKCR ".eeprom\OpenWithProgids" "${PROG_ID_EEPROM}"
221
222         DeleteRegKey   HKCR ".telem\${PROG_ID_TELEM}"
223         DeleteRegValue HKCR ".telem\OpenWithProgids" "${PROG_ID_TELEM}"
224
225         DetailPrint "Delete file association reg entries"
226
227         Delete "$INSTDIR\${FAT_NAME}"
228         Delete "$INSTDIR\uninstall-${REG_NAME}.exe"
229
230         Delete "$INSTDIR\${WIN_APP_ICON}"
231         Delete "$INSTDIR\${WIN_APP_EXE}"
232
233         ; Remove shortcuts, if any
234         Delete "$SMPROGRAMS\${REG_NAME}.lnk"
235         Delete "$DESKTOP\${REG_NAME}.lnk"
236         
237         Call un.RefreshShellIcons
238 SectionEnd