From 8ef7d621c5903eeeacaeded88384e38e4f666339 Mon Sep 17 00:00:00 2001 From: Jeffrey Altman Date: Sun, 21 Mar 2004 20:56:25 +0000 Subject: [PATCH] nsis-installer-20040321 Remove Rob's new way of installing services as it does not appear to work properly. Add in code to test the legitimacy of the upgrade to ensure we don't try to upgrade an old IBM AFS version that isn't supported Make sure that the only AFS in the PATH is ours and that we are only in once. Add the TransarcAFSDaemon entry into the Control\NetworkProviders::Order value to support Integrated Login Build service.exe and killer.exe with static libraries to avoid run-time dependencies at install and uninstall time ==================== This delta was composed from multiple commits as part of the CVS->Git migration. The checkin message with each commit was inconsistent. The following are the additional commit messages. ==================== Check both Client and Server for unsupported previous installation --- src/WINNT/install/NSIS/NTMakefile | 3 + src/WINNT/install/NSIS/OpenAFS.nsi | 311 +++++++++++++++-------------- 2 files changed, 168 insertions(+), 146 deletions(-) diff --git a/src/WINNT/install/NSIS/NTMakefile b/src/WINNT/install/NSIS/NTMakefile index 4bb9cb25a..25f5308ed 100644 --- a/src/WINNT/install/NSIS/NTMakefile +++ b/src/WINNT/install/NSIS/NTMakefile @@ -5,6 +5,9 @@ RELDIR=WINNT\install\NSIS EXEDIR = $(DESTDIR)\WinInstall\Config NSISDIR = C:\Program Files\NSIS +# Revise the rule for compiling sources to use static libraries +C2OBJ = $(cc) /Fo$@ /Fd$*.pdb $(cflags) $(cdebug) $(cvars) $(afscflags) $(afscdefs) /c + $(OUT)\Service.obj: Service.cpp $(C2OBJ) Service.cpp diff --git a/src/WINNT/install/NSIS/OpenAFS.nsi b/src/WINNT/install/NSIS/OpenAFS.nsi index 26bed3117..45e6a2e98 100644 --- a/src/WINNT/install/NSIS/OpenAFS.nsi +++ b/src/WINNT/install/NSIS/OpenAFS.nsi @@ -32,7 +32,7 @@ VIAddVersionKey "CompanyName" "OpenAFS.org" VIAddVersionKey "ProductVersion" ${AFS_VERSION} VIAddVersionKey "FileVersion" ${AFS_VERSION} VIAddVersionKey "FileDescription" "OpenAFS for Windows Installer" -VIAddVersionKey "LegalCopyright" "(C)2004" +VIAddVersionKey "LegalCopyright" "(C)2000-2004" !ifdef DEBUG VIAddVersionKey "PrivateBuild" "Checked/Debug" !endif ; End DEBUG @@ -281,9 +281,6 @@ VIAddVersionKey "PrivateBuild" "Checked/Debug" !insertmacro MUI_RESERVEFILE_LANGDLL ;Language selection dialog ;-------------------------------- ; Macros - -!include "ServiceLib.nsh" - ; Macro - Upgrade DLL File ; Written by Joost Verburg ; ------------------------ @@ -458,13 +455,14 @@ var REG_DATA_3 Section "AFS Client" secClient SetShellVarContext all - + ; Check for bad previous installation (if we are doing a new install) Call IsAnyAFSInstalled Pop $R0 StrCmp $R0 "0" +1 skipCheck Call CheckPathForAFS -skipCheck: + skipCheck: + ; Stop any running services or we can't replace the files ; Stop the running processes GetTempFileName $R0 @@ -472,14 +470,13 @@ skipCheck: nsExec::Exec '$R0 afscreds.exe' Exec "afscreds.exe -z" ; in case we are upgrading an old version that does not support -z - Sleep 2000 nsExec::Exec '$R0 afscreds.exe' !IFDEF INSTALL_KFW ;nsExec::Exec '$R0 krbcc32s.exe' !ENDIF - !insertmacro SERVICE "stop" "TransarcAFSDaemon" "" - !insertmacro SERVICE "stop" "TransarcAFSServer" "" + nsExec::Exec "net stop TransarcAFSDaemon" + nsExec::Exec "net stop TransarcAFSServer" ; Do client components SetOutPath "$INSTDIR\Client\Program" @@ -611,28 +608,27 @@ skipCheck: CreateShortCut "$SMSTARTUP\AFS Credentials.lnk" "$INSTDIR\Client\Program\afscreds.exe" "-A -M -N -Q" Push "$INSTDIR\Client\Program" - Call AddToPath + Call AddToUniquePath Push "$INSTDIR\Common" - Call AddToPath + Call AddToUniquePath !ifdef INSTALL_KFW ; Add kfw to path too Push "$INSTDIR\kfw\bin" - Call AddToPath + Call AddToUniquePath !endif ; Create the AFS service SetOutPath "$INSTDIR\Common" - ;File "${AFS_WININSTALL_DIR}\Service.exe" - !insertmacro SERVICE "stop" "TransarcAFSDaemon" "" + File "${AFS_WININSTALL_DIR}\Service.exe" + nsExec::Exec "net stop TransarcAFSDaemon" ;IMPORTANT! If we are not refreshing the config files, do NOT remove the service ;Don't re-install because it must be present or we wouldn't have passed the Reg check ReadRegStr $R2 HKLM "SYSTEM\CurrentControlSet\Services\TransarcAFSDaemon\Parameters" "Cell" StrCmp $R2 "" +1 skipremove - !insertmacro SERVICE "delete" "TransarcAFSDaemon" "" + nsExec::Exec '$INSTDIR\Common\Service.exe u TransarcAFSDaemon' nsExec::Exec '$INSTDIR\Common\Service.exe TransarcAFSDaemon "$INSTDIR\Client\Program\afsd_service.exe" "OpenAFS Client Service"' - ;insertmacro SERVICE "create" "TransarcAFSDaemon" "path=$INSTDIR\Client\Program\afsd_service.exe;autostart=1;interact=1;machine=;user=;password=" skipremove: Delete "$INSTDIR\Common\service.exe" @@ -643,6 +639,7 @@ skipremove: WriteRegStr HKLM "SYSTEM\CurrentControlSet\Services\TransarcAFSDaemon\NetworkProvider" "AuthentProviderPath" "$INSTDIR\Client\Program\afslogon.dll" WriteRegDWORD HKLM "SYSTEM\CurrentControlSet\Services\TransarcAFSDaemon\NetworkProvider" "Class" 2 WriteRegDWORD HKLM "SYSTEM\CurrentControlSet\Services\TransarcAFSDaemon\NetworkProvider" "VerboseLogging" 10 + ; Must also add HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\NetworkProvider\HwOrder ; and HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\NetworkProvider\Order ; to also include the service name. @@ -664,7 +661,7 @@ skipremove: WriteRegDWORD HKLM "SYSTEM\CurrentControlSet\Services\TransarcAFSDaemon\Parameters" "SecurityLevel" $R0 ReadINIStr $R0 $1 "Field 5" "State" WriteRegDWORD HKLM "SYSTEM\CurrentControlSet\Services\TransarcAFSDaemon\Parameters" "FreelanceClient" $R0 - ReadINIStr $R0 $1 "Field 11" "State" + ReadINIStr $R0 $1 "Field 11" "State" WriteRegDWORD HKLM "SYSTEM\CurrentControlSet\Services\TransarcAFSDaemon\Parameters" "UseDNS" $R0 WriteRegStr HKLM "SYSTEM\CurrentControlSet\Services\TransarcAFSDaemon\Parameters" "NetbiosName" "AFS" WriteRegStr HKLM "SYSTEM\CurrentControlSet\Services\TransarcAFSDaemon\Parameters" "MountRoot" "/afs" @@ -700,6 +697,14 @@ SectionEnd Section "AFS Server" secServer SetShellVarContext all + + ; Check for bad previous installation (if we are doing a new install) + Call IsAnyAFSInstalled + Pop $R0 + StrCmp $R0 "0" +1 skipCheck + Call CheckPathForAFS +skipCheck: + ; Stop any running services or we can't replace the files ; Stop the running processes GetTempFileName $R0 @@ -817,8 +822,7 @@ Section "AFS Server" secServer File "${AFS_WININSTALL_DIR}\Service.pdb" !endif ;Don't want to whack existing settings... Make users un-install and then re-install if they want that - !insertmacro SERVICE "delete" "TransarcAFSServer" "" - ;insertmacro SERVICE "create" "TransarcAFSServer" "path=$INSTDIR\Server\usr\afs\bin\bosctlsvc.exe;autostart=1" + ;nsExec::Exec '$INSTDIR\Common\service.exe u TransarcAFSServer' nsExec::Exec '$INSTDIR\Common\service.exe TransarcAFSServer "$INSTDIR\Server\usr\afs\bin\bosctlsvc.exe" "OpenAFS AFS Server"' Delete "$INSTDIR\Common\service.exe" @@ -1607,7 +1611,7 @@ StartRemove: GetTempFileName $R0 File /oname=$R0 "${AFS_WININSTALL_DIR}\Killer.exe" nsExec::Exec '$R0 afscreds.exe' - nsExec::Exec "afscreds.exe -z" + Exec "afscreds.exe -z" ; in case we are upgrading an old version that does not support -z Sleep 2000 nsExec::Exec '$R0 afscreds.exe' @@ -1616,16 +1620,19 @@ StartRemove: !ENDIF ; Delete the AFS service - ; New method for service manipulation - !undef "UN" - !define "UN" "un." - !insertmacro SERVICE "stop" "TransarcAFSDaemon" "" - !insertmacro SERVICE "stop" "TransarcAFSDaemon" "" - !insertmacro SERVICE "delete" "TransarcAFSDaemon" "" - !insertmacro SERVICE "delete" "TransarcAFSServer" "" + GetTempFileName $R0 + File /oname=$R0 "${AFS_WININSTALL_DIR}\Service.exe" + nsExec::Exec "net stop TransarcAFSDaemon" + nsExec::Exec "net stop TransarcAFSServer" + nsExec::Exec '$R0 u TransarcAFSDaemon' + ; After we stop the service, but before we delete it, we have to remove the volume data + ; This is because the storage locations are in the registry under the service key. + ; Call un.RemoveAFSVolumes + nsExec::Exec '$R0 u TransarcAFSServer' + Delete $R0 Call un.RemoveProvider - + Push "$INSTDIR\Client\Program" Call un.RemoveFromPath Push "$INSTDIR\Common" @@ -2021,12 +2028,12 @@ StrCmp $R0 "1" DoDownload ReadINIStr $R0 $0 "Field 2" "State" StrCmp $R0 "1" done +ReadINIStr $R0 $0 "Field 6" "State" +StrCmp $R0 "1" CheckOther + ReadINIStr $R0 $0 "Field 3" "State" StrCmp $R0 "1" UsePackaged -ReadINIStr $R0 $0 "Field 6" "State" - StrCmp $R0 "1" CheckOther - ; If none of these, grab file from other location goto UsePackaged @@ -2052,6 +2059,132 @@ done: FunctionEnd +Function AddProvider + Push $R0 + Push $R1 + ReadRegStr $R0 HKLM "SYSTEM\CurrentControlSet\Control\NetworkProvider\HWOrder" "ProviderOrder" + Push $R0 + StrCpy $R0 "TransarcAFSDaemon" + Push $R0 + Call StrStr + Pop $R0 + StrCmp $R0 "" +1 DoOther + ReadRegStr $R1 HKLM "SYSTEM\CurrentControlSet\Control\NetworkProvider\HWOrder" "ProviderOrder" + StrCpy $R0 "$R1,TransarcAFSDaemon" + WriteRegStr HKLM "SYSTEM\CurrentControlSet\Control\NetworkProvider\HWOrder" "ProviderOrder" $R0 +DoOther: + ReadRegStr $R0 HKLM "SYSTEM\CurrentControlSet\Control\NetworkProvider\Order" "ProviderOrder" + Push $R0 + StrCpy $R0 "TransarcAFSDaemon" + Push $R0 + Call StrStr + Pop $R0 + StrCmp $R0 "" +1 End + ReadRegStr $R1 HKLM "SYSTEM\CurrentControlSet\Control\NetworkProvider\Order" "ProviderOrder" + StrCpy $R0 "$R1,TransarcAFSDaemon" + WriteRegStr HKLM "SYSTEM\CurrentControlSet\Control\NetworkProvider\Order" "ProviderOrder" $R0 +End: + Pop $R1 + Pop $R0 +FunctionEnd + +Function un.RemoveProvider + Push $R0 + StrCpy $R0 "TransarcAFSDaemon" + Push $R0 + StrCpy $R0 "SYSTEM\CurrentControlSet\Control\NetworkProvider\HWOrder" + Call un.RemoveFromProvider + StrCpy $R0 "TransarcAFSDaemon" + Push $R0 + StrCpy $R0 "SYSTEM\CurrentControlSet\Control\NetworkProvider\Order" + Call un.RemoveFromProvider + Pop $R0 +FunctionEnd + +Function un.RemoveFromProvider + Exch $0 + Push $1 + Push $2 + Push $3 + Push $4 + Push $5 + Push $6 + + ReadRegStr $1 HKLM "$R0" "ProviderOrder" + 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 $2 ; pos of our dir + StrCmp $2 "" unRemoveFromPath_done + ; else, it is in path + # $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 + + StrCpy $5 $3 1 -1 # copy last char + StrCmp $5 "," 0 +2 # if last char == , + StrCpy $3 $3 -1 # remove last char + + WriteRegStr HKLM "$R0" "ProviderOrder" $3 + + unRemoveFromPath_done: + Pop $6 + Pop $5 + Pop $4 + Pop $3 + Pop $2 + Pop $1 + Pop $0 +FunctionEnd + +Function CheckPathForAFS + Push $0 + Push $1 + Push $2 + Push $3 + ReadRegStr $1 HKLM "SYSTEM\CurrentControlSet\Control\Session Manager\Environment" "PATH" + StrCpy $1 "$1;" +loop: + Push $1 + Push ";" + Call StrStr + Pop $0 + StrLen $2 $0 + StrCpy $3 $1 -$2 + IfFileExists "$3\afsd_service.exe" Error + StrCpy $1 $0 32768 1 + StrLen $2 $1 + IntCmp $2 0 Done Done loop + goto Done +Error: + MessageBox MB_ICONSTOP|MB_OK|MB_TOPMOST "This installer is unable to upgrade the previous version of AFS. Please uninstall the current AFS version before continuing." + Abort "Unable to install OpenAFS" +Done: + Pop $3 + Pop $2 + Pop $1 + Pop $0 +FunctionEnd + +Function AddToUniquePath + Pop $R0 + Push $R0 + Push "$R0;" + ReadRegStr $R0 HKLM "SYSTEM\CurrentControlSet\Control\Session Manager\Environment" "PATH" + Push "$R0;" + Call StrStr + Pop $R0 + StrCmp $R0 "" +1 Done + Call AddToPath +Done: +FunctionEnd ;------------------------------- @@ -3606,118 +3739,4 @@ noClose: Pop $2 Pop $1 Exch $R0 -FunctionEnd - -Function AddProvider - Push $R0 - Push $R1 - ReadRegStr $R0 HKLM "SYSTEM\CurrentControlSet\Control\NetworkProvider\HWOrder" "ProviderOrder" - Push $R0 - StrCpy $R0 "TransarcAFSDaemon" - Push $R0 - Call StrStr - Pop $R0 - StrCmp $R0 "" +1 DoOther - ReadRegStr $R1 HKLM "SYSTEM\CurrentControlSet\Control\NetworkProvider\HWOrder" "ProviderOrder" - StrCpy $R0 "$R1,TransarcAFSDaemon" - WriteRegStr HKLM "SYSTEM\CurrentControlSet\Control\NetworkProvider\HWOrder" "ProviderOrder" $R0 -DoOther: - ReadRegStr $R0 HKLM "SYSTEM\CurrentControlSet\Control\NetworkProvider\Order" "ProviderOrder" - Push $R0 - StrCpy $R0 "TransarcAFSDaemon" - Push $R0 - Call StrStr - Pop $R0 - StrCmp $R0 "" +1 End - ReadRegStr $R1 HKLM "SYSTEM\CurrentControlSet\Control\NetworkProvider\Order" "ProviderOrder" - StrCpy $R0 "$R1,TransarcAFSDaemon" - WriteRegStr HKLM "SYSTEM\CurrentControlSet\Control\NetworkProvider\Order" "ProviderOrder" $R0 -End: - Pop $R1 - Pop $R0 -FunctionEnd - -Function un.RemoveProvider - Push $R0 - StrCpy $R0 "TransarcAFSDaemon" - Push $R0 - StrCpy $R0 "SYSTEM\CurrentControlSet\Control\NetworkProvider\HWOrder" - Call un.RemoveFromProvider - StrCpy $R0 "TransarcAFSDaemon" - Push $R0 - StrCpy $R0 "SYSTEM\CurrentControlSet\Control\NetworkProvider\Order" - Call un.RemoveFromProvider - Pop $R0 -FunctionEnd - -Function un.RemoveFromProvider - Exch $0 - Push $1 - Push $2 - Push $3 - Push $4 - Push $5 - Push $6 - - ReadRegStr $1 HKLM "$R0" "ProviderOrder" - 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 $2 ; pos of our dir - StrCmp $2 "" unRemoveFromPath_done - ; else, it is in path - # $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 - - StrCpy $5 $3 1 -1 # copy last char - StrCmp $5 "," 0 +2 # if last char == , - StrCpy $3 $3 -1 # remove last char - - WriteRegStr HKLM "$R0" "ProviderOrder" $3 - - unRemoveFromPath_done: - Pop $6 - Pop $5 - Pop $4 - Pop $3 - Pop $2 - Pop $1 - Pop $0 -FunctionEnd - -Function CheckPathForAFS - Push $0 - Push $1 - Push $2 - Push $3 - ReadRegStr $1 HKLM "SYSTEM\CurrentControlSet\Control\Session Manager\Environment" "PATH" - StrCpy $1 "$1;" -loop: - Push $1 - Push ";" - Call StrStr - Pop $0 - StrLen $2 $0 - StrCpy $3 $1 -$2 - IfFileExists "$3\afsd_service.exe" Error - StrCpy $1 $0 32768 1 - StrLen $2 $1 - IntCmp $2 0 Done Done loop - goto Done -Error: - MessageBox MB_ICONSTOP|MB_OK|MB_TOPMOST "This installer is unable to upgrade the previous version of AFS. Please uninstall the current AFS version before continuing." - Abort "Unable to install OpenAFS" -Done: - Pop $3 - Pop $2 - Pop $1 - Pop $0 -FunctionEnd +FunctionEnd \ No newline at end of file -- 2.39.5