Check-in [eb868495e1]
Not logged in
Overview
Comment:Fix the settings file logic in two ways: 1) do not re-evaluate any settings file (via wildcard matching) that may have already been evaluated based on the list of prefixes. 2) always evaluate settings files relative to the (parent) script directory, not the current directory.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | vNext
Files: files | file ages | folders
SHA1: eb868495e1a44feea29dbcbf8d701b2cc0a8d3e2
User & Date: test on 2022-02-20 16:25:40
Original Comment: Fix the settings file logic in two ways: 1) do not re-evaluate any settings file (via wildcard matching) that may have already been evaluated based on the list of prefixes. 2) always evaluate script files relative to the script directory, not the current directory.
Other Links: branch diff | manifest | tags
Context
2022-02-20
16:34
Fix some comments. check-in: 19cfb58c4c user: test tags: vNext
16:25
Fix the settings file logic in two ways: 1) do not re-evaluate any settings file (via wildcard matching) that may have already been evaluated based on the list of prefixes. 2) always evaluate settings files relative to the (parent) script directory, not the current directory. check-in: eb868495e1 user: test tags: vNext
15:47
Skip adding temporary package directories if they do not contain an appropriate package index file. check-in: badaf4f7d9 user: test tags: vNext
Changes

Modified client/1.0/neutral/pkgr.eagle from [8a55e06b77] to [3dcc4235ec].

451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
        set subDirectory $directory
      }

      if {[file isdirectory $subDirectory]} then {
        foreach fileNameOnly $openPgpFileNamesOnly {
          set fileName [file join $subDirectory $fileNameOnly]

          if {[file exists $fileName] && [file isfile $fileName]} then {
            pkgLog [appendArgs \
                "the OpenPGP directory is being initialized to \"" \
                $subDirectory "\" based on OpenPGP file name \"" \
                $fileNameOnly \"]

            return [addToPath $subDirectory]
          }







|







451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
        set subDirectory $directory
      }

      if {[file isdirectory $subDirectory]} then {
        foreach fileNameOnly $openPgpFileNamesOnly {
          set fileName [file join $subDirectory $fileNameOnly]

          if {[file exists $fileName]} then {
            pkgLog [appendArgs \
                "the OpenPGP directory is being initialized to \"" \
                $subDirectory "\" based on OpenPGP file name \"" \
                $fileNameOnly \"]

            return [addToPath $subDirectory]
          }
2198
2199
2200
2201
2202
2203
2204



































2205
2206
2207
2208
2209
2210
2211
2212
2213
2214
2215
2216
2217
2218
2219
2220

2221
2222
2223
2224
2225
2226
2227
2228
2229
2230
2231
2232
2233
2234
2235
2236

2237
2238
2239
2240
2241
2242
2243


2244
2245
2246
2247
2248
2249
2250
2251

2252
2253
2254
2255
2256
2257
2258
2259

2260



2261
2262
2263
2264
2265
2266
2267
2268
2269
2270









2271
2272

2273
2274
2275
2276
2277
2278
2279
      #       value here is ignored.
      #
      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.
  #
  # <public>
  proc maybeReadSettingsFiles { script } {
    global env
    global tcl_platform

    if {[string length $script] == 0 || \
        ![file exists $script] || ![file isfile $script]} then {
      return -1
    }


    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]

    if {[info exists [appendArgs \
        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 {
      if {[string length $prefix] > 0} then {
        set prefix [appendArgs . $prefix]
      }

      set fileName [appendArgs \
          $scriptRootName .settings $prefix $scriptExtension]





      if {[file exists $fileName] && [file isfile $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]]

      foreach fileName [glob -nocomplain -- $pattern] {









        if {[file exists $fileName] && [file isfile $fileName]} then {
          uplevel 1 [list source $fileName]; incr count

        }
      }
    }

    return $count
  }








>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
|
|
|
<
|






|
<



>












|

<
|
>
|
|
<
|
|
|

>
>
|

<
<
|


|
>

|




|
|
>

>
>
>
|





|
|


>
>
>
>
>
>
>
>
>
|
|
>







2198
2199
2200
2201
2202
2203
2204
2205
2206
2207
2208
2209
2210
2211
2212
2213
2214
2215
2216
2217
2218
2219
2220
2221
2222
2223
2224
2225
2226
2227
2228
2229
2230
2231
2232
2233
2234
2235
2236
2237
2238
2239
2240
2241
2242

2243
2244
2245
2246
2247
2248
2249
2250

2251
2252
2253
2254
2255
2256
2257
2258
2259
2260
2261
2262
2263
2264
2265
2266
2267
2268

2269
2270
2271
2272

2273
2274
2275
2276
2277
2278
2279
2280


2281
2282
2283
2284
2285
2286
2287
2288
2289
2290
2291
2292
2293
2294
2295
2296
2297
2298
2299
2300
2301
2302
2303
2304
2305
2306
2307
2308
2309
2310
2311
2312
2313
2314
2315
2316
2317
2318
2319
2320
2321
2322
2323
2324
2325
2326
2327
      #       value here is ignored.
      #
      isPackagePresent $package $version
    }
  }

  #
  # 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.
  #
  # <public>
  proc maybeReadSettingsFiles { script } {
    global env
    global tcl_platform

    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]

    if {[info exists [appendArgs \
        env(NO_SETTINGS_ $scriptUpperName )]]} then {
      return -2
    }

    set count 0
    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 fileNameOnly [appendArgs \
          $scriptRootName .settings $prefix \
          $scriptExtension]

      set fileName [file join \
          $scriptPath $fileNameOnly]

      if {[file exists $fileName]} then {
        uplevel 1 [list source $fileName]; incr count
      }
    }

    if {$count == 0} then {
      set pattern [file join $scriptPath [appendArgs \
          $scriptRootName .settings.* $scriptExtension]]

      foreach fileName [glob -nocomplain -- $pattern] {
        #
        # 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
  }

2291
2292
2293
2294
2295
2296
2297
2298
2299
2300
2301
2302
2303
2304
2305
    if {[info exists env(PKGR_NO_API_KEYS_FILE)]} then {
      return
    }

    if {[info exists env(PKGR_API_KEYS_FILE)]} then {
      set fileName $env(PKGR_API_KEYS_FILE)

      if {[file exists $fileName] && [file isfile $fileName]} then {
        uplevel 1 [list source $fileName]
      }
    }
  }

  #
  # NOTE: This procedure sets up the default values for all configuration







|







2339
2340
2341
2342
2343
2344
2345
2346
2347
2348
2349
2350
2351
2352
2353
    if {[info exists env(PKGR_NO_API_KEYS_FILE)]} then {
      return
    }

    if {[info exists env(PKGR_API_KEYS_FILE)]} then {
      set fileName $env(PKGR_API_KEYS_FILE)

      if {[file exists $fileName]} then {
        uplevel 1 [list source $fileName]
      }
    }
  }

  #
  # NOTE: This procedure sets up the default values for all configuration