Changes On Branch 19cfb58c4c9fcd90
Not logged in

Changes In Branch vNext Through [19cfb58c4c] Excluding Merge-Ins

This is equivalent to a diff from fecb8511da to 19cfb58c4c

2022-03-02
20:43
Merge various recent fixes and enhancements to the package client toolset. check-in: 372ee60877 user: mistachkin tags: trunk
2022-02-20
16:44
Update generated documentation. check-in: 029c9867a5 user: test tags: vNext
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
02:30
Optionally allow reuse of temporary package directories. check-in: e5470474bd user: test tags: vNext
2021-11-11
15:23
Pickup the platform detection changes from upstream. check-in: fecb8511da user: mistachkin tags: trunk
2021-08-08
00:11
Pickup the Harpy script signing tooling changes from upstream. check-in: 7f8b164b2f user: mistachkin tags: trunk

Modified client/1.0/neutral/pkgd.eagle from [0aa315b515] to [3c3ca7ea39].

697
698
699
700
701
702
703




























704
705
706
707
708
709
710
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738







+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+







        return true
      }
    } else {
      return false
    }
  }

  #
  # NOTE: This procedure attempts to verify the specified OpenPGP signature
  #       file.  If the forcePgp parameter is non-zero verification will be
  #       attempted even when the specified file does not appear to be an
  #       OpenPGP signature file.  This procedure may raise script errors.
  #
  proc maybeVerifyOpenPgpSignature { fileName forcePgp } {
    #
    # NOTE: Is this temporary package file actually just an OpenPGP
    #       signature file?  If so, skip it.
    #
    if {$forcePgp || \
        [isOpenPgpSignatureFileName $fileName true]} then {
      #
      # NOTE: Attempt to verify the OpenPGP signature.  If this fails,
      #       an error is raised.
      #
      ::PackageRepository::probeForOpenPgpInstallation
      ::PackageRepository::openPgpMustBeInstalled

      if {![::PackageRepository::verifyOpenPgpSignature \
          $fileName]} then {
        error [appendArgs \
            "bad OpenPGP signature \"" $fileName \"]
      }
    }
  }

  #
  # NOTE: This procedure returns the auto-path for the language specified by
  #       the language argument.  An empty list is returned if the auto-path
  #       does not exist in the target language.  This procedure may raise
  #       script errors.
  #
  proc getAutoPath { language } {
1748
1749
1750
1751
1752
1753
1754
1755

1756
1757

1758
1759
1760
1761

1762
1763
1764
1765
1766
1767
1768
1776
1777
1778
1779
1780
1781
1782

1783
1784

1785
1786
1787
1788

1789
1790
1791
1792
1793
1794
1795
1796







-
+

-
+



-
+







  #       a package index file.  The language argument must be one of the
  #       literal strings "eagle", "tcl", or "client".  The fileNames argument
  #       must be the list of file names to be downloaded.  The package name,
  #       if one can be detected, is returned; otherwise, an empty string will
  #       be returned.
  #
  proc guessPackageNameFromFileNames { language fileNames } {
    set packageIndexFileName [getPackageIndexFileName $language]
    set packageIndexFileNameOnly [getPackageIndexFileName $language]

    if {[string length $packageIndexFileName] > 0} then {
    if {[string length $packageIndexFileNameOnly] > 0} then {
      foreach fileName $fileNames {
        set fileNameOnly [file tail $fileName]

        if {$fileNameOnly eq $packageIndexFileName} then {
        if {$fileNameOnly eq $packageIndexFileNameOnly} then {
          set directory [file dirname $fileName]

          if {[string length $directory] > 0} then {
            return [file tail $directory]
          }
        }
      }
1896
1897
1898
1899
1900
1901
1902
1903

1904
1905
1906
1907


1908
1909
1910
1911
1912

1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1924
1925
1926
1927
1928
1929
1930

1931

1932


1933
1934
1935




1936



1937
1938
1939
1940
1941
1942
1943







-
+
-

-
-
+
+

-
-
-
-
+
-
-
-







    #
    writeFile $localFileName [getPackageFile $uri]

    #
    # NOTE: Is use of OpenPGP for signature verification enabled?  Also,
    #       did we just download an OpenPGP signature file?
    #
    if {$usePgp && ($forcePgp || \
    if {$usePgp} then {
        [isOpenPgpSignatureFileName $localFileName true])} then {
      #
      # NOTE: Attempt to verify the OpenPGP signature.  If this fails,
      #       an error is raised.
      # NOTE: Maybe attempt to verify the OpenPGP signature.  If this
      #       fails, an error is raised.
      #
      ::PackageRepository::probeForOpenPgpInstallation
      ::PackageRepository::openPgpMustBeInstalled

      if {![::PackageRepository::verifyOpenPgpSignature $localFileName]} then {
      maybeVerifyOpenPgpSignature $localFileName $forcePgp
        error [appendArgs \
            "bad OpenPGP signature \"" $localFileName \"]
      }
    }
  }

  #
  # NOTE: This procedure downloads a single file from the package file server,
  #       writing its contents to the specified local file name.  It can also
  #       verify the OpenPGP signatures.  When an OpenPGP signature file is
2185
2186
2187
2188
2189
2190
2191
2192

2193
2194

2195
2196
2197

2198
2199
2200
2201
2202
2203
2204
2205
2206
2207
2208
2209
2210















































































2211
2212
2213
2214
2215
2216
2217
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







-
+

-
+


-
+













+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+







        set downloadDirectories [list $persistentDirectory]
      } else {
        #
        # NOTE: Check each unique download directory for a package index
        #       file.  If a directory has a package index for the target
        #       language, add to the auto-path for the target language.
        #
        set packageIndexFileName [getPackageIndexFileName $language]
        set packageIndexFileNameOnly [getPackageIndexFileName $language]

        if {[string length $packageIndexFileName] > 0} then {
        if {[string length $packageIndexFileNameOnly] > 0} then {
          foreach downloadDirectory $downloadDirectories {
            if {[file exists [file join \
                $downloadDirectory $packageIndexFileName]]} then {
                $downloadDirectory $packageIndexFileNameOnly]]} then {
              addToAutoPath $language $downloadDirectory
            }
          }
        }
      }
    }

    #
    # NOTE: Always return the list of directories that were actually added
    #       to the auto-path, if any.
    #
    return $downloadDirectories
  }

  #
  # NOTE: This procedure adds temporary package directories to the auto-path
  #       of the specified language (i.e. native Tcl or Eagle).  Directories
  #       will not be added if already present.  The language argument must
  #       be the literal string "eagle" or the literal string "tcl".  The
  #       pattern argument is the optional pattern to match against each of
  #       the candidate temporary package directories.  If the pattern is an
  #       empty string then all candidate temporary package directories will
  #       be added to the auto-path; otherwise, the pattern will be matched
  #       against the final portion of the temporary package directory name
  #       and only those temporary package directories that actually match
  #       the pattern will be added to the auto-path.  The options argument
  #       must be a dictionary of name/value pairs.  This procedure does not
  #       currently support any options.  This procedure may raise script
  #       errors.  This procedure assumes the local temporary directory is
  #       writable only by applications that are implicitly trusted by the
  #       current user.  If this assumption does not hold on your platform,
  #       DO NOT USE THIS PROCEDURE AS IT MAY BE UNSAFE.
  #
  # <public>
  proc maybeAddTemporaryPackagesToAutoPath { language options {pattern *} } {
    variable temporaryRootDirectory
    variable verboseTemporaryDirectory

    #
    # NOTE: Initially, no temporary package directories have been added
    #       to the auto-path.
    #
    set result [list]; set packageNames [list]

    #
    # NOTE: What is the package index file name for this language?  Each
    #       candidate temporary package directory will be checked to see
    #       if it contains this file; otherwise, it will not be added to
    #       the auto-path.
    #
    set packageIndexFileNameOnly [getPackageIndexFileName $language]

    #
    # HACK: Obtain the list of candidate temporary package directories
    #       that may need to be added to the auto-path.  The prefix we
    #       use here is considered "well-known" by this package.
    #
    set directories(1) [glob -nocomplain -types {d} \
        [file join $temporaryRootDirectory pkgd_lib_*]]

    foreach directory(1) $directories(1) {
      set directories(2) [glob -nocomplain -types {d} \
          [file join $directory(1) *]]

      foreach directory(2) $directories(2) {
        set directoryNameOnly(2) [file tail $directory(2)]
        set packageName $directoryNameOnly(2); # HACK: Well-known.

        if {[lsearch -exact $packageNames $packageName] == -1} then {
          if {[string length $pattern] == 0 || \
              [string match $pattern $directoryNameOnly(2)]} then {
            if {[string length $packageIndexFileNameOnly] == 0 || \
                [file exists [file join $directory(2) \
                    $packageIndexFileNameOnly]]} then {
              if {[maybeAddToAutoPath $language $directory(2)]} then {
                lappend packageNames $directoryNameOnly(2)
                lappend result $directory(2)

                if {$verboseTemporaryDirectory} then {
                  pkgLog [appendArgs \
                      "added temporary package directory named \"" \
                      $directory(2) "\" to auto-path..."]
                }
              }
            }
          }
        }
      }
    }

    return $result
  }

  #
  # NOTE: This package requires the package repository client package.
  #
  package require Eagle.Package.Repository

  #

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
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 {
          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
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 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
  # 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
  #       and file name for the primary package repository client script
  #       file.
  #       for a package client toolset script file.
  #
  # <public>
  proc maybeReadSettingsFiles { script } {
    global env
    global tcl_platform

    if {[string length $script] == 0 || \
    if {[string length $script] == 0 || ![file exists $script]} then {
        ![file exists $script] || ![file isfile $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 prefixes [list]
    set allFileNamesOnly [list]

    if {[info exists tcl_platform(user)]} then {
      lappend prefixes $tcl_platform(user)
    }

    set allPrefixes [getSettingsPrefixes \
        $scriptLowerName $scriptUpperName true]

    foreach prefix $allPrefixes {
    if {[catch {info hostname} hostName] == 0 && \
        [string length $hostName] > 0} then {
      lappend prefixes $hostName
    }
      if {[string length $prefix] > 0} then {
        set prefix [appendArgs . $prefix]
      }

      set fileNameOnly [appendArgs \
          $scriptRootName .settings $prefix \
    lappend prefixes $scriptLowerName
          $scriptExtension]

    if {[info exists [appendArgs \
        env(DEBUG_ $scriptUpperName )]]} then {
      lappend prefixes debug
      lappend allFileNamesOnly $fileNameOnly
    }

    lappend prefixes ""
    set scriptPrefixes [getSettingsPrefixes \
        $scriptLowerName $scriptUpperName false]

    foreach prefix $prefixes {
    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] {
        #
        # 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] && [file isfile $fileName]} then {
          uplevel 1 [list source $fileName]; incr count
          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
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] && [file isfile $fileName]} then {
      if {[file exists $fileName]} then {
        uplevel 1 [list source $fileName]
      }
    }
  }

  #
  # NOTE: This procedure sets up the default values for all configuration