LibCecSharp: added quotes to the linker statement for libcec.lib. fixes compilation...
[deb_libcec.git] / project / libCEC.nsi
index 23f341afd69c169022c092eee8c10a8de271a654..2d73500192f3a4366719e09eed4205f79d1ffe5a 100644 (file)
@@ -1,5 +1,5 @@
 ;libCEC installer
-;Copyright (C) 2011 Pulse-Eight Ltd.
+;Copyright (C) 2012 Pulse-Eight Ltd.
 ;http://www.pulse-eight.com/
 
 !include "MUI2.nsh"
@@ -7,12 +7,12 @@
 !include "LogicLib.nsh"
 !include "x64.nsh"
 
-Name "libCEC"
+Name "Pulse-Eight USB-CEC Adapter"
 OutFile "..\build\libCEC-installer.exe"
 
 XPStyle on
-InstallDir "$PROGRAMFILES\libCEC"
-InstallDirRegKey HKCU "Software\libCEC" ""
+InstallDir "$PROGRAMFILES\Pulse-Eight\USB-CEC Adapter"
+InstallDirRegKey HKLM "Software\Pulse-Eight\USB-CEC Adapter software" ""
 RequestExecutionLevel admin
 Var StartMenuFolder
 
@@ -22,10 +22,11 @@ Var StartMenuFolder
 
 !insertmacro MUI_PAGE_WELCOME
 !insertmacro MUI_PAGE_LICENSE "..\COPYING"
+!insertmacro MUI_PAGE_COMPONENTS
 !insertmacro MUI_PAGE_DIRECTORY
 
-!define MUI_STARTMENUPAGE_REGISTRY_ROOT "HKCU
-!define MUI_STARTMENUPAGE_REGISTRY_KEY "Software\libCEC
+!define MUI_STARTMENUPAGE_REGISTRY_ROOT "HKLM
+!define MUI_STARTMENUPAGE_REGISTRY_KEY "Software\Pulse-Eight\USB-CEC Adapter sofware
 !define MUI_STARTMENUPAGE_REGISTRY_VALUENAME "Start Menu Folder"
 !insertmacro MUI_PAGE_STARTMENU Application $StartMenuFolder  
 
@@ -39,23 +40,87 @@ Var StartMenuFolder
 
 !insertmacro MUI_LANGUAGE "English"
 
-InstType "Full"
+InstType "USB-CEC driver & libCEC"
+InstType "USB-CEC driver only"
+InstType "Full installation"
 
-Section "libCEC" SecLibCEC
+Section "USB-CEC driver" SecDriver
   SetShellVarContext current
   SectionIn RO
-  SectionIn 1 #section is in installtype Full
+  SectionIn 1 2 3
+
+  ; Uninstall the old unsigned software if it's found
+  ReadRegStr $1 HKCU "Software\libCEC" ""
+  ${If} $1 != ""
+    MessageBox MB_OK \
+         "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."
+    ExecWait '"$1\Uninstall.exe" /S _?=$1'
+       Delete "$1\Uninstall.exe"
+       RMDir "$1"
+  ${EndIf}
 
   ; Copy to the installation directory
   SetOutPath "$INSTDIR"
   File "..\AUTHORS"
-  File /x dpinst*.exe "..\build\*.exe"
-  File "..\ChangeLog"
   File "..\COPYING"
+
+  ; Copy the driver installer
+  SetOutPath "$INSTDIR\driver"
+  File "..\build\p8-usbcec-driver-installer.exe"
+
+  ;Store installation folder
+  WriteRegStr HKLM "Software\Pulse-Eight\USB-CEC Adapter software" "" $INSTDIR
+
+  ;Create uninstaller
+  WriteUninstaller "$INSTDIR\Uninstall.exe"
+
+  !insertmacro MUI_STARTMENU_WRITE_BEGIN Application
+  SetOutPath "$INSTDIR"
+
+  CreateDirectory "$SMPROGRAMS\$StartMenuFolder"
+  CreateShortCut "$SMPROGRAMS\$StartMenuFolder\Uninstall Pulse-Eight USB-CEC Adapter software.lnk" "$INSTDIR\Uninstall.exe" \
+    "" "$INSTDIR\Uninstall.exe" 0 SW_SHOWNORMAL \
+    "" "Uninstall Pulse-Eight USB-CEC Adapter software."
+
+  WriteINIStr "$SMPROGRAMS\$StartMenuFolder\Visit Pulse-Eight.url" "InternetShortcut" "URL" "http://www.pulse-eight.com/"
+  !insertmacro MUI_STARTMENU_WRITE_END  
+    
+  ;add entry to add/remove programs
+  WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Pulse-Eight USB-CEC Adapter sofware" \
+                 "DisplayName" "Pulse-Eight USB-CEC Adapter software"
+  WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Pulse-Eight USB-CEC Adapter sofware" \
+                 "UninstallString" "$INSTDIR\uninstall.exe"
+  WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Pulse-Eight USB-CEC Adapter sofware" \
+                 "NoModify" 1
+  WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Pulse-Eight USB-CEC Adapter sofware" \
+                 "NoRepair" 1
+  WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Pulse-Eight USB-CEC Adapter sofware" \
+                 "InstallLocation" "$INSTDIR"
+  WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Pulse-Eight USB-CEC Adapter sofware" \
+                 "DisplayIcon" "$INSTDIR\cec-client.exe,0"
+  WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Pulse-Eight USB-CEC Adapter sofware" \
+                 "Publisher" "Pulse-Eight Limited"
+  WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Pulse-Eight USB-CEC Adapter sofware" \
+                 "HelpLink" "http://www.pulse-eight.com/"
+  WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Pulse-Eight USB-CEC Adapter sofware" \
+                 "URLInfoAbout" "http://www.pulse-eight.com"
+
+  ;install driver
+  ExecWait '"$INSTDIR\driver\p8-usbcec-driver-installer.exe" /S'
+  Delete "$INSTDIR\driver\p8-usbcec-driver-installer.exe"
+SectionEnd
+
+Section "libCEC" SecLibCec
+  SetShellVarContext current
+  SectionIn 1 3
+
+  ; Copy to the installation directory
+  SetOutPath "$INSTDIR"
+  File "..\ChangeLog"
   File "..\README"
   File "..\build\*.dll"
   SetOutPath "$INSTDIR\x64"
-  File /nonfatal "..\build\x64\*"
+  File /nonfatal "..\build\x64\*.dll"
 
   ; Copy to XBMC\system
   ReadRegStr $1 HKCU "Software\XBMC" ""
@@ -64,12 +129,6 @@ Section "libCEC" SecLibCEC
        File "..\build\libcec.dll"
   ${EndIf}
 
-  ; Copy the driver installer and .inf file
-  SetOutPath "$INSTDIR\driver"
-  File "..\build\dpinst-amd64.exe"
-  File "..\build\dpinst-x86.exe"
-  File "..\OEM001.inf"
-
   ; Copy the headers
   SetOutPath "$INSTDIR\include"
   File /r /x *.so "..\include\cec*.*"
@@ -80,12 +139,17 @@ Section "libCEC" SecLibCEC
   ${If} ${RunningX64}
     File /nonfatal "..\build\x64\libcec.x64.dll"
   ${EndIf}
+SectionEnd
 
-  ;Store installation folder
-  WriteRegStr HKCU "Software\libCEC" "" $INSTDIR
+Section "CEC debug client" SecCecClient
+  SetShellVarContext current
+  SectionIn 3
 
-  ;Create uninstaller
-  WriteUninstaller "$INSTDIR\Uninstall.exe"
+  ; Copy to the installation directory
+  SetOutPath "$INSTDIR"
+  File /x p8-usbcec-driver-installer.exe "..\build\*.exe"
+  SetOutPath "$INSTDIR\x64"
+  File /nonfatal "..\build\x64\*.exe"
 
   !insertmacro MUI_STARTMENU_WRITE_BEGIN Application
   SetOutPath "$INSTDIR"
@@ -99,40 +163,8 @@ Section "libCEC" SecLibCEC
       "" "$INSTDIR\cec-client.x64.exe" 0 SW_SHOWNORMAL \
       "" "Start the CEC Test client (x64)."
   ${EndIf}
-  CreateShortCut "$SMPROGRAMS\$StartMenuFolder\Uninstall libCEC.lnk" "$INSTDIR\Uninstall.exe" \
-    "" "$INSTDIR\Uninstall.exe" 0 SW_SHOWNORMAL \
-    "" "Uninstall libCEC."
-
-  WriteINIStr "$SMPROGRAMS\$StartMenuFolder\Visit Pulse-Eight.url" "InternetShortcut" "URL" "http://www.pulse-eight.com/"
   !insertmacro MUI_STARTMENU_WRITE_END  
-  
-  
-  ;add entry to add/remove programs
-  WriteRegStr HKCU "Software\Microsoft\Windows\CurrentVersion\Uninstall\libCEC" \
-                 "DisplayName" "libCEC"
-  WriteRegStr HKCU "Software\Microsoft\Windows\CurrentVersion\Uninstall\libCEC" \
-                 "UninstallString" "$INSTDIR\uninstall.exe"
-  WriteRegDWORD HKCU "Software\Microsoft\Windows\CurrentVersion\Uninstall\libCEC" \
-                 "NoModify" 1
-  WriteRegDWORD HKCU "Software\Microsoft\Windows\CurrentVersion\Uninstall\libCEC" \
-                 "NoRepair" 1
-  WriteRegStr HKCU "Software\Microsoft\Windows\CurrentVersion\Uninstall\libCEC" \
-                 "InstallLocation" "$INSTDIR"
-  WriteRegStr HKCU "Software\Microsoft\Windows\CurrentVersion\Uninstall\libCEC" \
-                 "DisplayIcon" "$INSTDIR\cec-client.exe,0"
-  WriteRegStr HKCU "Software\Microsoft\Windows\CurrentVersion\Uninstall\libCEC" \
-                 "Publisher" "Pulse-Eight Ltd."
-  WriteRegStr HKCU "Software\Microsoft\Windows\CurrentVersion\Uninstall\libCEC" \
-                 "HelpLink" "http://www.pulse-eight.com/"
-  WriteRegStr HKCU "Software\Microsoft\Windows\CurrentVersion\Uninstall\libCEC" \
-                 "URLInfoAbout" "http://www.pulse-eight.com"
-
-  ;install driver
-  ${If} ${RunningX64}
-       ExecWait '"$INSTDIR\driver\dpinst-amd64.exe" /lm /sa /sw /PATH "$INSTDIR\driver"'
-  ${Else}
-       ExecWait '"$INSTDIR\driver\dpinst-x86.exe" /lm /sa /sw /PATH "$INSTDIR\driver"'
-  ${EndIf}
+    
 SectionEnd
 
 ;--------------------------------
@@ -142,11 +174,6 @@ Section "Uninstall"
 
   SetShellVarContext current
 
-  ${If} ${RunningX64}
-       ExecWait '"$INSTDIR\driver\dpinst-amd64.exe" /u "$INSTDIR\driver\OEM001.inf"'
-  ${Else}
-       ExecWait '"$INSTDIR\driver\dpinst-x64.exe" /u "$INSTDIR\driver\OEM001.inf"'
-  ${EndIf}
   Delete "$INSTDIR\AUTHORS"
   Delete "$INSTDIR\cec*.exe"
   Delete "$INSTDIR\ChangeLog"
@@ -156,25 +183,29 @@ Section "Uninstall"
   Delete "$INSTDIR\x64\*.dll"
   Delete "$INSTDIR\x64\*.lib"
   Delete "$INSTDIR\README"
-  Delete "$INSTDIR\driver\OEM001.inf"
-  Delete "$INSTDIR\driver\dpinst-amd64.exe"
-  Delete "$INSTDIR\driver\dpinst-x86.exe"
+
+  ; Uninstall the driver
+  ReadRegStr $1 HKLM "Software\Pulse-Eight\USB-CEC Adapter driver" ""
+  ${If} $1 != ""
+    ExecWait '"$1\Uninstall.exe" /S _?=$1'
+  ${EndIf}
 
   RMDir /r "$INSTDIR\include"
   Delete "$INSTDIR\Uninstall.exe"
   RMDir /r "$INSTDIR"
+  RMDir "$PROGRAMFILES\Pulse-Eight"
   
   !insertmacro MUI_STARTMENU_GETFOLDER Application $StartMenuFolder
   Delete "$SMPROGRAMS\$StartMenuFolder\CEC Test client.lnk"
   ${If} ${RunningX64}
     Delete "$SMPROGRAMS\$StartMenuFolder\CEC Test client (x64).lnk"
   ${EndIf}
-  Delete "$SMPROGRAMS\$StartMenuFolder\Uninstall libCEC.lnk"
+  Delete "$SMPROGRAMS\$StartMenuFolder\Uninstall Pulse-Eight USB-CEC Adapter software.lnk"
   Delete "$SMPROGRAMS\$StartMenuFolder\Visit Pulse-Eight.url"
-  RMDir "$SMPROGRAMS\$StartMenuFolder"  
-
-  DeleteRegKey HKCU "Software\Microsoft\Windows\CurrentVersion\Uninstall\libCEC"
-
-  DeleteRegKey /ifempty HKCU "Software\libCEC"
+  RMDir "$SMPROGRAMS\$StartMenuFolder"
 
+  DeleteRegKey HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Pulse-Eight USB-CEC Adapter sofware"
+  DeleteRegKey HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Pulse-Eight USB-CEC Adapter driver"
+  DeleteRegKey /ifempty HKLM "Software\Pulse-Eight\USB-CEC Adapter software"
+  DeleteRegKey /ifempty HKLM "Software\Pulse-Eight"
 SectionEnd