Merge remote-tracking branch 'origin/master'
[fw/altos] / micropeak / micropeak-windows.nsi.in
1 !addplugindir Instdrv/NSIS/Plugins
2 ; Definitions for Java 1.6 Detection
3 !define JRE_VERSION "1.6"
4 !define JRE_ALTERNATE "1.7"
5 !define JRE_URL "http://javadl.sun.com/webapps/download/AutoDL?BundleId=52247&/jre-6u27-windows-i586-p.exe"
6 !define PRODUCT_NAME "Altus Metrum Windows Software"
7
8 Name "Altus Metrum MicroPeak Installer"
9
10 ; Default install directory
11 InstallDir "$PROGRAMFILES\AltusMetrum"
12
13 ; Tell the installer where to re-install a new version
14 InstallDirRegKey HKLM "Software\AltusMetrum" "Install_Dir"
15
16 LicenseText "GNU General Public License Version 2"
17 LicenseData "../COPYING"
18
19 ; Need admin privs for Vista or Win7
20 RequestExecutionLevel admin
21
22 ShowInstDetails Show
23
24 ComponentText "Altus Metrum MicroPeak Software Installer"
25
26 Function GetJRE
27         MessageBox MB_OK "${PRODUCT_NAME} uses Java ${JRE_VERSION} 32-bit, it will now \
28                          be downloaded and installed"
29
30         StrCpy $2 "$TEMP\Java Runtime Environment.exe"
31         nsisdl::download /TIMEOUT=30000 ${JRE_URL} $2
32         Pop $R0 ;Get the return value
33                 StrCmp $R0 "success" +3
34                 MessageBox MB_OK "Download failed: $R0"
35                 Quit
36         ExecWait $2
37         Delete $2
38 FunctionEnd
39
40
41 Function DetectJRE
42   ReadRegStr $2 HKLM "SOFTWARE\JavaSoft\Java Runtime Environment" \
43              "CurrentVersion"
44   StrCmp $2 ${JRE_VERSION} done
45
46   StrCmp $2 ${JRE_ALTERNATE} done
47
48   Call GetJRE
49
50   done:
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 "MicroPeak Application"
66         Call DetectJRE
67
68         SetOutPath $INSTDIR
69
70         File "micropeak-fat.jar"
71         File "altoslib_@ALTOSLIB_VERSION@.jar"
72         File "altosuilib_@ALTOSUILIB_VERSION@.jar"
73         File "jfreechart.jar"
74         File "jcommon.jar"
75
76         File "*.dll"
77
78         File "../icon/*.ico"
79
80         CreateShortCut "$SMPROGRAMS\MicroPeak.lnk" "$SYSDIR\javaw.exe" "-jar micropeak-fat.jar" "$INSTDIR\micro-peak.ico"
81 SectionEnd
82
83 Section "FTDI USB Driver"
84         SetOutPath $INSTDIR
85
86         File "CDM20824_Setup.exe"
87
88         StrCpy $2 "$INSTDIR\CDM20824_Setup.exe"
89         ExecWait $2
90 SectionEnd
91
92 Section "MicroPeak Desktop Shortcut"
93         CreateShortCut "$DESKTOP\MicroPeak.lnk" "$INSTDIR\micropeak-fat.jar"  "" "$INSTDIR\micro-peak.ico"
94 SectionEnd
95
96 Section "Documentation"
97
98         SetOutPath $INSTDIR
99
100         File "../doc/micropeak.pdf"
101 SectionEnd
102
103 Section "Uninstaller"
104
105         ; Deal with the uninstaller
106
107         SetOutPath $INSTDIR
108
109         ; Write the install path to the registry
110         WriteRegStr HKLM SOFTWARE\AltusMetrum "Install_Dir" "$INSTDIR"
111
112         ; Write the uninstall keys for windows
113         WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\AltusMetrum" "DisplayName" "Altus Metrum"
114         WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\AltusMetrum" "UninstallString" '"$INSTDIR\uninstall.exe"'
115         WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\AltusMetrum" "NoModify" "1"
116         WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\AltusMetrum" "NoRepair" "1"
117
118         WriteUninstaller "uninstall.exe"
119 SectionEnd
120
121 Section "Uninstall"
122         DeleteRegKey HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\AltusMetrum"
123         DeleteRegKey HKLM "Software\AltusMetrum"
124
125         Delete "$INSTDIR\*.*"
126         RMDir "$INSTDIR"
127
128         ; Remove shortcuts, if any
129         Delete "$SMPROGRAMS\MicroPeak.lnk"
130         Delete "$DESKTOP\MicroPeak.lnk"
131         
132 SectionEnd