baa153e94aae45f5330db1e01f2a14336acc7314
[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" "$INSTDIR\${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         ${DisableX64FSRedirection}
106
107         SetOutPath $INSTDIR
108
109         File "../icon/${WIN_APP_EXE}"
110         File "../icon/${WIN_MPD_EXE}"
111
112         SearchPath $1 "javaw.exe"
113
114         ; application elements
115         
116         DeleteRegKey HKCR "${PROG_ID}"
117         DeleteRegKey HKCR "${PROG_ID_MPD}"
118
119         WriteRegStr HKCR "${PROG_ID_MPD}"               ""                              "MicroPeak Data File"
120         WriteRegStr HKCR "${PROG_ID_MPD}"               "FriendlyTypeName"              "MicroPeak Data File"
121         WriteRegStr HKCR "${PROG_ID_MPD}\CurVer"        ""                              "${PROG_ID_MPD}"
122         WriteRegStr HKCR "${PROG_ID_MPD}\DefaultIcon"   ""                              '"$INSTDIR\${WIN_MPD_EXE}",-101'
123   WriteRegExpandStr HKCR "${PROG_ID_MPD}\shell\play\command" ""                         '"$1" -Djava.library.path="$INSTDIR" -jar "$INSTDIR\${FAT_NAME}" "%1"'
124
125         ; .mpd elements
126
127         WriteRegStr HKCR ".mpd"                         ""                              "${PROG_ID_MPD}"
128         WriteRegStr HKCR ".mpd"                         "PerceivedType"                 "MicroPeak Data File"
129         WriteRegStr HKCR ".mpd"                         "Content Type"                  "application/vnd.altusmetrum.micropeak"
130
131         WriteRegStr HKCR ".mpd\OpenWithProgids"         "${PROG_ID_MPD}"                        ""
132         WriteRegStr HKCR ".mpd\${PROG_ID_MPD}"          ""                              "${REG_NAME}"
133
134         Call RefreshShellIcons
135 SectionEnd
136         
137 Section "Uninstaller"
138
139         ; Deal with the uninstaller
140
141         ${DisableX64FSRedirection}
142         SetOutPath $INSTDIR
143
144         ; Write the install path to the registry
145         WriteRegStr HKLM "SOFTWARE\${REG_NAME}" "Install_Dir" "$INSTDIR"
146
147         ; Write the uninstall keys for windows
148         WriteRegStr HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\${REG_NAME}" "DisplayName" "${REG_NAME}"
149         WriteRegStr HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\${REG_NAME}" "UninstallString" '"$INSTDIR\uninstall-${REG_NAME}.exe"'
150         WriteRegStr HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\${REG_NAME}" "NoModify" "1"
151         WriteRegStr HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\${REG_NAME}" "NoRepair" "1"
152
153         WriteUninstaller "uninstall-${REG_NAME}.exe"
154 SectionEnd
155
156 Section "Uninstall"
157
158         ${DisableX64FSRedirection}
159
160         DeleteRegKey   HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\${REG_NAME}"
161         DeleteRegKey   HKLM "SOFTWARE\${REG_NAME}"
162
163         DetailPrint "Delete uninstall reg entries"
164
165         DeleteRegKey   HKCR "${PROG_ID}"
166         DeleteRegKey   HKCR "${PROG_ID_MPD}"
167
168         DeleteRegKey   HKCR ".mpd\${PROG_ID_MPD}"
169         DeleteRegValue HKCR ".mpd\OpenWithProgids" "${PROG_ID_MPD}"
170
171         Delete "$INSTDIR\${FAT_NAME}"
172         Delete "$INSTDIR\uninstall-${REG_NAME}.exe"
173
174         Delete "$INSTDIR\${WIN_APP_ICON}"
175         Delete "$INSTDIR\${WIN_APP_EXE}"
176
177         ; Remove shortcuts, if any
178         Delete "$SMPROGRAMS\${REG_NAME}.lnk"
179         Delete "$DESKTOP\${REG_NAME}.lnk"
180         
181         Call un.RefreshShellIcons
182 SectionEnd