Merge remote-tracking branch 'origin/master'
[fw/altos] / altosui / altos-windows.nsi.in
1 !addplugindir Instdrv/NSIS/Plugins
2 !include x64.nsh
3 ; Definitions for Java 1.7 Detection
4 !define JRE_VERSION "1.7"
5 !define JRE_ALTERNATE "1.6"
6 !define JRE32_URL "http://javadl.sun.com/webapps/download/AutoDL?BundleId=83383&/jre-7u51-windows-i586.exe"
7 !define JRE64_URL "http://javadl.sun.com/webapps/download/AutoDL?BundleId=83385&/jre-7u51-windows-x64.exe"
8 !define PRODUCT_NAME "Altus Metrum Windows Software"
9
10 Name "Altus Metrum Installer"
11
12 ; Default install directory
13 InstallDir "$PROGRAMFILES\AltusMetrum"
14
15 ; Tell the installer where to re-install a new version
16 InstallDirRegKey HKLM "Software\AltusMetrum" "Install_Dir"
17
18 LicenseText "GNU General Public License Version 2"
19 LicenseData "../COPYING"
20
21 ; Need admin privs for Vista or Win7
22 RequestExecutionLevel admin
23
24 ShowInstDetails Show
25
26 ComponentText "Altus Metrum Software and Driver Installer"
27
28 Function .onInit
29         DetailPrint "Checking host operating system"
30         ${If} ${RunningX64}
31                 DetailPrint "Installer running on 64-bit host"
32                 SetRegView 64
33                 StrCpy $INSTDIR "$PROGRAMFILES64\AltusMetrum"
34                 ${DisableX64FSRedirection}
35         ${EndIf}
36 FunctionEnd
37
38 Var JavaDownload
39 Var JavaBits
40
41 Function GetJRE
42         ${If} ${RunningX64}
43            StrCpy $JavaDownload ${JRE64_URL}
44            StrCpy $JavaBits "64"
45         ${Else}
46            StrCpy $JavaDownload ${JRE32_URL}
47            StrCpy $JavaBits "32"
48         ${EndIf}
49
50         MessageBox MB_OK "${PRODUCT_NAME} uses Java ${JRE_VERSION}, \
51                         $JavaBits bits, it will now \
52                         be downloaded and installed"
53
54         StrCpy $2 "$TEMP\Java Runtime Environment.exe"
55         nsisdl::download /TIMEOUT=30000 $JavaDownload $2
56         Pop $R0 ;Get the return value
57                 StrCmp $R0 "success" +3
58                 MessageBox MB_OK "Download failed: $R0"
59                 Quit
60         ExecWait $2
61         Delete $2
62 FunctionEnd
63
64 Function DetectJRE
65   ReadRegStr $2 HKLM "SOFTWARE\JavaSoft\Java Runtime Environment" \
66              "CurrentVersion"
67
68   StrCmp $2 ${JRE_VERSION} done
69
70   StrCmp $2 ${JRE_ALTERNATE} done
71
72   Call GetJRE
73
74   done:
75 FunctionEnd
76
77 ; Pages to present
78
79 Page license
80 Page components
81 Page directory
82 Page instfiles
83
84 UninstPage uninstConfirm
85 UninstPage instfiles
86
87 ; And the stuff to install
88
89 Section "Install Driver" InstDriver
90
91         InstDrv::InitDriverSetup /NOUNLOAD {4D36E96D-E325-11CE-BFC1-08002BE10318} AltusMetrumSerial
92         Pop $0
93         DetailPrint "InitDriverSetup: $0"
94         InstDrv::DeleteOemInfFiles /NOUNLOAD
95         InstDrv::CreateDevice /NOUNLOAD
96
97         SetOutPath $INSTDIR
98         File "../altusmetrum.inf"
99         File "../altusmetrum.cat"
100
101         ${DisableX64FSRedirection}
102         IfFileExists $WINDIR\System32\PnPutil.exe 0 nopnp
103                 ${DisableX64FSRedirection}
104                 nsExec::ExecToLog '"$WINDIR\System32\PnPutil.exe" -i -a "$INSTDIR\altusmetrum.inf"'
105                 Goto done
106 nopnp:
107                 InstDrv::InstallDriver /NOUNLOAD "$INSTDIR\altusmetrum.inf"
108 done:
109
110 SectionEnd
111
112 Section "AltosUI Application"
113         Call DetectJRE
114
115         SetOutPath $INSTDIR
116
117         File "altosui-fat.jar"
118         File "altoslib_@ALTOSLIB_VERSION@.jar"
119         File "altosuilib_@ALTOSUILIB_VERSION@.jar"
120         File "cmudict04.jar"
121         File "cmulex.jar"
122         File "cmu_time_awb.jar"
123         File "cmutimelex.jar"
124         File "cmu_us_kal.jar"
125         File "en_us.jar"
126         File "freetts.jar"
127         File "jfreechart.jar"
128         File "jcommon.jar"
129
130         File "*.dll"
131
132         File "../icon/*.ico"
133
134         CreateShortCut "$SMPROGRAMS\AltusMetrum.lnk" "$SYSDIR\javaw.exe" "-jar altosui-fat.jar" "$INSTDIR\altus-metrum.ico"
135 SectionEnd
136
137 Section "AltosUI Desktop Shortcut"
138         CreateShortCut "$DESKTOP\AltusMetrum.lnk" "$INSTDIR\altosui-fat.jar"  "" "$INSTDIR\altus-metrum.ico"
139 SectionEnd
140
141 Section "TeleMetrum, TeleDongle and TeleBT Firmware"
142
143         SetOutPath $INSTDIR
144
145         File "../src/telemetrum-v1.0/telemetrum-v1.0-${VERSION}.ihx"
146         File "../src/telemetrum-v1.1/telemetrum-v1.1-${VERSION}.ihx"
147         File "../src/telemetrum-v1.2/telemetrum-v1.2-${VERSION}.ihx"
148         File "../src/telemini-v1.0/telemini-v1.0-${VERSION}.ihx"
149         File "../src/telegps-v1.0/telegps-v1.0-${VERSION}.ihx"
150         File "../src/teledongle-v0.2/teledongle-v0.2-${VERSION}.ihx"
151         File "../src/telebt-v1.0/telebt-v1.0-${VERSION}.ihx"
152         File "../src/telemega-v1.0/telemega-v1.0-${VERSION}.ihx"
153         File "../src/easymini-v1.0/easymini-v1.0-${VERSION}.ihx"
154
155 SectionEnd
156
157 Section "Documentation"
158
159         SetOutPath $INSTDIR
160
161         File "../doc/altusmetrum.pdf"
162         File "../doc/altos.pdf"
163         File "../doc/telemetry.pdf"
164         File "../doc/telemetrum-outline.pdf"
165         File "../doc/telemega-outline.pdf"
166         File "../doc/easymini-outline.pdf"
167         File "../doc/telemini.pdf"
168 SectionEnd
169
170 Section "Uninstaller"
171
172         ; Deal with the uninstaller
173
174         SetOutPath $INSTDIR
175
176         ; Write the install path to the registry
177         WriteRegStr HKLM SOFTWARE\AltusMetrum "Install_Dir" "$INSTDIR"
178
179         ; Write the uninstall keys for windows
180         WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\AltusMetrum" "DisplayName" "Altus Metrum"
181         WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\AltusMetrum" "UninstallString" '"$INSTDIR\uninstall.exe"'
182         WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\AltusMetrum" "NoModify" "1"
183         WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\AltusMetrum" "NoRepair" "1"
184
185         WriteUninstaller "uninstall.exe"
186 SectionEnd
187
188 Section "Uninstall"
189         DeleteRegKey HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\AltusMetrum"
190         DeleteRegKey HKLM "Software\AltusMetrum"
191
192         Delete "$INSTDIR\*.*"
193         RMDir "$INSTDIR"
194
195         ; Remove devices
196         InstDrv::InitDriverSetup /NOUNLOAD {4D36E96D-E325-11CE-BFC1-08002BE10318} AltusMetrumSerial
197         InstDrv::DeleteOemInfFiles /NOUNLOAD
198         InstDrv::RemoveAllDevices
199
200         ; Remove shortcuts, if any
201         Delete "$SMPROGRAMS\AltusMetrum.lnk"
202         Delete "$DESKTOP\AltusMetrum.lnk"
203         
204 SectionEnd