Index: client/1.0/neutral/pkgr.eagle ================================================================== --- client/1.0/neutral/pkgr.eagle +++ client/1.0/neutral/pkgr.eagle @@ -453,11 +453,11 @@ if {[file isdirectory $subDirectory]} then { foreach fileNameOnly $openPgpFileNamesOnly { set fileName [file join $subDirectory $fileNameOnly] - if {[file exists $fileName] && [file isfile $fileName]} then { + if {[file exists $fileName]} then { pkgLog [appendArgs \ "the OpenPGP directory is being initialized to \"" \ $subDirectory "\" based on OpenPGP file name \"" \ $fileNameOnly \"] @@ -2200,26 +2200,60 @@ isPackagePresent $package $version } } # - # NOTE: This procedure evaluates the package repository client settings - # script file, if it exists. Any script errors raised are not - # masked. The script argument must be the fully qualified path - # and file name for the primary package repository client script - # file. + # NOTE: This procedure returns the list of possible prefixes that should be + # considered for settings files. The scriptName parameter is the name + # of the script being evaluated, if any. The envVarName parameter is + # the name of an environment variable associated with the script being + # evaluated, if any. The all parameter should be non-zero to include + # all available prefixes, even if they are inapplicable to the current + # configuration. This procedure may raise script errors. + # + proc getSettingsPrefixes { scriptName envVarName all } { + global env + + set result [list] + + if {[info exists tcl_platform(user)]} then { + lappend result $tcl_platform(user) + } + + if {[catch {info hostname} hostName] == 0 && \ + [string length $hostName] > 0} then { + lappend result $hostName + } + + if {[string length $scriptName] > 0} then { + lappend result $scriptName + } + + if {$all || ([string length $envVarName] > 0 && \ + [info exists [appendArgs env(DEBUG_ $envVarName )]])} then { + lappend result debug + } + + lappend result ""; return $result + } + + # + # NOTE: This procedure evaluates package repository client settings script + # files, if they exists. Any script errors raised are not masked. + # The script argument must be the fully qualified path and file name + # for a package client toolset script file. # # proc maybeReadSettingsFiles { script } { global env global tcl_platform - if {[string length $script] == 0 || \ - ![file exists $script] || ![file isfile $script]} then { + if {[string length $script] == 0 || ![file exists $script]} then { return -1 } + set scriptPath [file normalize [file dirname $script]] set scriptTail [file tail $script] set scriptRootName [file rootname $scriptTail] set scriptExtension [file extension $scriptTail] set scriptUpperName [string toupper $scriptRootName] set scriptLowerName [string tolower $scriptRootName] @@ -2228,50 +2262,64 @@ env(NO_SETTINGS_ $scriptUpperName )]]} then { return -2 } set count 0 - set prefixes [list] - - if {[info exists tcl_platform(user)]} then { - lappend prefixes $tcl_platform(user) - } - - if {[catch {info hostname} hostName] == 0 && \ - [string length $hostName] > 0} then { - lappend prefixes $hostName - } - - lappend prefixes $scriptLowerName - - if {[info exists [appendArgs \ - env(DEBUG_ $scriptUpperName )]]} then { - lappend prefixes debug - } - - lappend prefixes "" - - foreach prefix $prefixes { + set allFileNamesOnly [list] + + set allPrefixes [getSettingsPrefixes \ + $scriptLowerName $scriptUpperName true] + + foreach prefix $allPrefixes { + if {[string length $prefix] > 0} then { + set prefix [appendArgs . $prefix] + } + + set fileNameOnly [appendArgs \ + $scriptRootName .settings $prefix \ + $scriptExtension] + + lappend allFileNamesOnly $fileNameOnly + } + + set scriptPrefixes [getSettingsPrefixes \ + $scriptLowerName $scriptUpperName false] + + foreach prefix $scriptPrefixes { if {[string length $prefix] > 0} then { set prefix [appendArgs . $prefix] } - set fileName [appendArgs \ - $scriptRootName .settings $prefix $scriptExtension] + set fileNameOnly [appendArgs \ + $scriptRootName .settings $prefix \ + $scriptExtension] + + set fileName [file join \ + $scriptPath $fileNameOnly] - if {[file exists $fileName] && [file isfile $fileName]} then { + if {[file exists $fileName]} then { uplevel 1 [list source $fileName]; incr count } } if {$count == 0} then { - set pattern [file join [file normalize [file dirname $script]] \ - [appendArgs $scriptRootName .settings.* $scriptExtension]] + set pattern [file join $scriptPath [appendArgs \ + $scriptRootName .settings.* $scriptExtension]] foreach fileName [glob -nocomplain -- $pattern] { - if {[file exists $fileName] && [file isfile $fileName]} then { - uplevel 1 [list source $fileName]; incr count + # + # BUGFIX: Do not consider any settings script file + # that may have already been evaluated via + # the above list(s) of script prefixes. + # + set fileNameOnly [file tail $fileName] + + if {[lsearch -exact \ + $allFileNamesOnly $fileNameOnly] == -1} then { + if {[file exists $fileName]} then { + uplevel 1 [list source $fileName]; incr count + } } } } return $count @@ -2293,11 +2341,11 @@ } if {[info exists env(PKGR_API_KEYS_FILE)]} then { set fileName $env(PKGR_API_KEYS_FILE) - if {[file exists $fileName] && [file isfile $fileName]} then { + if {[file exists $fileName]} then { uplevel 1 [list source $fileName] } } }