File: functions.nsh

package info (click to toggle)
libcec 7.1.1-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 2,372 kB
  • sloc: cpp: 20,697; ansic: 2,070; python: 1,362; sh: 42; makefile: 17
file content (68 lines) | stat: -rw-r--r-- 2,239 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
!include LogicLib.nsh
!include FileFunc.nsh

Var oldVersionDir

!macro !defineifexist _VAR_NAME _FILE_NAME
	!tempfile _TEMPFILE
	!ifdef NSIS_WIN32_MAKENSIS
		; Windows - cmd.exe
		!system 'if exist "${_FILE_NAME}" echo !define ${_VAR_NAME} > "${_TEMPFILE}"'
	!else
		; Posix - sh
		!system 'if [ -e "${_FILE_NAME}" ]; then echo "!define ${_VAR_NAME}" > "${_TEMPFILE}"; fi'
	!endif
	!include '${_TEMPFILE}'
	!delfile '${_TEMPFILE}'
	!undef _TEMPFILE
!macroend
!define !defineifexist "!insertmacro !defineifexist"

Function DeleteOldFiles
	RMDir /r "$INSTDIR\EventGhost"
	RMDir /r "$INSTDIR\include"
	RMDir /r "$INSTDIR\python"
	RMDir /r "$INSTDIR\x64"
	RMDir /r "$INSTDIR\x86"
	Delete "$INSTDIR\AUTHORS"
	Delete "$INSTDIR\cec.dll"
	Delete "$INSTDIR\cec.pdb"
	Delete "$INSTDIR\cecc-client.exe"
	Delete "$INSTDIR\cec-client.exe"
	Delete "$INSTDIR\cec-firmware-latest.exe"
	Delete "$INSTDIR\ChangeLog"
	Delete "$INSTDIR\COPYING"
	Delete "$INSTDIR\libusb0.dll"
	Delete "$INSTDIR\LICENSE.md"
	Delete "$INSTDIR\README.*"
	Delete "$INSTDIR\tv_on.cmd"
	Delete "$INSTDIR\tv_off.cmd"
	Delete "$INSTDIR\Uninstall.exe"
	Delete "$INSTDIR\uninstall_libcec.exe"
FunctionEnd

Function UninstallOldVersion
	ReadRegStr $0 HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Pulse-Eight USB-CEC Adapter sofware" "UninstallString"
	${If} $0 != ""
		${If} ${Cmd} `MessageBox MB_YESNO|MB_ICONQUESTION "An old libCEC installation was found. This version must be uninstalled before installing libCEC v${LIBCEC_VERSION_STRING}. Continue?" /SD IDYES IDYES`
			${GetParent} "$0" $oldVersionDir
			ExecWait '"$0" _?=$oldVersionDir' $0
			${If} $0 <> 0
				MessageBox MB_OK "Failed to uninstall"
				Quit
			${Else}
				; old uninstaller was bugged and didn't always uninstall
				Call DeleteOldFiles
				DeleteRegKey HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Pulse-Eight USB-CEC Adapter sofware"
				DeleteRegKey HKLM "Software\Pulse-Eight\USB-CEC Adapter sofware"
				DeleteRegKey /ifempty HKLM "Software\Pulse-Eight"
				SetShellVarContext current
				RMDir /r "$SMPROGRAMS\Pulse-Eight libCEC v6.0.2"
				SetShellVarContext all
				RMDir /r "$SMPROGRAMS\Pulse-Eight libCEC v6.0.2"
			${EndIf}
		${Else}
			Quit
		${EndIf}
	${EndIf}
FunctionEnd