82a538c19958709409a677ec3dcf51aae0081123
[deb_libcec.git] / project / libCEC.nsi
1 ;libCEC installer
2 ;Copyright (C) 2012 Pulse-Eight Ltd.
3 ;http://www.pulse-eight.com/
4
5 !include "MUI2.nsh"
6 !include "nsDialogs.nsh"
7 !include "LogicLib.nsh"
8 !include "x64.nsh"
9
10 Name "Pulse-Eight USB-CEC Adapter"
11 OutFile "..\build\libCEC-installer.exe"
12
13 XPStyle on
14 InstallDir "$PROGRAMFILES\Pulse-Eight\USB-CEC Adapter"
15 InstallDirRegKey HKLM "Software\Pulse-Eight\USB-CEC Adapter software" ""
16 RequestExecutionLevel admin
17 Var StartMenuFolder
18
19 !define MUI_FINISHPAGE_LINK "Visit http://www.pulse-eight.com/ for more information."
20 !define MUI_FINISHPAGE_LINK_LOCATION "http://www.pulse-eight.com/"
21 !define MUI_ABORTWARNING
22
23 !insertmacro MUI_PAGE_WELCOME
24 !insertmacro MUI_PAGE_LICENSE "..\COPYING"
25 !insertmacro MUI_PAGE_COMPONENTS
26 !insertmacro MUI_PAGE_DIRECTORY
27
28 !define MUI_STARTMENUPAGE_REGISTRY_ROOT "HKLM"
29 !define MUI_STARTMENUPAGE_REGISTRY_KEY "Software\Pulse-Eight\USB-CEC Adapter sofware"
30 !define MUI_STARTMENUPAGE_REGISTRY_VALUENAME "Start Menu Folder"
31 !insertmacro MUI_PAGE_STARTMENU Application $StartMenuFolder
32
33 !insertmacro MUI_PAGE_INSTFILES
34 !insertmacro MUI_PAGE_FINISH
35
36 !insertmacro MUI_UNPAGE_WELCOME
37 !insertmacro MUI_UNPAGE_CONFIRM
38 !insertmacro MUI_UNPAGE_INSTFILES
39 !insertmacro MUI_UNPAGE_FINISH
40
41 !insertmacro MUI_LANGUAGE "English"
42
43 InstType "USB-CEC driver & libCEC"
44 InstType "USB-CEC driver only"
45 InstType "Full installation"
46
47 Section "USB-CEC driver" SecDriver
48 SetShellVarContext current
49 SectionIn RO
50 SectionIn 1 2 3
51
52 ; Uninstall the old unsigned software if it's found
53 ReadRegStr $1 HKCU "Software\libCEC" ""
54 ${If} $1 != ""
55 MessageBox MB_OK \
56 "A previous libCEC and USB-CEC driver was found. This update requires the old version to be uninstalled. Press OK to uninstall the old version."
57 ExecWait '"$1\Uninstall.exe" /S _?=$1'
58 Delete "$1\Uninstall.exe"
59 RMDir "$1"
60 ${EndIf}
61
62 ; Delete libcec.dll and libcec.x64.dll from the system directory
63 ; Let a seperate installer do this, when we need it
64 Delete "$SYSDIR\libcec.dll"
65 ${If} ${RunningX64}
66 Delete "$SYSDIR\libcec.x64.dll"
67 ${EndIf}
68
69 ; Copy to the installation directory
70 SetOutPath "$INSTDIR"
71 File "..\AUTHORS"
72 File "..\COPYING"
73
74 ; Copy the driver installer
75 SetOutPath "$INSTDIR\driver"
76 File "..\build\p8-usbcec-driver-installer.exe"
77
78 ;Store installation folder
79 WriteRegStr HKLM "Software\Pulse-Eight\USB-CEC Adapter software" "" $INSTDIR
80
81 ;Create uninstaller
82 WriteUninstaller "$INSTDIR\Uninstall.exe"
83
84 !insertmacro MUI_STARTMENU_WRITE_BEGIN Application
85 SetOutPath "$INSTDIR"
86
87 CreateDirectory "$SMPROGRAMS\$StartMenuFolder"
88 CreateShortCut "$SMPROGRAMS\$StartMenuFolder\Uninstall Pulse-Eight USB-CEC Adapter software.lnk" "$INSTDIR\Uninstall.exe" \
89 "" "$INSTDIR\Uninstall.exe" 0 SW_SHOWNORMAL \
90 "" "Uninstall Pulse-Eight USB-CEC Adapter software."
91
92 WriteINIStr "$SMPROGRAMS\$StartMenuFolder\Visit Pulse-Eight.url" "InternetShortcut" "URL" "http://www.pulse-eight.com/"
93 !insertmacro MUI_STARTMENU_WRITE_END
94
95 ;add entry to add/remove programs
96 WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Pulse-Eight USB-CEC Adapter sofware" \
97 "DisplayName" "Pulse-Eight USB-CEC Adapter software"
98 WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Pulse-Eight USB-CEC Adapter sofware" \
99 "UninstallString" "$INSTDIR\uninstall.exe"
100 WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Pulse-Eight USB-CEC Adapter sofware" \
101 "NoModify" 1
102 WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Pulse-Eight USB-CEC Adapter sofware" \
103 "NoRepair" 1
104 WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Pulse-Eight USB-CEC Adapter sofware" \
105 "InstallLocation" "$INSTDIR"
106 WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Pulse-Eight USB-CEC Adapter sofware" \
107 "DisplayIcon" "$INSTDIR\cec-client.exe,0"
108 WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Pulse-Eight USB-CEC Adapter sofware" \
109 "Publisher" "Pulse-Eight Limited"
110 WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Pulse-Eight USB-CEC Adapter sofware" \
111 "HelpLink" "http://www.pulse-eight.com/"
112 WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Pulse-Eight USB-CEC Adapter sofware" \
113 "URLInfoAbout" "http://www.pulse-eight.com"
114
115 ;install driver
116 ExecWait '"$INSTDIR\driver\p8-usbcec-driver-installer.exe" /S'
117 Delete "$INSTDIR\driver\p8-usbcec-driver-installer.exe"
118 SectionEnd
119
120 Section "libCEC" SecLibCec
121 SetShellVarContext current
122 SectionIn 1 3
123
124 ; Copy to the installation directory
125 SetOutPath "$INSTDIR"
126 File "..\ChangeLog"
127 File "..\README"
128 File "..\build\*.dll"
129 SetOutPath "$INSTDIR\x64"
130 File /nonfatal "..\build\x64\*.dll"
131
132 ; Copy to XBMC\system
133 ReadRegStr $1 HKCU "Software\XBMC" ""
134 ${If} $1 != ""
135 SetOutPath "$1\system"
136 File "..\build\libcec.dll"
137 ${EndIf}
138
139 ; Copy the headers
140 SetOutPath "$INSTDIR\include"
141 File /r /x *.so "..\include\cec*.*"
142 SectionEnd
143
144 Section "CEC debug client" SecCecClient
145 SetShellVarContext current
146 SectionIn 3
147
148 ; Copy to the installation directory
149 SetOutPath "$INSTDIR"
150 File /x p8-usbcec-driver-installer.exe /x cec-config-gui.exe "..\build\*.exe"
151 SetOutPath "$INSTDIR\x64"
152 File /nonfatal /x cec-config-gui.exe "..\build\x64\*.exe"
153
154 !insertmacro MUI_STARTMENU_WRITE_BEGIN Application
155 SetOutPath "$INSTDIR"
156
157 CreateDirectory "$SMPROGRAMS\$StartMenuFolder"
158 ${If} ${RunningX64}
159 CreateShortCut "$SMPROGRAMS\$StartMenuFolder\CEC Test client (x64).lnk" "$INSTDIR\x64\cec-client.x64.exe" \
160 "" "$INSTDIR\cec-client.x64.exe" 0 SW_SHOWNORMAL \
161 "" "Start the CEC Test client (x64)."
162 ${Else}
163 CreateShortCut "$SMPROGRAMS\$StartMenuFolder\CEC Test client.lnk" "$INSTDIR\cec-client.exe" \
164 "" "$INSTDIR\cec-client.exe" 0 SW_SHOWNORMAL \
165 "" "Start the CEC Test client."
166 ${EndIf}
167 !insertmacro MUI_STARTMENU_WRITE_END
168
169 SectionEnd
170
171 Section "CEC configuration tool" SecCecConfig
172 SetShellVarContext current
173 SectionIn 1 3
174
175 ; Copy to the installation directory
176 SetOutPath "$INSTDIR"
177 File "..\build\cec-config-gui.exe"
178 SetOutPath "$INSTDIR\x64"
179 File /nonfatal "..\build\x64\cec-config-gui.exe"
180
181 !insertmacro MUI_STARTMENU_WRITE_BEGIN Application
182 SetOutPath "$INSTDIR"
183
184 CreateDirectory "$SMPROGRAMS\$StartMenuFolder"
185 ${If} ${RunningX64}
186 CreateShortCut "$SMPROGRAMS\$StartMenuFolder\CEC Adapter Configuration (x64).lnk" "$INSTDIR\x64\cec-config-gui.exe" \
187 "" "$INSTDIR\x64\cec-config-gui.exe" 0 SW_SHOWNORMAL \
188 "" "Start the CEC Adapter Configuration tool (x64)."
189 ${Else}
190 CreateShortCut "$SMPROGRAMS\$StartMenuFolder\CEC Adapter Configuration.lnk" "$INSTDIR\cec-config-gui.exe" \
191 "" "$INSTDIR\cec-config-gui.exe" 0 SW_SHOWNORMAL \
192 "" "Start the CEC Adapter Configuration tool."
193 ${EndIf}
194 !insertmacro MUI_STARTMENU_WRITE_END
195
196 SectionEnd
197
198 ;--------------------------------
199 ;Uninstaller Section
200
201 Section "Uninstall"
202
203 SetShellVarContext current
204
205 Delete "$INSTDIR\AUTHORS"
206 Delete "$INSTDIR\*.exe"
207 Delete "$INSTDIR\ChangeLog"
208 Delete "$INSTDIR\COPYING"
209 Delete "$INSTDIR\*.dll"
210 Delete "$INSTDIR\*.lib"
211 Delete "$INSTDIR\x64\*.dll"
212 Delete "$INSTDIR\x64\*.lib"
213 Delete "$INSTDIR\x64\*.exe"
214 Delete "$INSTDIR\README"
215 Delete "$SYSDIR\libcec.dll"
216 ${If} ${RunningX64}
217 Delete "$SYSDIR\libcec.x64.dll"
218 ${EndIf}
219
220 ; Uninstall the driver
221 ReadRegStr $1 HKLM "Software\Pulse-Eight\USB-CEC Adapter driver" ""
222 ${If} $1 != ""
223 ExecWait '"$1\Uninstall.exe" /S _?=$1'
224 ${EndIf}
225
226 RMDir /r "$INSTDIR\include"
227 Delete "$INSTDIR\Uninstall.exe"
228 RMDir /r "$INSTDIR"
229 RMDir "$PROGRAMFILES\Pulse-Eight"
230
231 !insertmacro MUI_STARTMENU_GETFOLDER Application $StartMenuFolder
232 Delete "$SMPROGRAMS\$StartMenuFolder\CEC Adapter Configuration.lnk"
233 ${If} ${RunningX64}
234 Delete "$SMPROGRAMS\$StartMenuFolder\CEC Adapter Configuration (x64).lnk"
235 ${EndIf}
236 Delete "$SMPROGRAMS\$StartMenuFolder\CEC Test client.lnk"
237 ${If} ${RunningX64}
238 Delete "$SMPROGRAMS\$StartMenuFolder\CEC Test client (x64).lnk"
239 ${EndIf}
240 Delete "$SMPROGRAMS\$StartMenuFolder\Uninstall Pulse-Eight USB-CEC Adapter software.lnk"
241 Delete "$SMPROGRAMS\$StartMenuFolder\Visit Pulse-Eight.url"
242 RMDir "$SMPROGRAMS\$StartMenuFolder"
243
244 DeleteRegKey HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Pulse-Eight USB-CEC Adapter sofware"
245 DeleteRegKey HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Pulse-Eight USB-CEC Adapter driver"
246 DeleteRegKey /ifempty HKLM "Software\Pulse-Eight\USB-CEC Adapter software"
247 DeleteRegKey /ifempty HKLM "Software\Pulse-Eight"
248 SectionEnd