Commit 2c020848 authored by Anthony Léonard's avatar Anthony Léonard Committed by Olivier SOLDANO

setup: detect a previous install of Ring

When Ring is installed, some keys are set in the Registry to indicate
various locations, including the uninstall.exe and the root install
folder.

Now, the installer check the presence of this last value and use it as
the default install location. With this change, updating Ring is just
about pressing “Next” even if it is installed in a custom location.

Change-Id: I48b28c840c094c94f03e763c72f29d833aaa690b
Reviewed-by: default avatarOlivier Soldano <olivier.soldano@savoirfairelinux.com>
Tuleap: #1460
parent 0b8af91b
......@@ -46,6 +46,51 @@ outFile "ring-windows-nightly.exe"
!include LogicLib.nsh
!include "FileFunc.nsh"
Function StrRep
Exch $R4 ; $R4 = Replacement String
Exch
Exch $R3 ; $R3 = String to replace (needle)
Exch 2
Exch $R1 ; $R1 = String to do replacement in (haystack)
Push $R2 ; Replaced haystack
Push $R5 ; Len (needle)
Push $R6 ; len (haystack)
Push $R7 ; Scratch reg
StrCpy $R2 ""
StrLen $R5 $R3
StrLen $R6 $R1
loop:
StrCpy $R7 $R1 $R5
StrCmp $R7 $R3 found
StrCpy $R7 $R1 1 ; - optimization can be removed if U know len needle=1
StrCpy $R2 "$R2$R7"
StrCpy $R1 $R1 $R6 1
StrCmp $R1 "" done loop
found:
StrCpy $R2 "$R2$R4"
StrCpy $R1 $R1 $R6 $R5
StrCmp $R1 "" done loop
done:
StrCpy $R3 $R2
Pop $R7
Pop $R6
Pop $R5
Pop $R2
Pop $R1
Pop $R4
Exch $R3
FunctionEnd
!macro _StrReplaceConstructor ORIGINAL_STRING TO_REPLACE REPLACE_BY
Push "${ORIGINAL_STRING}"
Push "${TO_REPLACE}"
Push "${REPLACE_BY}"
Call StrRep
Pop $0
!macroend
!define StrReplace '!insertmacro "_StrReplaceConstructor"'
!macro VerifyUserIsAdmin
UserInfo::GetAccountType
pop $0
......@@ -61,12 +106,19 @@ ${EndIf}
function .onInit
setShellVarContext all
!insertmacro VerifyUserIsAdmin
ReadRegStr $0 HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${COMPANYNAME} ${APPNAME}" "InstallLocation"
StrCmp $0 "" notfound
${StrReplace} $0 "$\"" ""
StrCpy $INSTDIR $0
Goto done
notfound:
StrCpy $INSTDIR "$PROGRAMFILES\${COMPANYNAME}\${APPNAME}"
${If} ${ARCH} == "x64"
${If} ${RunningX64}
StrCpy $INSTDIR "$PROGRAMFILES64\${COMPANYNAME}\${APPNAME}"
${EndIf}
${EndIf}
done:
functionEnd
Function LaunchLink
......@@ -116,7 +168,7 @@ section "install"
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${COMPANYNAME} ${APPNAME}" "DisplayName" ${APPNAME}
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${COMPANYNAME} ${APPNAME}" "UninstallString" "$\"$INSTDIR\uninstall.exe$\""
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${COMPANYNAME} ${APPNAME}" "QuietUninstallString" "$\"$INSTDIR\uninstall.exe$\" /S"
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${COMPANYNAME} ${APPNAME}" "InstallLocation" "$\"$INSTDIR$\""
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${COMPANYNAME} ${APPNAME}" "InstallLocation" $INSTDIR
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${COMPANYNAME} ${APPNAME}" "DisplayIcon" "$\"$INSTDIR\ring.ico$\""
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${COMPANYNAME} ${APPNAME}" "Publisher" "${COMPANYNAME}"
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${COMPANYNAME} ${APPNAME}" "HelpLink" "$\"${HELPURL}$\""
......
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