| 1 | ;libCEC installer |
| 2 | ;Copyright (C) 2011 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 "libCEC" |
| 11 | OutFile "..\build\libCEC-installer.exe" |
| 12 | |
| 13 | XPStyle on |
| 14 | InstallDir "$PROGRAMFILES\libCEC" |
| 15 | InstallDirRegKey HKCU "Software\libCEC" "" |
| 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_DIRECTORY |
| 26 | |
| 27 | !define MUI_STARTMENUPAGE_REGISTRY_ROOT "HKCU" |
| 28 | !define MUI_STARTMENUPAGE_REGISTRY_KEY "Software\libCEC" |
| 29 | !define MUI_STARTMENUPAGE_REGISTRY_VALUENAME "Start Menu Folder" |
| 30 | !insertmacro MUI_PAGE_STARTMENU Application $StartMenuFolder |
| 31 | |
| 32 | !insertmacro MUI_PAGE_INSTFILES |
| 33 | !insertmacro MUI_PAGE_FINISH |
| 34 | |
| 35 | !insertmacro MUI_UNPAGE_WELCOME |
| 36 | !insertmacro MUI_UNPAGE_CONFIRM |
| 37 | !insertmacro MUI_UNPAGE_INSTFILES |
| 38 | !insertmacro MUI_UNPAGE_FINISH |
| 39 | |
| 40 | !insertmacro MUI_LANGUAGE "English" |
| 41 | |
| 42 | InstType "Full" |
| 43 | |
| 44 | Section "libCEC" SecLibCEC |
| 45 | SetShellVarContext current |
| 46 | SectionIn RO |
| 47 | SectionIn 1 #section is in installtype Full |
| 48 | |
| 49 | ; Copy to the installation directory |
| 50 | SetOutPath "$INSTDIR" |
| 51 | File "..\AUTHORS" |
| 52 | File /x dpinst*.exe "..\build\*.exe" |
| 53 | File "..\ChangeLog" |
| 54 | File "..\COPYING" |
| 55 | File "..\README" |
| 56 | File "..\build\*.dll" |
| 57 | SetOutPath "$INSTDIR\x64" |
| 58 | File /nonfatal "..\build\x64\*" |
| 59 | |
| 60 | ; Copy to XBMC\system |
| 61 | ReadRegStr $1 HKCU "Software\XBMC" "" |
| 62 | ${If} $1 != "" |
| 63 | SetOutPath "$1\system" |
| 64 | File "..\build\libcec.dll" |
| 65 | ${EndIf} |
| 66 | |
| 67 | ; Copy the driver installer and .inf file |
| 68 | SetOutPath "$INSTDIR\driver" |
| 69 | File "..\build\dpinst-amd64.exe" |
| 70 | File "..\build\dpinst-x86.exe" |
| 71 | File "..\OEM001.inf" |
| 72 | |
| 73 | ; Copy the headers |
| 74 | SetOutPath "$INSTDIR\include" |
| 75 | File /r /x *.so "..\include\cec*.*" |
| 76 | |
| 77 | ; Copy libcec.dll and libcec.x64.dll to the system directory |
| 78 | SetOutPath "$SYSDIR" |
| 79 | File "..\build\libcec.dll" |
| 80 | ${If} ${RunningX64} |
| 81 | File /nonfatal "..\build\x64\libcec.x64.dll" |
| 82 | ${EndIf} |
| 83 | |
| 84 | ;Store installation folder |
| 85 | WriteRegStr HKCU "Software\libCEC" "" $INSTDIR |
| 86 | |
| 87 | ;Create uninstaller |
| 88 | WriteUninstaller "$INSTDIR\Uninstall.exe" |
| 89 | |
| 90 | !insertmacro MUI_STARTMENU_WRITE_BEGIN Application |
| 91 | SetOutPath "$INSTDIR" |
| 92 | |
| 93 | CreateDirectory "$SMPROGRAMS\$StartMenuFolder" |
| 94 | CreateShortCut "$SMPROGRAMS\$StartMenuFolder\CEC Test client.lnk" "$INSTDIR\cec-client.exe" \ |
| 95 | "" "$INSTDIR\cec-client.exe" 0 SW_SHOWNORMAL \ |
| 96 | "" "Start the CEC Test client." |
| 97 | ${If} ${RunningX64} |
| 98 | CreateShortCut "$SMPROGRAMS\$StartMenuFolder\CEC Test client (x64).lnk" "$INSTDIR\x64\cec-client.x64.exe" \ |
| 99 | "" "$INSTDIR\cec-client.x64.exe" 0 SW_SHOWNORMAL \ |
| 100 | "" "Start the CEC Test client (x64)." |
| 101 | ${EndIf} |
| 102 | CreateShortCut "$SMPROGRAMS\$StartMenuFolder\Uninstall libCEC.lnk" "$INSTDIR\Uninstall.exe" \ |
| 103 | "" "$INSTDIR\Uninstall.exe" 0 SW_SHOWNORMAL \ |
| 104 | "" "Uninstall libCEC." |
| 105 | |
| 106 | WriteINIStr "$SMPROGRAMS\$StartMenuFolder\Visit Pulse-Eight.url" "InternetShortcut" "URL" "http://www.pulse-eight.com/" |
| 107 | !insertmacro MUI_STARTMENU_WRITE_END |
| 108 | |
| 109 | |
| 110 | ;add entry to add/remove programs |
| 111 | WriteRegStr HKCU "Software\Microsoft\Windows\CurrentVersion\Uninstall\libCEC" \ |
| 112 | "DisplayName" "libCEC" |
| 113 | WriteRegStr HKCU "Software\Microsoft\Windows\CurrentVersion\Uninstall\libCEC" \ |
| 114 | "UninstallString" "$INSTDIR\uninstall.exe" |
| 115 | WriteRegDWORD HKCU "Software\Microsoft\Windows\CurrentVersion\Uninstall\libCEC" \ |
| 116 | "NoModify" 1 |
| 117 | WriteRegDWORD HKCU "Software\Microsoft\Windows\CurrentVersion\Uninstall\libCEC" \ |
| 118 | "NoRepair" 1 |
| 119 | WriteRegStr HKCU "Software\Microsoft\Windows\CurrentVersion\Uninstall\libCEC" \ |
| 120 | "InstallLocation" "$INSTDIR" |
| 121 | WriteRegStr HKCU "Software\Microsoft\Windows\CurrentVersion\Uninstall\libCEC" \ |
| 122 | "DisplayIcon" "$INSTDIR\cec-client.exe,0" |
| 123 | WriteRegStr HKCU "Software\Microsoft\Windows\CurrentVersion\Uninstall\libCEC" \ |
| 124 | "Publisher" "Pulse-Eight Ltd." |
| 125 | WriteRegStr HKCU "Software\Microsoft\Windows\CurrentVersion\Uninstall\libCEC" \ |
| 126 | "HelpLink" "http://www.pulse-eight.com/" |
| 127 | WriteRegStr HKCU "Software\Microsoft\Windows\CurrentVersion\Uninstall\libCEC" \ |
| 128 | "URLInfoAbout" "http://www.pulse-eight.com" |
| 129 | |
| 130 | ;install driver |
| 131 | ${If} ${RunningX64} |
| 132 | ExecWait '"$INSTDIR\driver\dpinst-amd64.exe" /lm /sa /sw /PATH "$INSTDIR\driver"' |
| 133 | ${Else} |
| 134 | ExecWait '"$INSTDIR\driver\dpinst-x86.exe" /lm /sa /sw /PATH "$INSTDIR\driver"' |
| 135 | ${EndIf} |
| 136 | SectionEnd |
| 137 | |
| 138 | ;-------------------------------- |
| 139 | ;Uninstaller Section |
| 140 | |
| 141 | Section "Uninstall" |
| 142 | |
| 143 | SetShellVarContext current |
| 144 | |
| 145 | ${If} ${RunningX64} |
| 146 | ExecWait '"$INSTDIR\driver\dpinst-amd64.exe" /u "$INSTDIR\driver\OEM001.inf"' |
| 147 | ${Else} |
| 148 | ExecWait '"$INSTDIR\driver\dpinst-x64.exe" /u "$INSTDIR\driver\OEM001.inf"' |
| 149 | ${EndIf} |
| 150 | Delete "$INSTDIR\AUTHORS" |
| 151 | Delete "$INSTDIR\cec*.exe" |
| 152 | Delete "$INSTDIR\ChangeLog" |
| 153 | Delete "$INSTDIR\COPYING" |
| 154 | Delete "$INSTDIR\*.dll" |
| 155 | Delete "$INSTDIR\*.lib" |
| 156 | Delete "$INSTDIR\x64\*.dll" |
| 157 | Delete "$INSTDIR\x64\*.lib" |
| 158 | Delete "$INSTDIR\README" |
| 159 | Delete "$INSTDIR\driver\OEM001.inf" |
| 160 | Delete "$INSTDIR\driver\dpinst-amd64.exe" |
| 161 | Delete "$INSTDIR\driver\dpinst-x86.exe" |
| 162 | |
| 163 | RMDir /r "$INSTDIR\include" |
| 164 | Delete "$INSTDIR\Uninstall.exe" |
| 165 | RMDir /r "$INSTDIR" |
| 166 | |
| 167 | !insertmacro MUI_STARTMENU_GETFOLDER Application $StartMenuFolder |
| 168 | Delete "$SMPROGRAMS\$StartMenuFolder\CEC Test client.lnk" |
| 169 | ${If} ${RunningX64} |
| 170 | Delete "$SMPROGRAMS\$StartMenuFolder\CEC Test client (x64).lnk" |
| 171 | ${EndIf} |
| 172 | Delete "$SMPROGRAMS\$StartMenuFolder\Uninstall libCEC.lnk" |
| 173 | Delete "$SMPROGRAMS\$StartMenuFolder\Visit Pulse-Eight.url" |
| 174 | RMDir "$SMPROGRAMS\$StartMenuFolder" |
| 175 | |
| 176 | DeleteRegKey HKCU "Software\Microsoft\Windows\CurrentVersion\Uninstall\libCEC" |
| 177 | |
| 178 | DeleteRegKey /ifempty HKCU "Software\libCEC" |
| 179 | |
| 180 | SectionEnd |