altosuilib: Wait for product data while scanning
[fw/altos] / micropeak / micropeak-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        "MicroPeak"
8 !define PROG_ID         "org.altusmetrum.micropeak.1"
9 !define PROG_ID_MPD     "org.altusmetrum.micropeak.mpd.1"
10 !define FAT_NAME        "micropeak-fat.jar"
11 !define WIN_APP_ICON    "altusmetrum-micropeak.ico"
12 !define WIN_APP_EXE     "altusmetrum-micropeak.exe"
13 !define WIN_MPD_EXE     "application-vnd.altusmetrum.micropeak.exe"
14
15 Name "${REG_NAME} Installer"
16
17 ; Default install directory
18 InstallDir "$PROGRAMFILES\AltusMetrum"
19
20 ; Tell the installer where to re-install a new version
21 InstallDirRegKey HKLM "Software\${REG_NAME}" "Install_Dir"
22
23 LicenseText "GNU General Public License Version 2"
24 LicenseData "../COPYING"
25
26 ; Need admin privs for Vista or Win7
27 RequestExecutionLevel admin
28
29 ShowInstDetails Show
30
31 ComponentText "${REG_NAME} Software and Driver Installer"
32
33 Function .onInit
34         DetailPrint "Checking host operating system"
35         ${If} ${RunningX64}
36                 DetailPrint "Installer running on 64-bit host"
37                 SetRegView 64
38                 StrCpy $INSTDIR "$PROGRAMFILES64\AltusMetrum"
39                 ${DisableX64FSRedirection}
40         ${EndIf}
41 FunctionEnd
42
43 Function un.onInit
44         DetailPrint "Checking host operating system"
45         ${If} ${RunningX64}
46                 DetailPrint "Installer running on 64-bit host"
47                 SetRegView 64
48                 StrCpy $INSTDIR "$PROGRAMFILES64\AltusMetrum"
49                 ${DisableX64FSRedirection}
50         ${EndIf}
51 FunctionEnd
52
53 ; Pages to present
54
55 Page license
56 Page components
57 Page directory
58 Page instfiles
59
60 UninstPage uninstConfirm
61 UninstPage instfiles
62
63 ; And the stuff to install
64
65 Section "FTDI USB Driver"
66         SetOutPath $INSTDIR
67
68         File "CDM20824_Setup.exe"
69
70         StrCpy $2 "$INSTDIR\CDM20824_Setup.exe"
71         ExecWait $2
72 SectionEnd
73
74 Section "Install Driver" InstDriver
75
76         InstDrv::InitDriverSetup /NOUNLOAD {4D36E96D-E325-11CE-BFC1-08002BE10318} AltusMetrumSerial
77         Pop $0
78         DetailPrint "InitDriverSetup: $0"
79         InstDrv::DeleteOemInfFiles /NOUNLOAD
80         InstDrv::CreateDevice /NOUNLOAD
81
82         SetOutPath $INSTDIR
83         File "../altusmetrum.inf"
84         File "../altusmetrum.cat"
85
86         ${DisableX64FSRedirection}
87         IfFileExists $WINDIR\System32\PnPutil.exe 0 nopnp
88                 ${DisableX64FSRedirection}
89                 nsExec::ExecToLog '"$WINDIR\System32\PnPutil.exe" -i -a "$INSTDIR\altusmetrum.inf"'
90                 Goto done
91 nopnp:
92                 InstDrv::InstallDriver /NOUNLOAD "$INSTDIR\altusmetrum.inf"
93 done:
94
95 SectionEnd
96
97 Section "${REG_NAME} Application"
98         Call DetectJRE
99
100         SetOutPath $INSTDIR
101
102         File "${FAT_NAME}"
103         File "altoslib_@ALTOSLIB_VERSION@.jar"
104         File "altosuilib_@ALTOSUILIB_VERSION@.jar"
105         File "jfreechart.jar"
106         File "jcommon.jar"
107
108         File "*.dll"
109
110         File "../icon/${WIN_APP_ICON}"
111
112         CreateShortCut "$SMPROGRAMS\${REG_NAME}.lnk" "$INSTDIR\${FAT_NAME}" "" "$INSTDIR\${WIN_APP_ICON}"
113 SectionEnd
114
115 Section "${REG_NAME} Desktop Shortcut"
116         CreateShortCut "$DESKTOP\${REG_NAME}.lnk" "$INSTDIR\${FAT_NAME}"  "" "$INSTDIR\${WIN_APP_ICON}"
117 SectionEnd
118
119 Section "Documentation"
120
121         SetOutPath $INSTDIR
122
123         File "../doc/micropeak.pdf"
124 SectionEnd
125
126 Section "File Associations"
127
128         ${DisableX64FSRedirection}
129
130         SetOutPath $INSTDIR
131
132         File "../icon/${WIN_APP_EXE}"
133         File "../icon/${WIN_MPD_EXE}"
134
135         SearchPath $1 "javaw.exe"
136
137         ; application elements
138         
139         DeleteRegKey HKCR "${PROG_ID}"
140         DeleteRegKey HKCR "${PROG_ID_MPD}"
141
142         WriteRegStr HKCR "${PROG_ID_MPD}"               ""                              "MicroPeak Data File"
143         WriteRegStr HKCR "${PROG_ID_MPD}"               "FriendlyTypeName"              "MicroPeak Data File"
144         WriteRegStr HKCR "${PROG_ID_MPD}\CurVer"        ""                              "${PROG_ID_MPD}"
145         WriteRegStr HKCR "${PROG_ID_MPD}\DefaultIcon"   ""                              '"$INSTDIR\${WIN_MPD_EXE}",-101'
146   WriteRegExpandStr HKCR "${PROG_ID_MPD}\shell\play\command" ""                         '"$1" -Djava.library.path="$INSTDIR" -jar "$INSTDIR\${FAT_NAME}" "%1"'
147
148         ; .mpd elements
149
150         WriteRegStr HKCR ".mpd"                         ""                              "${PROG_ID_MPD}"
151         WriteRegStr HKCR ".mpd"                         "PerceivedType"                 "MicroPeak Data File"
152         WriteRegStr HKCR ".mpd"                         "Content Type"                  "application/vnd.altusmetrum.micropeak"
153
154         WriteRegStr HKCR ".mpd\OpenWithProgids"         "${PROG_ID_MPD}"                        ""
155         WriteRegStr HKCR ".mpd\${PROG_ID_MPD}"          ""                              "${REG_NAME}"
156
157         Call RefreshShellIcons
158 SectionEnd
159         
160 Section "Uninstaller"
161
162         ; Deal with the uninstaller
163
164         ${DisableX64FSRedirection}
165         SetOutPath $INSTDIR
166
167         ; Write the install path to the registry
168         WriteRegStr HKLM "SOFTWARE\${REG_NAME}" "Install_Dir" "$INSTDIR"
169
170         ; Write the uninstall keys for windows
171         WriteRegStr HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\${REG_NAME}" "DisplayName" "${REG_NAME}"
172         WriteRegStr HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\${REG_NAME}" "UninstallString" '"$INSTDIR\uninstall-${REG_NAME}.exe"'
173         WriteRegStr HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\${REG_NAME}" "NoModify" "1"
174         WriteRegStr HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\${REG_NAME}" "NoRepair" "1"
175
176         WriteUninstaller "uninstall-${REG_NAME}.exe"
177 SectionEnd
178
179 Section "Uninstall"
180
181         ${DisableX64FSRedirection}
182
183         DeleteRegKey   HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\${REG_NAME}"
184         DeleteRegKey   HKLM "SOFTWARE\${REG_NAME}"
185
186         DetailPrint "Delete uninstall reg entries"
187
188         DeleteRegKey   HKCR "${PROG_ID}"
189         DeleteRegKey   HKCR "${PROG_ID_MPD}"
190
191         DeleteRegKey   HKCR ".mpd\${PROG_ID_MPD}"
192         DeleteRegValue HKCR ".mpd\OpenWithProgids" "${PROG_ID_MPD}"
193
194         Delete "$INSTDIR\${FAT_NAME}"
195         Delete "$INSTDIR\uninstall-${REG_NAME}.exe"
196
197         Delete "$INSTDIR\${WIN_APP_ICON}"
198         Delete "$INSTDIR\${WIN_APP_EXE}"
199
200         ; Remove shortcuts, if any
201         Delete "$SMPROGRAMS\${REG_NAME}.lnk"
202         Delete "$DESKTOP\${REG_NAME}.lnk"
203         
204         Call un.RefreshShellIcons
205 SectionEnd