📄 destdir.tcl
字号:
# checkInstallover# .tE## PARAMETERS: N/A## RETURNS: 0 = NO - installation over the existing tree is NOT allowed# 1 = YES - installation over the existing tree is allowed## ERRORS: N/A#proc checkInstallover {} { global env setupVals global installRules global ctrlVals set instFile [file join $env(CD_ROOT) RESOURCE INF INSTALLOVER.INF] set setupFile [file join [destDirGet] setup.log] set invalidTree 0 set treePoolIdList "" set tornadoInstalled 0 # if no setup.log... if { ![file exists $setupFile] } { dbgputs "setup.log does not exist" if { [isBSPcd] } { set invalidTree 1 } else { # For CORE CD: new tree -> allow installation return 1 } } # get previous installations information (TDK#s) from setup.log # SETUP uses this info to check against validation table # (INSTALLOVER.INF) to see if this tree will be compatible # with the current installation of the CD. if { ![catch {open $setupFile "r"} setupFd] } { # loop through and check EVERY record in setup.log while { [gets $setupFd line] >= 0 } { if {[regexp {(TDK-[0-9]+-[a-zA-Z]+-[0-9]+)} $line id]} { lappend treePoolIdList $id } elseif { [regexp {.+Tornado Tools: .+} $line] } { if { [isBSPcd] } { # BSP CD: check if tree contains Tornado Tools set tornadoInstalled 1 } } else { continue } } close $setupFd } dbgputs "current CD poolId: $setupVals(CDnumber)" dbgputs "installed tree poolId list: $treePoolIdList" # empty setup.log = prev installation didn't get pass # copying SETUP files... if { [string match $treePoolIdList ""] } { dbgputs "Empty setup.log" if { [isBSPcd] } { set invalidTree 1 } else { # For CORE CD: new tree -> allow installation return 1 } } # For BSP CD: give warning for invalid tree if { $invalidTree && !$tornadoInstalled } { if { [dialog yes_no "WARNING: Invalid Tree" \ [strTableGet DESTDIR_INVALID_TOR_TREE]] } { # user chooses "no" to re-enter directory return 0 } else { uninstLog setupLog "BSP/Drivers CD installation: user chose\ to install in an invalid Tornado tree." } } # If this installation is of the same CD as the previous # one (same TDK#), then allow installover if {[lsearch $treePoolIdList $setupVals(CDnumber)] != -1} { dbgputs "Same CD as previous install - OK" return 1 } # If missing INSTALLOVER.INF file, it's our fault # Warn user, log in setup.log and proceed. if { ![file exists $instFile]} { set msg "Missing File: $instFile\nSETUP is unable to find\ the installation validation rules for this CD" # test automation if { $ctrlVals(useInputScript) } { autoSetupLog "Destination Directory page:" autoSetupLog "WARNING: Missing File $msg" } else { dialog ok_with_title "WARNING: Missing File" $msg uninstLog setupLog $msg } return 1 } if { [catch {open $instFile "r"} instFd] } { # If cannot open/read INSTALLOVER.INF file, it's our fault # Warn user, log in setup.log and proceed. set msg "Error in reading $instFile\nSETUP is unable to\ find the installation validation rules for this CD" # test automation if { $ctrlVals(useInputScript) } { autoSetupLog "Destination Directory page:" autoSetupLog "Error Reading File $msg" } else { dialog ok_with_title "Error Reading File" $msg uninstLog setupLog $msg } return 1 } else { # This block of codes reads INSTALLOVER.INF each line # and do checking to see if the current installation of this # this CD will be compatible with the existing tree user. # variable used to check if the current CD's poolId is # found in an entry (in 1st column) set matchRuleOnce 0 # reading INSTALLOVER.INF file while { [gets $instFd line] >= 0 } { # skip comment line if {[regexp {^#} [string trimleft $line] ]} { continue } # skip empty line if {[regexp {^$} [string trimleft $line] ]} { continue } # remove empty elements due to white spaces between 2 columns set str [split $line] while {[set ndex [lsearch -exact $str {}]] != -1} { set str [lreplace $str $ndex $ndex] } # get rule: # cd-tdk and compatible installed-tdk set ruleCdTdk [string trimleft [lindex $str 0]] set ruleInstTdk [string trimleft [lindex $str 1]] # find the right rule for this current CD # (i.e. matching a rule with the CD Number (TDK#)) if { [string match $ruleCdTdk $setupVals(CDnumber)] } { # find rule for this CD set matchRuleOnce 1 # find rule: now check if installed tree is compatible # if more than one compatible TDKs, seperate them by space set ruleInstTdk [split $ruleInstTdk ":"] # Loop through all compatible TDKs to match at least one. # Compare each "compatible-tdk" from the rule table to # match one of the TDK numbers obtained from setup.log # If the existing tree is compatible with the current # installation of this CD, log Rule matched # and proceed with installation foreach iTdk $ruleInstTdk { if {[lsearch $treePoolIdList $iTdk] != -1} { set msg "Match Installation Validation Rule:\ $ruleCdTdk\t$iTdk" dbgputs $msg uninstLog setupLog $msg return 1 } } # If poolId of the existing tree does not match with # any of the compatible TDKs in the table, give error set msg "Installation validation FAILED - no match" dbgputs $msg set displayMsg \ "You appear to be installing this CD into an\ incompatible tree. The installation tree must match the\ following(s): $setupVals(CDnumber) $ruleInstTdk\n\nIf you\ choose to continue, you may corrupt your existing tree." # For BSP/Drivers CD, only give warnings and log in setup.log - # allow user to install multiple-arch BSPs/Drivers in one tree. # BUT for core CD, error - must install in a tree with same arch if { [isBSPcd] } { set choice "Do you want to continue with installation?\ Click yes to proceed or click no to re-enter\ the destination directory." # swap the return value from procedure "dialog" # to match the return value for this procedure set answer [dialog yes_no "WARNING: BSP Installation" \ "WARNING: $displayMsg\n\n$choice"] if { $answer } { # user chooses "no" return 0 } else { uninstLog setupLog "$msg, and installation\ was continued (BSP CD)" return 1 } } else { set msg "ERROR: $displayMsg SETUP will not allow this\ installation. Please choose another directory." dialog ok_with_title "Error: Installation Not Allowed" $msg return 0 } } } # Rule for this CD's poolId is not listed in INSTALLOVER.INF # Our fault - missing an entry. Inform user, log it, and proceed if { !$matchRuleOnce && [isBSPcd]} { set msg "Rules not found.\nSETUP is unable to find the\ installation validation rules for this CD" # test automation if { $ctrlVals(useInputScript) } { autoSetupLog "Destination Directory page:" autoSetupLog "WARNING: Rules not found $msg" } else { dialog ok_with_title "WARNING: Rules not found" $msg uninstLog setupLog $msg } } return 1 }}####################################################################### Dialog Text Messages######################################################################set strTable(DESTDIR_TITLE) "Select Directory"set strTable(DESTDIR_LABEL_1) \ "format %s \"Please enter the directory path where\n\[cdromDescGet]\ has already been installed.\ \n\nClick the Browse button to choose the directory\ interactively.\""set strTable(DESTDIR_LABEL_SHORTCUTS) \ "format %s \"Please enter the directory path where\n\[cdNameGet description]\ has already been installed on your\ network, or click the Browse button to choose the directory\ interactively.\""set strTable(DESTDIR_LABEL_2) "Remote Directory"set strTable(DESTDIR_LABEL_3) \ "format %s \"Please enter the directory path where you\ want SETUP to install [cdNameGet description],\ or click the Browse button to choose the directory\ interactively.\""set strTable(DESTDIR_LABEL_3_TEXT) \ "format %s \"Please enter the directory path where you\ want SETUP to install [cdromDescGet].\""set strTable(DESTDIR_LABEL_3_BSP_TEXT) \ "format %s \"Please enter the directory path of the installed\ Tornado tree where you wish to install BSP/Driver products\ from this CD.\""set strTable(DESTDIR_LABEL_4) "Destination Directory"set strTable(DESTDIR_LABEL_5) "Installed Tornado Tree Directory"set strTable(DESTDIR_LABEL_6) \ "format %s \"Please provide the location of the installed\ Tornado tree where you wish to install BSP/Driver products\ from this CD. \n\nClick the Browse button to choose the\ directory interactively.\""set strTable(DESTDIR_WARN_1) \ "format %s \"The installation directory you entered contains white\ space(s). Please select another directory.\""set strTable(DESTDIR_WARN_2) \ "format %s \"Installing \[cdromDescGet\] in the root directory\ is not recommended.\nClick Yes to select another directory.\""set strTable(DESTDIR_WARN_2_TEXT) \ "format %s \"Installing \[cdromDescGet\] in the root directory\ is not recommended.\""set strTable(DESTDIR_WARN_3) \ "The installation directory you entered does not exist.\ \nDo you want to create it now?"set strTable(DESTDIR_WARN_4) \ "You do not have permission to write files into the installation\ directory you entered.\ \n\nPlease choose a writable directory."set strTable(DESTDIR_WARN_5) \ "format %s \"Unable to create [destDirGet].\""set strTable(DESTDIR_WARN_6) \ "format %s \"Creating [destDirGet] failed: file exists.\""set strTable(DESTDIR_WARN_7) \ "Please provide a directory path starting with a drive name."set strTable(DESTDIR_WARN_8) \ "Please provide a directory path starting with a letter character."set strTable(DESTDIR_WARN_9) \ "Please provide directory path starting with letter characters."set strTable(DESTDIR_WARN_10) \ "Please provide a directory path without these special characters:\ \]\[\$\^\?\+\*\(\)\|\{\}."set strTable(DESTDIR_WARN_11) \ "Please provide a directory path without these special characters:\ \]\[\$\^\?\+\*\(\)\|\{\}'~."set strTable(DESTDIR_INVALID_TOR_TREE) \ "The directory path you have entered is not a valid\ Tornado tree.\n\n\"BSPs/Drivers\" CD must be installed over\ a tree which contains Tornado Tools.\n\nDo you want to continue\ with installation? Click yes to proceed or click no to\ re-enter the destination directory."
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -