Commit 4977a7b9 authored by Bill Hoffman's avatar Bill Hoffman
Browse files

ENH: move fix for nsis to branch

parent be1d30de
Changes in CMake 2.4.8 RC 4
* fix for cpack and messing up PATH with NSIS
Changes in CMake 2.4.8 RC 3
* fix for bug 5363: GET_TARGET_PROPERTY(... DEBUG_LOCATION)
returns value containing $(OutDir)
......
......@@ -122,15 +122,51 @@ FunctionEnd
;----------------------------------------------------
!define NT_current_env 'HKCU "Environment"'
!define NT_all_env 'HKLM "SYSTEM\CurrentControlSet\Control\Session Manager\Environment"'
;====================================================
!ifndef WriteEnvStr_RegKey
!ifdef ALL_USERS
!define WriteEnvStr_RegKey \
'HKLM "SYSTEM\CurrentControlSet\Control\Session Manager\Environment"'
!else
!define WriteEnvStr_RegKey 'HKCU "Environment"'
!endif
!endif
; AddToPath - Adds the given dir to the search path.
; Input - head of the stack
; Note - Win9x systems requires reboot
;====================================================
Function AddToPath
Exch $0
Push $1
Push $2
Push $3
# don't add if the path doesn't exist
IfFileExists "$0\*.*" "" AddToPath_done
ReadEnvStr $1 PATH
Push "$1;"
Push "$0;"
Call StrStr
Pop $2
StrCmp $2 "" "" AddToPath_done
Push "$1;"
Push "$0\;"
Call StrStr
Pop $2
StrCmp $2 "" "" AddToPath_done
GetFullPathName /SHORT $3 $0
Push "$1;"
Push "$3;"
Call StrStr
Pop $2
StrCmp $2 "" "" AddToPath_done
Push "$1;"
Push "$3\;"
Call StrStr
Pop $2
StrCmp $2 "" "" AddToPath_done
Call IsNT
Pop $1
......@@ -138,76 +174,47 @@ Function AddToPath
; Not on NT
StrCpy $1 $WINDIR 2
FileOpen $1 "$1\autoexec.bat" a
FileSeek $1 0 END
GetFullPathName /SHORT $0 $0
FileWrite $1 "$\r$\n\
$\r$\n\
SET PATH=%PATH%;$0$\r$\n\
$\r$\n\
"
FileSeek $1 -1 END
FileReadByte $1 $2
IntCmp $2 26 0 +2 +2 # DOS EOF
FileSeek $1 -1 END # write over EOF
FileWrite $1 "$\r$\nSET PATH=%PATH%;$3$\r$\n"
FileClose $1
SetRebootFlag true
Goto AddToPath_done
AddToPath_NT:
Push $4
Call select_NT_profile
Pop $4
AddToPath_NT_selection_done:
StrCmp $4 "current" read_path_NT_current
ReadRegStr $1 ${NT_all_env} "PATH"
Goto read_path_NT_resume
read_path_NT_current:
ReadRegStr $1 ${NT_current_env} "PATH"
read_path_NT_resume:
StrCmp $1 "" AddToPath_NoCurrentPath
StrCpy $2 "$0;$1"
Goto AddToPath_NTdoIt
AddToPath_NoCurrentPath:
DetailPrint "No current path, so just use $0"
StrCpy $2 $0
Goto AddToPath_NTdoIt
ReadRegStr $1 ${WriteEnvStr_RegKey} "PATH"
StrCmp $1 "" AddToPath_NTdoIt
Push $1
Call Trim
Pop $1
StrCpy $0 "$1;$0"
AddToPath_NTdoIt:
StrCmp $4 "current" write_path_NT_current
ClearErrors
WriteRegExpandStr ${NT_all_env} "PATH" $2
IfErrors 0 write_path_NT_resume
MessageBox MB_YESNO|MB_ICONQUESTION "The path could not be set for all users$\n\
$\n\
Should I try for the current user?" \
IDNO write_path_NT_failed
; change selection
StrCpy $4 "current"
Goto AddToPath_NT_selection_done
write_path_NT_current:
ClearErrors
WriteRegExpandStr ${NT_current_env} "PATH" $2
IfErrors 0 write_path_NT_resume
MessageBox MB_OK|MB_ICONINFORMATION "The path could not be set for the current user."
Goto write_path_NT_failed
write_path_NT_resume:
WriteRegExpandStr ${WriteEnvStr_RegKey} "PATH" $0
SendMessage ${HWND_BROADCAST} ${WM_WININICHANGE} 0 "STR:Environment" /TIMEOUT=5000
DetailPrint "Added path for user ($4), $0"
DetailPrint "New path is: $2"
write_path_NT_failed:
Pop $4
AddToPath_done:
Pop $3
Pop $2
Pop $1
Pop $0
FunctionEnd
;====================================================
; RemoveFromPath - Remove a given dir from the path
; Input: head of the stack
;====================================================
Function un.RemoveFromPath
Exch $0
Push $1
Push $2
Push $3
Push $4
Push $5
Push $6
IntFmt $6 "%c" 26 # DOS EOF
Call un.IsNT
Pop $1
......@@ -219,20 +226,22 @@ Function un.RemoveFromPath
FileOpen $2 $4 w
GetFullPathName /SHORT $0 $0
StrCpy $0 "SET PATH=%PATH%;$0"
SetRebootFlag true
Goto unRemoveFromPath_dosLoop
unRemoveFromPath_dosLoop:
FileRead $1 $3
StrCmp $3 "$0$$\r$\n\
$\r$\n\
" unRemoveFromPath_dosLoop
StrCmp $3 "$0$\r$\n\
" unRemoveFromPath_dosLoop
StrCmp $3 "$0" unRemoveFromPath_dosLoop
StrCpy $5 $3 1 -1 # read last char
StrCmp $5 $6 0 +2 # if DOS EOF
StrCpy $3 $3 -1 # remove DOS EOF so we can compare
StrCmp $3 "$0$\r$\n" unRemoveFromPath_dosLoopRemoveLine
StrCmp $3 "$0$\n" unRemoveFromPath_dosLoopRemoveLine
StrCmp $3 "$0" unRemoveFromPath_dosLoopRemoveLine
StrCmp $3 "" unRemoveFromPath_dosLoopEnd
FileWrite $2 $3
Goto unRemoveFromPath_dosLoop
unRemoveFromPath_dosLoopRemoveLine:
SetRebootFlag true
Goto unRemoveFromPath_dosLoop
unRemoveFromPath_dosLoopEnd:
FileClose $2
......@@ -244,60 +253,42 @@ $\r$\n\
Goto unRemoveFromPath_done
unRemoveFromPath_NT:
StrLen $2 $0
Call un.select_NT_profile
Pop $4
StrCmp $4 "current" un_read_path_NT_current
ReadRegStr $1 ${NT_all_env} "PATH"
Goto un_read_path_NT_resume
un_read_path_NT_current:
ReadRegStr $1 ${NT_current_env} "PATH"
un_read_path_NT_resume:
StrCpy $8 $0
ReadRegStr $1 ${WriteEnvStr_RegKey} "PATH"
StrCpy $5 $1 1 -1 # copy last char
StrCmp $5 ";" +2 # if last char != ;
StrCpy $1 "$1;" # append ;
Push $1
Push $0
Call un.StrStr ; Find $0 in $1
Pop $0 ; pos of our dir
IntCmp $0 -1 unRemoveFromPath_done
Push "$0;"
Call un.StrStr ; Find `$0;` in $1
Pop $2 ; pos of our dir
StrCmp $2 "" unRemoveFromPath_done
; else, it is in path
StrLen $5 $1 ; Get the length of the original path
StrLen $6 $0 ; get the length of path without the first path
IntOp $5 $5 - $6
IntOp $5 $5 - 1
IntCmp $5 -1 unRemoveFromPath_nothingBefore
StrCpy $3 $1 $5 ; $3 now has the part of the path before our dir
Goto unRemoveFromPath_AfterBefore
unRemoveFromPath_nothingBefore:
StrCpy $3 ""
unRemoveFromPath_AfterBefore:
StrCpy $7 $0 "" $2 ; $3 now has the part of the path after our dir
StrCpy $3 "$3$7"
; $3 now holds path, but there may be some stray semicolon at
; beginning. Let's remove it
StrCpy $7 $3 1
StrCmp $7 ";" 0 unRemoveFromPath_NoTrailingSemiColon
StrCpy $3 $3 "" 1
unRemoveFromPath_NoTrailingSemiColon:
# $0 - path to add
# $1 - path var
StrLen $3 "$0;"
StrLen $4 $2
StrCpy $5 $1 -$4 # $5 is now the part before the path to remove
StrCpy $6 $2 "" $3 # $6 is now the part after the path to remove
StrCpy $3 $5$6
StrCmp $4 "current" un_write_path_NT_current
WriteRegExpandStr ${NT_all_env} "PATH" $3
Goto un_write_path_NT_resume
un_write_path_NT_current:
WriteRegExpandStr ${NT_current_env} "PATH" $3
un_write_path_NT_resume:
StrCpy $5 $3 1 -1 # copy last char
StrCmp $5 ";" 0 +2 # if last char == ;
StrCpy $3 $3 -1 # remove last char
WriteRegExpandStr ${WriteEnvStr_RegKey} "PATH" $3
SendMessage ${HWND_BROADCAST} ${WM_WININICHANGE} 0 "STR:Environment" /TIMEOUT=5000
DetailPrint "Removed $8 from the path"
DetailPrint "New path is: $3"
unRemoveFromPath_done:
Pop $6
Pop $5
Pop $4
Pop $3
Pop $2
Pop $1
Pop $0
FunctionEnd
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; Uninstall sutff
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
......@@ -385,6 +376,24 @@ FunctionEnd
!insertmacro StrStr ""
!insertmacro StrStr "un."
Function Trim ; Added by Pelaca
Exch $R1
Push $R2
Loop:
StrCpy $R2 "$R1" 1 -1
StrCmp "$R2" " " RTrim
StrCmp "$R2" "$\n" RTrim
StrCmp "$R2" "$\r" RTrim
StrCmp "$R2" ";" RTrim
GoTo Done
RTrim:
StrCpy $R1 "$R1" -1
Goto Loop
Done:
Pop $R2
Exch $R1
FunctionEnd
Function ConditionalAddToRegisty
Pop $0
Pop $1
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment