src: Add easymini-v3.0
[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 "Install Driver" InstDriver
66
67         InstDrv::InitDriverSetup /NOUNLOAD {4D36E96D-E325-11CE-BFC1-08002BE10318} AltusMetrumSerial
68         Pop $0
69         DetailPrint "InitDriverSetup: $0"
70         InstDrv::DeleteOemInfFiles /NOUNLOAD
71         InstDrv::CreateDevice /NOUNLOAD
72
73         SetOutPath $INSTDIR
74         File "../altusmetrum.inf"
75         File "../altusmetrum.cat"
76
77         ${DisableX64FSRedirection}
78         IfFileExists $WINDIR\System32\PnPutil.exe 0 nopnp
79                 ${DisableX64FSRedirection}
80                 nsExec::ExecToLog '"$WINDIR\System32\PnPutil.exe" -i -a "$INSTDIR\altusmetrum.inf"'
81                 Goto done
82 nopnp:
83                 InstDrv::InstallDriver /NOUNLOAD "$INSTDIR\altusmetrum.inf"
84 done:
85
86 SectionEnd
87
88 Section "${REG_NAME} Application"
89         Call DetectJRE
90
91         SetOutPath $INSTDIR
92
93         File "${FAT_NAME}"
94         File "altoslib_@ALTOSLIB_VERSION@.jar"
95         File "altosuilib_@ALTOSUILIB_VERSION@.jar"
96         File "jfreechart.jar"
97         File "jcommon.jar"
98         File "../icon/${WIN_APP_EXE}"
99
100         File "*.dll"
101
102         File "../icon/${WIN_APP_ICON}"
103
104         CreateShortCut "$SMPROGRAMS\${REG_NAME}.lnk" "$INSTDIR\${WIN_APP_EXE}" "" "$INSTDIR\${WIN_APP_ICON}"
105 SectionEnd
106
107 Section "${REG_NAME} Desktop Shortcut"
108         CreateShortCut "$DESKTOP\${REG_NAME}.lnk" "$INSTDIR\${WIN_APP_EXE}"  "" "$INSTDIR\${WIN_APP_ICON}"
109 SectionEnd
110
111 Section "FTDI USB Driver"
112         SetOutPath $INSTDIR
113
114         File "CDM_v2.12.00_WHQL_Certified.exe"
115
116         StrCpy $2 "$INSTDIR\CDM_v2.12.00_WHQL_Certified.exe"
117         ExecWait $2
118 SectionEnd
119
120 Section "Documentation"
121
122         SetOutPath $INSTDIR
123
124         File "../doc/micropeak.pdf"
125 SectionEnd
126
127 Section "File Associations"
128
129         ${DisableX64FSRedirection}
130
131         SetOutPath $INSTDIR
132
133         File "../icon/${WIN_MPD_EXE}"
134
135         ; application elements
136         
137         DeleteRegKey HKCR "${PROG_ID}"
138         DeleteRegKey HKCR "${PROG_ID_MPD}"
139
140         WriteRegStr HKCR "${PROG_ID_MPD}"               ""                              "MicroPeak Data File"
141         WriteRegStr HKCR "${PROG_ID_MPD}"               "FriendlyTypeName"              "MicroPeak Data File"
142         WriteRegStr HKCR "${PROG_ID_MPD}\CurVer"        ""                              "${PROG_ID_MPD}"
143         WriteRegStr HKCR "${PROG_ID_MPD}\DefaultIcon"   ""                              '"$INSTDIR\${WIN_MPD_EXE}",-101'
144   WriteRegExpandStr HKCR "${PROG_ID_MPD}\shell\play\command" ""                         '"$INSTDIR\${WIN_APP_EXE}" "%1"'
145
146         ; .mpd elements
147
148         WriteRegStr HKCR ".mpd"                         ""                              "${PROG_ID_MPD}"
149         WriteRegStr HKCR ".mpd"                         "PerceivedType"                 "MicroPeak Data File"
150         WriteRegStr HKCR ".mpd"                         "Content Type"                  "application/vnd.altusmetrum.micropeak"
151
152         WriteRegStr HKCR ".mpd\OpenWithProgids"         "${PROG_ID_MPD}"                        ""
153         WriteRegStr HKCR ".mpd\${PROG_ID_MPD}"          ""                              "${REG_NAME}"
154
155         Call RefreshShellIcons
156 SectionEnd
157         
158 Section "Uninstaller"
159
160         ; Deal with the uninstaller
161
162         ${DisableX64FSRedirection}
163         SetOutPath $INSTDIR
164
165         ; Write the install path to the registry
166         WriteRegStr HKLM "SOFTWARE\${REG_NAME}" "Install_Dir" "$INSTDIR"
167
168         ; Write the uninstall keys for windows
169         WriteRegStr HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\${REG_NAME}" "DisplayName" "${REG_NAME}"
170         WriteRegStr HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\${REG_NAME}" "UninstallString" '"$INSTDIR\uninstall-${REG_NAME}.exe"'
171         WriteRegStr HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\${REG_NAME}" "NoModify" "1"
172         WriteRegStr HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\${REG_NAME}" "NoRepair" "1"
173
174         WriteUninstaller "uninstall-${REG_NAME}.exe"
175 SectionEnd
176
177 Section "Uninstall"
178
179         ${DisableX64FSRedirection}
180
181         DeleteRegKey   HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\${REG_NAME}"
182         DeleteRegKey   HKLM "SOFTWARE\${REG_NAME}"
183
184         DetailPrint "Delete uninstall reg entries"
185
186         DeleteRegKey   HKCR "${PROG_ID}"
187         DeleteRegKey   HKCR "${PROG_ID_MPD}"
188
189         DeleteRegKey   HKCR ".mpd\${PROG_ID_MPD}"
190         DeleteRegValue HKCR ".mpd\OpenWithProgids" "${PROG_ID_MPD}"
191
192         Delete "$INSTDIR\${FAT_NAME}"
193         Delete "$INSTDIR\uninstall-${REG_NAME}.exe"
194
195         Delete "$INSTDIR\${WIN_APP_ICON}"
196         Delete "$INSTDIR\${WIN_APP_EXE}"
197
198         ; Remove shortcuts, if any
199         Delete "$SMPROGRAMS\${REG_NAME}.lnk"
200         Delete "$DESKTOP\${REG_NAME}.lnk"
201         
202         Call un.RefreshShellIcons
203 SectionEnd