altos: Make sure pyro remains valid during delay
[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 "${REG_NAME} Application"
75         Call DetectJRE
76
77         SetOutPath $INSTDIR
78
79         File "${FAT_NAME}"
80         File "altoslib_@ALTOSLIB_VERSION@.jar"
81         File "altosuilib_@ALTOSUILIB_VERSION@.jar"
82         File "jfreechart.jar"
83         File "jcommon.jar"
84
85         File "*.dll"
86
87         File "../icon/${WIN_APP_ICON}"
88
89         CreateShortCut "$SMPROGRAMS\${REG_NAME}.lnk" "$SYSDIR\javaw.exe" "-jar ${FAT_NAME}" "$INSTDIR\${WIN_APP_ICON}"
90 SectionEnd
91
92 Section "${REG_NAME} Desktop Shortcut"
93         CreateShortCut "$DESKTOP\${REG_NAME}.lnk" "$INSTDIR\${FAT_NAME}"  "" "$INSTDIR\${WIN_APP_ICON}"
94 SectionEnd
95
96 Section "Documentation"
97
98         SetOutPath $INSTDIR
99
100         File "../doc/micropeak.pdf"
101 SectionEnd
102
103 Section "File Associations"
104
105         SetOutPath $INSTDIR
106
107         File "../icon/${WIN_APP_EXE}"
108         File "../icon/${WIN_MPD_EXE}"
109
110         ; application elements
111         
112         DeleteRegKey HKCR "${PROG_ID}"
113         DeleteRegKey HKCR "${PROG_ID_MPD}"
114
115         WriteRegStr HKCR "${PROG_ID_MPD}"               ""                              "MicroPeak Data File"
116         WriteRegStr HKCR "${PROG_ID_MPD}"               "FriendlyTypeName"              "MicroPeak Data File"
117         WriteRegStr HKCR "${PROG_ID_MPD}\CurVer"        ""                              "${PROG_ID_MPD}"
118         WriteRegStr HKCR "${PROG_ID_MPD}\DefaultIcon"   ""                              '"$INSTDIR\${WIN_MPD_EXE}",-101'
119   WriteRegExpandStr HKCR "${PROG_ID_MPD}\shell\play\command" ""                         '"%SYSTEMROOT%\System32\javaw.exe" -Djava.library.path="$INSTDIR" -jar "$INSTDIR\${FAT_NAME}" "%1"'
120
121         ; .mpd elements
122
123         WriteRegStr HKCR ".mpd"                         ""                              "${PROG_ID_MPD}"
124         WriteRegStr HKCR ".mpd"                         "PerceivedType"                 "MicroPeak Data File"
125         WriteRegStr HKCR ".mpd"                         "Content Type"                  "application/vnd.altusmetrum.micropeak"
126
127         WriteRegStr HKCR ".mpd\OpenWithProgids"         "${PROG_ID_MPD}"                        ""
128         WriteRegStr HKCR ".mpd\${PROG_ID_MPD}"          ""                              "${REG_NAME}"
129
130         Call RefreshShellIcons
131 SectionEnd
132         
133 Section "Uninstaller"
134
135         ; Deal with the uninstaller
136
137         ${DisableX64FSRedirection}
138         SetOutPath $INSTDIR
139
140         ; Write the install path to the registry
141         WriteRegStr HKLM "SOFTWARE\${REG_NAME}" "Install_Dir" "$INSTDIR"
142
143         ; Write the uninstall keys for windows
144         WriteRegStr HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\${REG_NAME}" "DisplayName" "${REG_NAME}"
145         WriteRegStr HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\${REG_NAME}" "UninstallString" '"$INSTDIR\uninstall-${REG_NAME}.exe"'
146         WriteRegStr HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\${REG_NAME}" "NoModify" "1"
147         WriteRegStr HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\${REG_NAME}" "NoRepair" "1"
148
149         WriteUninstaller "uninstall-${REG_NAME}.exe"
150 SectionEnd
151
152 Section "Uninstall"
153
154         ${DisableX64FSRedirection}
155
156         DeleteRegKey   HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\${REG_NAME}"
157         DeleteRegKey   HKLM "SOFTWARE\${REG_NAME}"
158
159         DetailPrint "Delete uninstall reg entries"
160
161         DeleteRegKey   HKCR "${PROG_ID}"
162         DeleteRegKey   HKCR "${PROG_ID_MPD}"
163
164         DeleteRegKey   HKCR ".mpd\${PROG_ID_MPD}"
165         DeleteRegValue HKCR ".mpd\OpenWithProgids" "${PROG_ID_MPD}"
166
167         Delete "$INSTDIR\${FAT_NAME}"
168         Delete "$INSTDIR\uninstall-${REG_NAME}.exe"
169
170         Delete "$INSTDIR\${WIN_APP_ICON}"
171         Delete "$INSTDIR\${WIN_APP_EXE}"
172
173         ; Remove shortcuts, if any
174         Delete "$SMPROGRAMS\${REG_NAME}.lnk"
175         Delete "$DESKTOP\${REG_NAME}.lnk"
176         
177         Call un.RefreshShellIcons
178 SectionEnd