Check-in [3cdc48fb08]
Not logged in
Overview
Comment:Add header comments to all procedures. Make sure to cleanup any 'after' events created when downloading via HTTP in native Tcl. Add language and version argument validation to the 'downloadFiles' procedure.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 3cdc48fb08a8ea10f40374464e4c1374dd89cb93
User & Date: mistachkin on 2016-08-17 22:39:16
Other Links: manifest | tags
Context
2016-08-17
23:15
Slight fix to 'after' cleanup handling. check-in: 7960da64e8 user: mistachkin tags: trunk
22:39
Add header comments to all procedures. Make sure to cleanup any 'after' events created when downloading via HTTP in native Tcl. Add language and version argument validation to the 'downloadFiles' procedure. check-in: 3cdc48fb08 user: mistachkin tags: trunk
20:06
Rename the package 'IfNeeded' piece of metadata to simply 'Script', since it may or may not actually be a real 'package ifneeded' script. check-in: b868c01046 user: mistachkin tags: trunk
Changes

Modified client/pkgd.eagle from [3c6abfbda1] to [c4607ff2e7].

16
17
18
19
20
21
22





23
24
25
26
27
28
29

#
# NOTE: Use our own namespace here because even though we do not directly
#       support namespaces ourselves, we do not want to pollute the global
#       namespace if this script actually ends up being evaluated in Tcl.
#
namespace eval ::PackageDownloader {





  proc setupDownloadVars {} {
    #
    # NOTE: Prevent progress messages from being displayed while downloading
    #       from the repository, etc?  By default, this is enabled.
    #
    variable quiet; # DEFAULT: true








>
>
>
>
>







16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34

#
# NOTE: Use our own namespace here because even though we do not directly
#       support namespaces ourselves, we do not want to pollute the global
#       namespace if this script actually ends up being evaluated in Tcl.
#
namespace eval ::PackageDownloader {
  #
  # NOTE: This procedure sets up the default values for all configuration
  #       parameters used by the package downloader client.  There are no
  #       arguments.
  #
  proc setupDownloadVars {} {
    #
    # NOTE: Prevent progress messages from being displayed while downloading
    #       from the repository, etc?  By default, this is enabled.
    #
    variable quiet; # DEFAULT: true

56
57
58
59
60
61
62





63
64
65
66
67
68
69
70








71
72
73
74
75
76
77
    variable persistentDirectory; # DEFAULT: [getPersistentRootDirectory]

    if {![info exists persistentDirectory]} then {
      set persistentDirectory [getPersistentRootDirectory]
    }
  }






  proc getPersistentRootDirectory {} {
    #
    # NOTE: Return a directory parallel to the one containing the library
    #       directory.
    #
    return [file join [file dirname [info library]] pkgr]
  }









  proc addToAutoPath { language directory } {
    #
    # NOTE: Add the specified directory to the auto-path if not already
    #       present.
    #
    if {[string length $language] == 0 || $language eq "eagle"} then {
      if {[isEagle]} then {







>
>
>
>
>








>
>
>
>
>
>
>
>







61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
    variable persistentDirectory; # DEFAULT: [getPersistentRootDirectory]

    if {![info exists persistentDirectory]} then {
      set persistentDirectory [getPersistentRootDirectory]
    }
  }

  #
  # NOTE: This procedure returns the root directory where any packages that
  #       are downloaded should be saved to permanent storage for subsequent
  #       use.  There are no arguments.
  #
  proc getPersistentRootDirectory {} {
    #
    # NOTE: Return a directory parallel to the one containing the library
    #       directory.
    #
    return [file join [file dirname [info library]] pkgr]
  }

  #
  # NOTE: This procedure adds a directory to the auto-path of the specified
  #       language (i.e. native Tcl or Eagle).  The directory will not be
  #       added if it is already present.  The language argument must be the
  #       literal string "eagle" or the literal string "tcl".  The directory
  #       argument is the fully qualified path for the directory to add to
  #       the auto-path.
  #
  proc addToAutoPath { language directory } {
    #
    # NOTE: Add the specified directory to the auto-path if not already
    #       present.
    #
    if {[string length $language] == 0 || $language eq "eagle"} then {
      if {[isEagle]} then {
104
105
106
107
108
109
110













111
112
113
114
115












116
117
118
119
120
121
122
        }
      }
    } else {
      error "unsupported language, no idea how to modify auto-path"
    }
  }














  proc downloadFiles { language version fileNames persistent } {
    variable baseUri
    variable downloadUri
    variable persistentDirectory
    variable quiet













    if {$persistent} then {
      set downloadRootDirectory [file join $persistentDirectory]
    } else {
      global env

      if {[info exists env(PKGD_TEMP)]} then {







>
>
>
>
>
>
>
>
>
>
>
>
>





>
>
>
>
>
>
>
>
>
>
>
>







122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
        }
      }
    } else {
      error "unsupported language, no idea how to modify auto-path"
    }
  }

  #
  # NOTE: This procedure attempts to download a list of files, optionally
  #       persistening them for subsequent uses by the target language.
  #       The language argument must be the literal string "eagle" or the
  #       literal string "tcl".  The version argument must be the literal
  #       string "8.4", "8.5", or "8.6" when the language is "tcl" -OR-
  #       the literal string "1.0" when the language is "eagle".  The
  #       fileNames argument must be a well-formed list of file names to
  #       download, each one relative to the language/version-specific
  #       directory on the package file server.  The persistent argument
  #       should be non-zero if the downloaded files should be saved to
  #       permanent storage for subsequent use.
  #
  proc downloadFiles { language version fileNames persistent } {
    variable baseUri
    variable downloadUri
    variable persistentDirectory
    variable quiet

    if {[string length $language] == 0 || $language eq "eagle"} then {
      if {$version ne "1.0"} then {
        error "unsupported Eagle version"
      }
    } elseif {$language eq "tcl"} then {
      if {$version ne "8.4" && $version ne "8.5" && $version ne "8.6"} then {
        error "unsupported Tcl version"
      }
    } else {
      error "unsupported language"
    }

    if {$persistent} then {
      set downloadRootDirectory [file join $persistentDirectory]
    } else {
      global env

      if {[info exists env(PKGD_TEMP)]} then {

Modified client/pkgd.eagle.harpy from [cabf8e37c6] to [82723fcc45].

17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
    THE ASSOCIATED SOFTWARE MAY NOT WORK PROPERLY IF THIS FILE IS ALTERED.
-->
<Certificate xmlns="https://eagle.to/2011/harpy"
             xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
             xmlns:xsd="http://www.w3.org/2001/XMLSchema">
  <Protocol>None</Protocol>
  <Vendor>Mistachkin Systems</Vendor>
  <Id>36e6e8e4-39ac-4f29-928e-5c10e32cb1eb</Id>
  <HashAlgorithm>SHA512</HashAlgorithm>
  <EntityType>Script</EntityType>
  <TimeStamp>2016-08-16T23:11:46.2517109Z</TimeStamp>
  <Duration>-1.00:00:00</Duration>
  <Key>0x2c322765603b5278</Key>
  <Signature>
    av/1fHoVZ0XejRwe+bdJJYFVWD8w3CDhQQG3Jvl/e05XiPQmGugz7+zNfPo6vvDze6zjsbSHMc8k
    06+r1uDhC6LuWqUe7LrnZXmvqFAnIAbw7r9eKyqNOyxkbpVqAj+xFqDAnkRWm8rrZrq0jM5kjhmn
    wqZ1frK/LA5KHTAer1dwgQ3S3WWkt0uWxCo93pZlTDZ8nhz7c1TTR03cUvNkQ+Kce+7BExuG3RB7
    hNmGeGtldBNTKrwSeHU9Es0gR5+RRZub2sAZpanND66uNyWQZLa7++qLNrbAwhOeRTxgmqliGjhN
    kHVKFKgMsbYmuR4YEWFaJeU/V/zKfiY1v+CbP3y0ftKeS6mO3eoAeELzJSTGQ8YD1BvdOyF3jL97
    pibYHVzW5rCxpc+b65axhqimwC+rNBFwSy0LSgbaLowd0k4K5HtPOqctYNT/ffyqKgLH1+Ef0urx
    CJOkXIssB5B7e1SzKCDobD+cnF3s8CyNGQ2+XPL1n0X5IWv3J8XGaVrKs6f/RljP20rjS2WtX8Nr
    GPauVB4rVwoeVckSirlRe6BAqmzu0YS/fjlk5wErpsSJJmtGB2E6SvctryrKk34KICO6gdPHsff7
    mSaRmSAOz9Fr2aMM5le7W1YlZW4tWfumS5LHZc2OlV7f++7oV6ca38J9fX211QwrU254Xg5WgKqg
    7T3wLaPl/zC5DwNjYYl8aVfHKUgeDo+89fC8SZGchDk167UKfaQ/h9qe+0xIplV2bpYBhuxW4stz
    ZYu/Byq+NFIvwACnVzbvXhlcJ639p11CfYyB4ewnDfGky0k1Xg/kSEM+MipTqJ92jQwIskKRP19k
    gC1Y9XTOMp75zAdzW9ObXZWJdU+sLcRHUOq1rCEtHXtKTxmVF/2qNRTLFeOk44Ar+pAbcmUYPo4j
    BOAA76tMi8P4cgBsOrRanoFK4BgaCwA3b9hxGjiN2so3o1+y9tg6eHOYkp7iRrxtDHSkL1yaAkp4
    6IH71p8ohr9nKxN2RhvWSE5pekYr0XlFJvJ7F2sGBt2DYMfhnRA3bXVv0fQ1NvJuKUsZrWm+ByMm
    3kZddXr/7Y3QscrRUp0nu3lmI3hN8ZWI5yfyBNScJNP2Cm86M2jotfybKLiJ6gbmEjrLsIHmGj4X
    BPVhTK78J6jcH9Q0uDEprRaNf6BUYI8AYOMhZ2qsQST0oObb5kNJC9IRA9Pn1oRC7GWxh+XYMJRi
    PDVTUkJykp7TSu0RA7ZgCX5cbvUPSy9Yyf6CMtCmqBem6hioB8ONTToIErAtR4r00krSX9YOQBmv
    Tam5TBg1vU/f4tepyyhLkMJKCQzpA3VMaz6jVIVbFq3OGf5oCidvknebKT2aks1nTp+w93leVA==
  </Signature>
</Certificate>







|


|



|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|


17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
    THE ASSOCIATED SOFTWARE MAY NOT WORK PROPERLY IF THIS FILE IS ALTERED.
-->
<Certificate xmlns="https://eagle.to/2011/harpy"
             xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
             xmlns:xsd="http://www.w3.org/2001/XMLSchema">
  <Protocol>None</Protocol>
  <Vendor>Mistachkin Systems</Vendor>
  <Id>2c09ab50-08d8-47a0-8d50-96529e4cf6fd</Id>
  <HashAlgorithm>SHA512</HashAlgorithm>
  <EntityType>Script</EntityType>
  <TimeStamp>2016-08-17T22:38:23.1247578Z</TimeStamp>
  <Duration>-1.00:00:00</Duration>
  <Key>0x2c322765603b5278</Key>
  <Signature>
    HGAwJrNRztqPPdvg2GOjxCYnrRvKg43cvC6XLAowps0rCe+mBJAdku3RaQ5u8mEIAyZJEoOlELso
    WiczSQIyjhxhqgY+gS9b6p7zL6njwmQoMbr00G0mVY053oSBk+9J7Urx8W2XmpEUFCIBsT/LSZgi
    nQUQANTZm/55u6U3x8bVbzvU+B1Pu2hfDGaBO/gx77UJQ5VQF3VyCihQ+7FU2A4P7ngBtmQOueE7
    mXkOXuA1kMmtK+T+WtO3tZgZK78EVIJH0W2SJr9Ffqv+alQgoXZkSV7VHXbUmS6Ey+UZIeKSdnzJ
    GVAGJ6tstKShaQcD/hpuUF0Q8SJfZgQQQUT7JBhtlOMLjzE4UB4GHW2t0334bifg93BSBeIkTe0P
    TnsKVRaXa8nzqAFm7jXWMvyri8XT7lvBHR57vfzv7pfwoLCRQMjBuYwtacyboVZKs01ZzTg4q6Oa
    S04vzk7/gKRSHbH3ymqOuRSlxrP60g8eeJXzeWWzx40j+7qO3coFse1ReJX+Nk4BVfAwmK+/4ua0
    5f769idwp7t4NlqUb87v0SYSwc1jzzg6jLd4nCExhXjj4oKVaLi7eHWomRoVoV7oGY1bB58zJiFu
    JkDVUAZwWsyDCRGOMhKyymJmSVtxnCp7ISywnjbagYSHC4LS/rGRaBkw6TBsMQVXxJiz+xK8zymV
    P96JDjTSULz4ZdveOyxUEVdgL3I6iCVTE7NnZ7BY21RNS2swKpS317EGX3nHnTA8U/bFjyvFohC0
    xmfllFePWuJpdOenbU9WTp66CPNNXFZOiPLzZ5/TwV9vRNJ0jGv0aVWJJqdBBeWJb22H2cQ8cQC9
    q4ZUn7dcI6aA47zzGur1duBX3O3yoMgt3X0dCjxfu1YqkjChFTCMKICkO9SLo3Lw74RDpykXlVH0
    BRo98TLofxiLBLyz3KxXxrA+sofBGCLcBMJy8H2NyAglP/8tdC/+EeCLRP0jGsK5AqCpmqUnk3T3
    MSaQoSnAFYfGVbVQWYqTayjfCKXIEBt2KiQaHzrOQfH62qQtVIN15wnjG/uD880WvEfKDkt3g+1G
    YYOjTl8T/1VxtmW+Dn1opxnwYbRttbJgzCFE8HC+0VXHyHREeah22QO1IGP6QyT2x0RdiY7oaWkD
    2CkRcRF3BywhU4JutYXGxodtRaGy5TUEd+GzRU6wTePBzd5HgNEi64vqzhDTOPCaEUsY5bbae4Yr
    Fn8vUZJ2pSuQVNeGnA23F0IPe4eXp3LRh/uVROrrVDhADSPBgbIJRLYMacblR43Sswke43V4Jfsn
    HZSYXOauejJmH8VRek5wH0dHK83EwGPP75uY1rS/+NLUx9NJT1gAfsOyFwfJbjZ/G2BxZGdWng==
  </Signature>
</Certificate>

Modified client/pkgr.eagle from [49ca3ae3fb] to [0f186f689f].

25
26
27
28
29
30
31




32
33
34
35
36






37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53





54
55
56
57
58
59





60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75






76
77
78
79
80
81
82
83
84
85






86
87
88
89
90
91
92
93
94
95





96
97
98
99
100
101
102
  #       package, even when it is being used by native Tcl.  If needed,
  #       prior to loading this package, the native Tcl auto-path should
  #       be modified to include the "Eagle1.0" directory (i.e. the one
  #       containing the Eagle core script library file "init.eagle").
  #
  package require Eagle.Library





  proc formatPackageName { package version } {
    return [string trim [appendArgs \
        $package " " [getLookupVersion $version]]]
  }







  proc formatResult { code result } {
    switch -exact -- $code {
      0 {set codeString ok}
      1 {set codeString error}
      2 {set codeString return}
      3 {set codeString break}
      4 {set codeString continue}
      default {set codeString [appendArgs unknown( $code )]}
    }

    if {[string length $result] > 0} then {
      return [appendArgs $codeString ": " [list $result]]
    } else {
      return $codeString
    }
  }






  proc pkgLog { string } {
    catch {
      tclLog [appendArgs [pid] " : " [clock seconds] " : pkgr : " $string]
    }
  }






  proc stringIsList { value } {
    if {[isEagle]} then {
      return [string is list $value]
    } else {
      global tcl_version

      if {[info exists tcl_version] && $tcl_version >= 8.5} then {
        return [string is list $value]
      } elseif {[catch {llength $value}] == 0} then {
        return true
      } else {
        return false
      }
    }
  }







  proc isHarpyCertificate { value } {
    if {[string length $value] == 0 || [string first [string trim {
      <Certificate xmlns="https://eagle.to/2011/harpy"
    }] $value] != -1} then {
      return true
    } else {
      return false
    }
  }







  proc isPgpSignature { value } {
    if {[string length $value] == 0 || [string first [string trim {
      -----BEGIN PGP SIGNATURE-----
    }] $value] != -1} then {
      return true
    } else {
      return false
    }
  }






  proc getFileTempName {} {
    if {[isEagle]} then {
      return [file tempname]
    } else {
      global env

      if {[info exists env(PKGR_TEMP)]} then {







>
>
>
>





>
>
>
>
>
>

















>
>
>
>
>






>
>
>
>
>
















>
>
>
>
>
>










>
>
>
>
>
>










>
>
>
>
>







25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
  #       package, even when it is being used by native Tcl.  If needed,
  #       prior to loading this package, the native Tcl auto-path should
  #       be modified to include the "Eagle1.0" directory (i.e. the one
  #       containing the Eagle core script library file "init.eagle").
  #
  package require Eagle.Library

  #
  # NOTE: This procedure returns a formatted, possibly version-specific,
  #       package name, for use in logging.
  #
  proc formatPackageName { package version } {
    return [string trim [appendArgs \
        $package " " [getLookupVersion $version]]]
  }

  #
  # NOTE: This procedure returns a formatted script result.  If the string
  #       result is empty, only the return code is used.  The code argument
  #       must be an integer Tcl return code (e.g. from [catch]) and the
  #       result argument is the script result or error message.
  #
  proc formatResult { code result } {
    switch -exact -- $code {
      0 {set codeString ok}
      1 {set codeString error}
      2 {set codeString return}
      3 {set codeString break}
      4 {set codeString continue}
      default {set codeString [appendArgs unknown( $code )]}
    }

    if {[string length $result] > 0} then {
      return [appendArgs $codeString ": " [list $result]]
    } else {
      return $codeString
    }
  }

  #
  # NOTE: This procedure emits a message to the package repository client
  #       log.  The string argument is the content of the message to emit.
  #
  # <public>
  proc pkgLog { string } {
    catch {
      tclLog [appendArgs [pid] " : " [clock seconds] " : pkgr : " $string]
    }
  }

  #
  # NOTE: This procedure attempts to determine if a string is a valid list
  #       and returns non-zero when that is true.  The value argument is
  #       the string to check.
  #
  proc stringIsList { value } {
    if {[isEagle]} then {
      return [string is list $value]
    } else {
      global tcl_version

      if {[info exists tcl_version] && $tcl_version >= 8.5} then {
        return [string is list $value]
      } elseif {[catch {llength $value}] == 0} then {
        return true
      } else {
        return false
      }
    }
  }

  #
  # NOTE: This procedure returns non-zero if the specified string value
  #       looks like a Harpy (script) certificate.  The value argument
  #       is the string to check.
  #
  # <public>
  proc isHarpyCertificate { value } {
    if {[string length $value] == 0 || [string first [string trim {
      <Certificate xmlns="https://eagle.to/2011/harpy"
    }] $value] != -1} then {
      return true
    } else {
      return false
    }
  }

  #
  # NOTE: This procedure returns non-zero if the specified string value
  #       looks like a PGP signature.  The value argument is the string
  #       to check.
  #
  # <public>
  proc isPgpSignature { value } {
    if {[string length $value] == 0 || [string first [string trim {
      -----BEGIN PGP SIGNATURE-----
    }] $value] != -1} then {
      return true
    } else {
      return false
    }
  }

  #
  # NOTE: This procedure returns a unique temporary file name.  A script
  #       error is raised if this task cannot be accomplished.  There are
  #       no arguments.
  #
  proc getFileTempName {} {
    if {[isEagle]} then {
      return [file tempname]
    } else {
      global env

      if {[info exists env(PKGR_TEMP)]} then {
120
121
122
123
124
125
126








127
128
129
130
131
132
133
        }

        incr counter
      }
    }
  }









  proc verifyPgpSignature { fileName } {
    variable pgpCommand

    if {[isEagle]} then {
      set fileName [appendArgs \" $fileName \"]

      if {[catch {







>
>
>
>
>
>
>
>







157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
        }

        incr counter
      }
    }
  }

  #
  # NOTE: This procedure attempts to verify the PGP signature contained in
  #       the specified (named) file.  Non-zero is only returned if the PGP
  #       signature is verified successfully.  A script error should not be
  #       raised by this procedure.  The fileName argument must be the fully
  #       qualified path and file name of the PGP signature file to verify.
  #
  # <public>
  proc verifyPgpSignature { fileName } {
    variable pgpCommand

    if {[isEagle]} then {
      set fileName [appendArgs \" $fileName \"]

      if {[catch {
142
143
144
145
146
147
148





149
150
151
152







153
154
155
156
157
158






159
160
161
162
163
164
165
        return true
      }
    }

    return false
  }






  proc getLookupVarNamePrefix {} {
    return ::pkgr_; # TODO: Make non-global?
  }








  proc getLookupVarNameSuffix {} {
    return [appendArgs \
        [string trim [pid] -] _ [string trim [clock seconds] -] _ \
        [string trim [clock clicks -milliseconds] -]]; # TODO: Bad?
  }







  proc getLookupApiKeys {} {
    set varName [appendArgs [getLookupVarNamePrefix] api_keys]

    if {[info exists $varName]} then {
      return [set $varName]
    }








>
>
>
>
>




>
>
>
>
>
>
>






>
>
>
>
>
>







187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
        return true
      }
    }

    return false
  }

  #
  # NOTE: This procedure returns the prefix for fully qualified variable
  #       names that MAY be present in the global namespace.  There are
  #       no arguments.
  #
  proc getLookupVarNamePrefix {} {
    return ::pkgr_; # TODO: Make non-global?
  }

  #
  # NOTE: This procedure returns a unique suffix for a fully qualified
  #       variable name that MAY be present in the global namespace.
  #       It is used (internally) to avoid any name collisions with
  #       variables and commands in the global namespace.  There are
  #       no arguments.
  #
  proc getLookupVarNameSuffix {} {
    return [appendArgs \
        [string trim [pid] -] _ [string trim [clock seconds] -] _ \
        [string trim [clock clicks -milliseconds] -]]; # TODO: Bad?
  }

  #
  # NOTE: This procedure returns the list of API keys to use when looking
  #       up packages via the package repository server.  An empty list
  #       is returned if no API keys are currently configured.  There are
  #       no arguments.
  #
  proc getLookupApiKeys {} {
    set varName [appendArgs [getLookupVarNamePrefix] api_keys]

    if {[info exists $varName]} then {
      return [set $varName]
    }

186
187
188
189
190
191
192










193
194
195
196
197
198
199
    if {[info exists env($varName)]} then {
      return $env($varName)
    }

    return https://urn.to/r/pkg; # NOTE: System default.
  }











  proc getLookupUri { apiKey package version } {
    set baseUri [getLookupBaseUri]

    if {[string length $baseUri] == 0} then {
      return ""
    }








>
>
>
>
>
>
>
>
>
>







249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
    if {[info exists env($varName)]} then {
      return $env($varName)
    }

    return https://urn.to/r/pkg; # NOTE: System default.
  }

  #
  # NOTE: This procedure returns the full URI to use when looking up a
  #       specific package via the package repository server.  The apiKey
  #       argument is the API key to use -OR- an empty string if a public
  #       package is being looked up.  The package argument is the name
  #       of the package being looked up, it cannot be an empty string.
  #       The version argument is the specific version being looked up
  #       -OR- an empty string for any available version.  No HTTP request
  #       is issued by this procedure; it just returns the URI to use.
  #
  proc getLookupUri { apiKey package version } {
    set baseUri [getLookupBaseUri]

    if {[string length $baseUri] == 0} then {
      return ""
    }

212
213
214
215
216
217
218








219
220
221
222
223
224
225
226







227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245










246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280





281
282
283
284
285
286
287
288





289
290
291
292
293
294
295
296





297
298
299
300
301
302
303
304








305
306
307
308
309
310
311

      return [appendArgs \
          $baseUri ? [http::formatQuery raw 1 method lookup apiKey $apiKey \
          package $package version $version]]
    }
  }









  proc getIfNeededVersion { package version } {
    if {[string length $version] > 0} then {
      return $version
    }

    return [lindex [package versions $package] 0]
  }








  proc getLookupVersion { requirement } {
    if {[set index [string first - $requirement]] != -1} then {
      incr index -1; set requirement [string range $requirement 0 $index]
    }

    if {[set index [string first a $requirement]] != -1 || \
        [set index [string first b $requirement]] != -1} then {
      incr index -1; set requirement [string range $requirement 0 $index]
    }

    if {$requirement eq "0"} then {
      set requirement ""
    } elseif {[regexp -- {^\d+$} $requirement]} then {
      append requirement .0
    }

    return $requirement
  }











  proc getLookupData { apiKey package version } {
    variable verboseUriDownload

    set uri [getLookupUri $apiKey $package $version]

    if {[string length $uri] == 0} then {
      return ""
    }

    if {$verboseUriDownload} then {
      pkgLog [appendArgs \
          "attempting to download URI \"" $uri \"...]
    }

    if {[isEagle]} then {
      set data [uri download -inline $uri]
    } else {
      variable quiet

      set data [getFileViaHttp $uri 10 stdout $quiet]
    }

    if {$verboseUriDownload} then {
      pkgLog [appendArgs \
          "raw response data is: " $data]
    }

    set data [string map [list &lt\; < &gt\; > &quot\; \" &amp\; &] $data]
    set data [string map [list \r\n \n \r \n] $data]
    set data [string map [list \n \r\n] $data]
    set data [string trim $data]

    return $data
  }






  proc getLookupCodeFromData { data } {
    if {![stringIsList $data] || [llength $data] < 1} then {
      return ""
    }

    return [lindex $data 0]
  }






  proc getLookupResultFromData { data } {
    if {![stringIsList $data] || [llength $data] < 2} then {
      return ""
    }

    return [lindex $data 1]
  }






  proc isLookupCodeOk { code } {
    #
    # NOTE: The code must be the literal string "OK" for the package lookup
    #       request to be considered successful.
    #
    return [expr {$code eq "OK"}]
  }









  proc extractAndVerifyLookupMetadata { result varName caller } {
    variable strictUnknownLanguage

    #
    # NOTE: Grab the language for the package script.  It must be an empty
    #       string, "Tcl", or "Eagle".  If it is an empty string, "Eagle"
    #       will be assumed.







>
>
>
>
>
>
>
>








>
>
>
>
>
>
>



















>
>
>
>
>
>
>
>
>
>

















<
|
















>
>
>
>
>








>
>
>
>
>








>
>
>
>
>








>
>
>
>
>
>
>
>







285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360

361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431

      return [appendArgs \
          $baseUri ? [http::formatQuery raw 1 method lookup apiKey $apiKey \
          package $package version $version]]
    }
  }

  #
  # NOTE: This procedure returns the version of the package that should be
  #       used to lookup the associated [package ifneeded] script -OR- an
  #       empty string if no such version exists.  The package argument is
  #       the name of the package, it cannot be an empty string.  The
  #       version argument is the specific version being looked up -OR- an
  #       empty string for any available version.
  #
  proc getIfNeededVersion { package version } {
    if {[string length $version] > 0} then {
      return $version
    }

    return [lindex [package versions $package] 0]
  }

  #
  # NOTE: This procedure accepts a package requirement (spec) and returns
  #       a simple package version, if possible.  An empty string will be
  #       returned, if appropriate (i.e. any version should be allowed).
  #       The requirement argument must be a package specification that
  #       conforms to TIP #268.
  #
  proc getLookupVersion { requirement } {
    if {[set index [string first - $requirement]] != -1} then {
      incr index -1; set requirement [string range $requirement 0 $index]
    }

    if {[set index [string first a $requirement]] != -1 || \
        [set index [string first b $requirement]] != -1} then {
      incr index -1; set requirement [string range $requirement 0 $index]
    }

    if {$requirement eq "0"} then {
      set requirement ""
    } elseif {[regexp -- {^\d+$} $requirement]} then {
      append requirement .0
    }

    return $requirement
  }

  #
  # NOTE: This procedure issues an HTTP request that should return metadata
  #       that can be used to load and/or provide the specified package.
  #       The apiKey argument is the API key to use -OR- an empty string if
  #       a public package is being looked up.  The package argument is the
  #       name of the package, it cannot be an empty string.  The version
  #       argument is the specific version being looked up -OR- an empty
  #       string for any available version.  This procedure may raise script
  #       errors.
  #
  proc getLookupData { apiKey package version } {
    variable verboseUriDownload

    set uri [getLookupUri $apiKey $package $version]

    if {[string length $uri] == 0} then {
      return ""
    }

    if {$verboseUriDownload} then {
      pkgLog [appendArgs \
          "attempting to download URI \"" $uri \"...]
    }

    if {[isEagle]} then {
      set data [uri download -inline $uri]
    } else {

      set quiet [expr {!$verboseUriDownload}]
      set data [getFileViaHttp $uri 10 stdout $quiet]
    }

    if {$verboseUriDownload} then {
      pkgLog [appendArgs \
          "raw response data is: " $data]
    }

    set data [string map [list &lt\; < &gt\; > &quot\; \" &amp\; &] $data]
    set data [string map [list \r\n \n \r \n] $data]
    set data [string map [list \n \r\n] $data]
    set data [string trim $data]

    return $data
  }

  #
  # NOTE: This procedure attempts to extract the lookup code from the raw
  #       HTTP response data.  The data argument is the raw HTTP response
  #       data.  An empty string is returned if no lookup code is available.
  #
  proc getLookupCodeFromData { data } {
    if {![stringIsList $data] || [llength $data] < 1} then {
      return ""
    }

    return [lindex $data 0]
  }

  #
  # NOTE: This procedure attempts to extract the lookup result from the raw
  #       HTTP response data.  The data argument is the raw HTTP response
  #       data.  An empty string is returned if no lookup result is available.
  #
  proc getLookupResultFromData { data } {
    if {![stringIsList $data] || [llength $data] < 2} then {
      return ""
    }

    return [lindex $data 1]
  }

  #
  # NOTE: This procedure returns non-zero if the specified lookup response
  #       code indicates success.  The code argument is the extracted HTTP
  #       lookup response code.
  #
  proc isLookupCodeOk { code } {
    #
    # NOTE: The code must be the literal string "OK" for the package lookup
    #       request to be considered successful.
    #
    return [expr {$code eq "OK"}]
  }

  #
  # NOTE: This procedure attempts to extract the package lookup metadata from
  #       the lookup result.  The result argument is the lookup result.  The
  #       varName argument is the name of an array variable, in the call frame
  #       of the immediate caller, that should receive the extracted package
  #       lookup metadata.  The caller argument must be an empty string -OR-
  #       the literal string "handler".
  #
  proc extractAndVerifyLookupMetadata { result varName caller } {
    variable strictUnknownLanguage

    #
    # NOTE: Grab the language for the package script.  It must be an empty
    #       string, "Tcl", or "Eagle".  If it is an empty string, "Eagle"
    #       will be assumed.
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374





375
376
377
378
379
380
381
382
383
384
385
386
387
388





389
390
391
392
393
394
395
396
397
398
399
400
401
402





403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
















419
420
421
422
423
424
425
        if {$language ne "Tcl"} then {
          error "repository package is not for Tcl"
        }
      }
    }

    #
    # NOTE: If the caller wants the package metadata, use their array
    #       variable name.
    #
    if {[string length $varName] > 0} then {
      upvar 1 $varName metadata

      set metadata(language) $language
      set metadata(script) $script
      set metadata(certificate) $certificate
    }
  }






  proc tclMustBeReady {} {
    #
    # NOTE: This procedure is not allowed to actually load a native Tcl
    #       library; therefore, one must already be loaded.
    #
    if {![isEagle]} then {
      error "already running in Tcl language"
    }

    if {![tcl ready]} then {
      error "cannot use Tcl language, supporting library is not loaded"
    }
  }






  proc eagleMustBeReady {} {
    #
    # NOTE: This procedure is not allowed to actually load Garuda (and
    #       Eagle); therefore, they must already be loaded.
    #
    if {[isEagle]} then {
      error "already running in Eagle language"
    }

    if {[llength [info commands eagle]] == 0} then {
      error "cannot use Eagle language, supporting package is not loaded"
    }
  }






  proc eagleHasSecurity {} {
    #
    # NOTE: If possible, check if the current interpreter has security
    #       enabled.
    #
    if {[isEagle] && [llength [info commands object]] > 0} then {
      if {[catch {
        object invoke -flags +NonPublic Interpreter.GetActive HasSecurity
      } security] == 0 && $security} then {
        return true
      }
    }

    return false
  }

















  proc processLookupMetadata { varName } {
    #
    # NOTE: If the metadata variable name appears to be invalid, fail.
    #
    if {[string length $varName] == 0} then {
      error "bad metadata"
    }







|
|










>
>
>
>
>














>
>
>
>
>














>
>
>
>
>
















>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>







476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
        if {$language ne "Tcl"} then {
          error "repository package is not for Tcl"
        }
      }
    }

    #
    # NOTE: If the caller wants the package lookup metadata, use their
    #       array variable name.
    #
    if {[string length $varName] > 0} then {
      upvar 1 $varName metadata

      set metadata(language) $language
      set metadata(script) $script
      set metadata(certificate) $certificate
    }
  }

  #
  # NOTE: This procedure, which may only be used from an Eagle script, checks
  #       if a native Tcl library is loaded and ready.  If not, a script error
  #       is raised.
  #
  proc tclMustBeReady {} {
    #
    # NOTE: This procedure is not allowed to actually load a native Tcl
    #       library; therefore, one must already be loaded.
    #
    if {![isEagle]} then {
      error "already running in Tcl language"
    }

    if {![tcl ready]} then {
      error "cannot use Tcl language, supporting library is not loaded"
    }
  }

  #
  # NOTE: This procedure, which may only be used from a native Tcl script,
  #       checks if Garuda and Eagle are loaded and ready.  If not, a script
  #       error is raised.
  #
  proc eagleMustBeReady {} {
    #
    # NOTE: This procedure is not allowed to actually load Garuda (and
    #       Eagle); therefore, they must already be loaded.
    #
    if {[isEagle]} then {
      error "already running in Eagle language"
    }

    if {[llength [info commands eagle]] == 0} then {
      error "cannot use Eagle language, supporting package is not loaded"
    }
  }

  #
  # NOTE: This procedure returns non-zero if the current script is being
  #       evaluated in Eagle with signed-only script security enabled.
  #       There are no arguments.
  #
  proc eagleHasSecurity {} {
    #
    # NOTE: If possible, check if the current interpreter has security
    #       enabled.
    #
    if {[isEagle] && [llength [info commands object]] > 0} then {
      if {[catch {
        object invoke -flags +NonPublic Interpreter.GetActive HasSecurity
      } security] == 0 && $security} then {
        return true
      }
    }

    return false
  }

  #
  # NOTE: This procedure uses the package lookup metadata.  If the package
  #       script is properly signed, an attempt will be made to evaluate it
  #       in the target language.  If the script was signed using PGP, then
  #       a conforming implementation of the OpenPGP specification (e.g.
  #       gpg2) must be installed locally.  If the script was signed using
  #       Harpy then Garuda, Eagle, and Harpy must be installed locally.
  #       This procedure is designed to work for both native Tcl and Eagle
  #       packages.  Additionally, it is designed to work when evaluated
  #       using either native Tcl or Eagle; however, it is up to the package
  #       script itself to either add the package or provide the package to
  #       the language(s) supported by that package.  The varName argument
  #       is the name of an array variable in the call frame of the
  #       immediate caller, that contains the package lookup metadata.  This
  #       procedure may raise script errors.
  #
  proc processLookupMetadata { varName } {
    #
    # NOTE: If the metadata variable name appears to be invalid, fail.
    #
    if {[string length $varName] == 0} then {
      error "bad metadata"
    }
736
737
738
739
740
741
742







743
744
745
746
747
748
749
        }
      }
    } else {
      error "unsupported script certificate"
    }
  }








  proc setupPackageUnknownHandler {} {
    variable autoHook
    variable autoLoadTcl
    variable autoRequireGaruda

    if {$autoRequireGaruda && ![isEagle]} then {
      #







>
>
>
>
>
>
>







887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
        }
      }
    } else {
      error "unsupported script certificate"
    }
  }

  #
  # NOTE: This procedure performs initial setup of the package repository
  #       client, using the current configuration parameters.  There are
  #       no arguments.  It may load the Garuda package when evaluated in
  #       native Tcl.  It may load a native Tcl library when evaluated in
  #       Eagle.  It may install the [package unknown] hook.
  #
  proc setupPackageUnknownHandler {} {
    variable autoHook
    variable autoLoadTcl
    variable autoRequireGaruda

    if {$autoRequireGaruda && ![isEagle]} then {
      #
766
767
768
769
770
771
772





773
774
775
776
777







778
779
780
781
782
783
784
785
786
787
788







789
790
791
792
793
794
795
796
797
798
799





800
801
802
803
804
805
806
807
808
809
810
811
812
813




814
815
816
817
818
819
820
821
822
823
      # NOTE: Install our [package unknown] handler and save the original
      #       one for our use as well.
      #
      hookPackageUnknownHandler
    }
  }






  proc isPackageUnknownHandlerHooked {} {
    return [info exists [appendArgs \
        [getLookupVarNamePrefix] saved_package_unknown]]
  }








  proc hookPackageUnknownHandler {} {
    set varName [appendArgs [getLookupVarNamePrefix] saved_package_unknown]

    if {[info exists $varName]} then {
      error "package unknown handler already hooked"
    }

    set $varName [package unknown]
    package unknown [appendArgs [namespace current] ::packageUnknownHandler]
  }








  proc unhookPackageUnknownHandler {} {
    set varName [appendArgs [getLookupVarNamePrefix] saved_package_unknown]

    if {![info exists $varName]} then {
      error "package unknown handler is not hooked"
    }

    package unknown [set $varName]
    unset $varName
  }






  proc runSavedPackageUnknownHandler { package version } {
    #
    # NOTE: See if there is a saved [package unknown] handler.  If so, then
    #       attempt to use it.
    #
    set varName [appendArgs [getLookupVarNamePrefix] saved_package_unknown]
    set oldHandler [expr {[info exists $varName] ? [set $varName] : ""}]

    if {[string length $oldHandler] > 0} then {
      lappend oldHandler $package $version; uplevel #0 $oldHandler
    }
  }

  #




  # NOTE: This version argument to this procedure must be optional, because
  #       Eagle does not add a version argument when one is not supplied to
  #       the [package require] sub-command itself.
  #
  proc packageUnknownHandler { package {version ""} } {
    variable verboseUnknownResult

    #
    # NOTE: First, run our [package unknown] handler.
    #







>
>
>
>
>





>
>
>
>
>
>
>











>
>
>
>
>
>
>











>
>
>
>
>














>
>
>
>
|
|
|







924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
      # NOTE: Install our [package unknown] handler and save the original
      #       one for our use as well.
      #
      hookPackageUnknownHandler
    }
  }

  #
  # NOTE: This procedure returns non-zero if the [package unknown] handler
  #       has already been hooked by the package repository client.  There
  #       are no arguments.
  #
  proc isPackageUnknownHandlerHooked {} {
    return [info exists [appendArgs \
        [getLookupVarNamePrefix] saved_package_unknown]]
  }

  #
  # NOTE: This procedure attempts to hook the [package unknown] handler.  It
  #       will raise a script error if this has already been done.  The old
  #       [package unknown] handler is saved and will be used by the new one
  #       as part of the overall package loading process.  There are no
  #       arguments.
  #
  proc hookPackageUnknownHandler {} {
    set varName [appendArgs [getLookupVarNamePrefix] saved_package_unknown]

    if {[info exists $varName]} then {
      error "package unknown handler already hooked"
    }

    set $varName [package unknown]
    package unknown [appendArgs [namespace current] ::packageUnknownHandler]
  }

  #
  # NOTE: This procedure attempts to unhook the [package unknown] handler.
  #       It will raise a script error if the [package unknown] handler is
  #       not hooked.  The old [package unknown] handler is restored and
  #       the saved [package unknown] handler is cleared.  There are no
  #       arguments.
  #
  proc unhookPackageUnknownHandler {} {
    set varName [appendArgs [getLookupVarNamePrefix] saved_package_unknown]

    if {![info exists $varName]} then {
      error "package unknown handler is not hooked"
    }

    package unknown [set $varName]
    unset $varName
  }

  #
  # NOTE: The procedure runs the saved [package unknown] handler.  Any script
  #       errors are raised to the caller.  The package and version arguments
  #       are passed in from the current [package unknown] handler verbatim.
  #
  proc runSavedPackageUnknownHandler { package version } {
    #
    # NOTE: See if there is a saved [package unknown] handler.  If so, then
    #       attempt to use it.
    #
    set varName [appendArgs [getLookupVarNamePrefix] saved_package_unknown]
    set oldHandler [expr {[info exists $varName] ? [set $varName] : ""}]

    if {[string length $oldHandler] > 0} then {
      lappend oldHandler $package $version; uplevel #0 $oldHandler
    }
  }

  #
  # NOTE: This procedure is the [package unknown] handler entry point called
  #       by native Tcl and Eagle.  The package argument is the name of the
  #       package being sought, it cannot be an empty string.  The version
  #       argument must be a specific version -OR- a package specification
  #       that conforms to TIP #268.  This version argument must be optional
  #       here, because Eagle does not add a version argument when one is
  #       not explicitly supplied to the [package require] sub-command.
  #
  proc packageUnknownHandler { package {version ""} } {
    variable verboseUnknownResult

    #
    # NOTE: First, run our [package unknown] handler.
    #
879
880
881
882
883
884
885







886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
        pkgLog [appendArgs \
            "package \"" [formatPackageName $package $version] \
            "\" was not loaded"]
      }
    }
  }








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

    set fileName [appendArgs \
        [file rootname $script] .settings [file extension $script]]

    if {[file exists $fileName] && [file isfile $fileName]} then {
      uplevel 1 [list source $fileName]
    }
  }

  proc setupPackageUnknownVars {} {
    #
    # NOTE: Prevent progress messages from being displayed while downloading
    #       from the repository, etc?  By default, this is enabled.
    #
    variable quiet; # DEFAULT: true

    if {![info exists quiet]} then {
      set quiet true
    }

    #
    # NOTE: Automatically install our [package unknown] handler when this
    #       package is loaded?
    #
    variable autoHook; # DEFAULT: true

    if {![info exists autoHook]} then {







>
>
>
>
>
>
>














<
|
|
|
|
<
|
<
<
<
|







1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092

1093
1094
1095
1096

1097



1098
1099
1100
1101
1102
1103
1104
1105
        pkgLog [appendArgs \
            "package \"" [formatPackageName $package $version] \
            "\" was not loaded"]
      }
    }
  }

  #
  # 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.
  #
  proc maybeReadSettingsFile { script } {
    if {[string length $script] == 0 || \
        ![file exists $script] || ![file isfile $script]} then {
      return
    }

    set fileName [appendArgs \
        [file rootname $script] .settings [file extension $script]]

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

  #
  # NOTE: This procedure sets up the default values for all configuration
  #       parameters used by the package repository client.  There are no
  #       arguments.

  #



  proc setupPackageUnknownVars {} {
    #
    # NOTE: Automatically install our [package unknown] handler when this
    #       package is loaded?
    #
    variable autoHook; # DEFAULT: true

    if {![info exists autoHook]} then {
974
975
976
977
978
979
980










981
982
983
984
985
986
987
    variable verboseUriDownload; # DEFAULT: false

    if {![info exists verboseUriDownload]} then {
      set verboseUriDownload false
    }
  }











  proc main { package version caller } {
    #
    # NOTE: Get the list of API keys and try each one, in order, until
    #       the package is found.
    #
    set apiKeys [getLookupApiKeys]; lappend apiKeys ""








>
>
>
>
>
>
>
>
>
>







1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
    variable verboseUriDownload; # DEFAULT: false

    if {![info exists verboseUriDownload]} then {
      set verboseUriDownload false
    }
  }

  #
  # NOTE: This procedure is the primary entry point to the package repository
  #       client.  It attempts to lookup the specified package using the
  #       currently configured package repository server.  The package
  #       argument is the name of the package being sought, it cannot be an
  #       empty string.  The version argument must be a specific version -OR-
  #       a package specification that conforms to TIP #268.  The caller
  #       argument must be an empty string -OR- the literal string "handler".
  #
  # <public>
  proc main { package version caller } {
    #
    # NOTE: Get the list of API keys and try each one, in order, until
    #       the package is found.
    #
    set apiKeys [getLookupApiKeys]; lappend apiKeys ""

1048
1049
1050
1051
1052
1053
1054
1055







1056
1057






1058
1059
1060
1061
1062
1063
1064
1065
1066

1067
1068


1069
1070
1071
1072
1073




1074

1075






1076
1077
1078
1079
1080
1081
1082

  if {![isEagle]} then {
    ###########################################################################
    ############################# BEGIN Tcl ONLY ##############################
    ###########################################################################

    #
    # NOTE: This procedure was stolen from the "getEagle.tcl" script.







    #
    proc pageProgress { channel type milliseconds } {






      #
      # NOTE: Show that something is happening...
      #
      catch {puts -nonewline $channel $type; flush $channel}

      #
      # NOTE: Make sure that we are scheduled to run again.
      #
      if {$milliseconds > 0} then {

        after $milliseconds [namespace code [list pageProgress \
            $channel $type $milliseconds]]


      }
    }

    #
    # NOTE: This procedure was stolen from the "getEagle.tcl" script.




    #

    proc getFileViaHttp { uri redirectLimit channel quiet args } {






      #
      # NOTE: This procedure requires the modern version of the HTTP package,
      #       which is typically included with the Tcl core distribution.
      #
      package require http 2.0

      #







|
>
>
>
>
>
>
>


>
>
>
>
>
>






|


>
|
|
>
>




|
>
>
>
>

>

>
>
>
>
>
>







1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307

  if {![isEagle]} then {
    ###########################################################################
    ############################# BEGIN Tcl ONLY ##############################
    ###########################################################################

    #
    # NOTE: This procedure was stolen from the "getEagle.tcl" script.  It is
    #       designed to emit a progress indicator while an HTTP request is
    #       being processed.  The channel argument is the Tcl channel where
    #       the progress indicator should be emitted.  The type argument is
    #       the single-character progress indicator.  The milliseconds
    #       argument is the number of milliseconds to wait until the next
    #       periodic progress indicator should be emitted.  This procedure
    #       reschedules its own execution.
    #
    proc pageProgress { channel type milliseconds } {
      #
      # NOTE: This variable is used to keep track of the currently scheduled
      #       (i.e. pending) [after] event.
      #
      variable afterForPageProgress

      #
      # NOTE: Show that something is happening...
      #
      catch {puts -nonewline $channel $type; flush $channel}

      #
      # NOTE: Make sure that we are scheduled to run again, if requested.
      #
      if {$milliseconds > 0} then {
        set afterForPageProgress [after $milliseconds \
            [namespace code [list pageProgress $channel $type \
            $milliseconds]]]
      } else {
        unset afterForPageProgress
      }
    }

    #
    # NOTE: This procedure was stolen from the "getEagle.tcl" script.  It is
    #       designed to process a single HTTP request, including any HTTP
    #       3XX redirects (up to the specified limit), and return the raw
    #       HTTP response data.  It does not contain special code to handle
    #       HTTP status codes other than 3XX (e.g. 4XX, 5XX, etc).
    #
    # <public>
    proc getFileViaHttp { uri redirectLimit channel quiet args } {
      #
      # NOTE: This variable is used to keep track of the currently scheduled
      #       (i.e. pending) [after] event.
      #
      variable afterForPageProgress

      #
      # NOTE: This procedure requires the modern version of the HTTP package,
      #       which is typically included with the Tcl core distribution.
      #
      package require http 2.0

      #
1202
1203
1204
1205
1206
1207
1208







1209
1210
1211
1212
1213
1214
1215
            #       kind of supported HTTP redirect.
            #
            set data [::http::data $token]
            ::http::cleanup $token; break
          }
        }
      }








      #
      # NOTE: If progress messages were emitted, start a fresh line.
      #
      if {!$quiet} then {
        catch {puts $channel [appendArgs " " $uri]; flush $channel}
      }







>
>
>
>
>
>
>







1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
            #       kind of supported HTTP redirect.
            #
            set data [::http::data $token]
            ::http::cleanup $token; break
          }
        }
      }

      #
      # NOTE: If there is a currently scheduled [after] event, cancel it.
      #
      if {[info exists afterForPageProgress]} then {
        catch {after cancel $afterForPageProgress}
      }

      #
      # NOTE: If progress messages were emitted, start a fresh line.
      #
      if {!$quiet} then {
        catch {puts $channel [appendArgs " " $uri]; flush $channel}
      }

Modified client/pkgr.eagle.harpy from [b8ccecd809] to [441ed8c9f9].

17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
    THE ASSOCIATED SOFTWARE MAY NOT WORK PROPERLY IF THIS FILE IS ALTERED.
-->
<Certificate xmlns="https://eagle.to/2011/harpy"
             xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
             xmlns:xsd="http://www.w3.org/2001/XMLSchema">
  <Protocol>None</Protocol>
  <Vendor>Mistachkin Systems</Vendor>
  <Id>3568d473-0bb6-4f90-be5f-8b450f8736d7</Id>
  <HashAlgorithm>SHA512</HashAlgorithm>
  <EntityType>Script</EntityType>
  <TimeStamp>2016-08-17T20:05:49.0964375Z</TimeStamp>
  <Duration>-1.00:00:00</Duration>
  <Key>0x2c322765603b5278</Key>
  <Signature>
    TVMgx73LgFs+3POFC1tl9D6GVCZg53ZMgqyzX0tMumKTEpUbgrGxcsj/OcZh2SO2yjobOwTSJrFT
    /pwycJOhF9cayu+4If5inkIfOz2chA1ACbAdYcF01u+RWu58dPsfGT9GKL+U5C3E2CLPZxF10opg
    DtiOlKEQW1hy5IUhLmDXmCcmkpeMJr38xYum+k3l7ngEkmLfE09XwngtZ2LV5XaJ8OT/qMQ2J583
    mges2JAoseNFuLDsR2gyJIqauUgitb+eX0E0uy2l7eeY8AvaOaG2540Yd7tWbss5DRayKYClpny0
    22xELBK5jknhYYoZGt3AtgTzB1aZlw6+qPfJu9+syHzMRgUrzWdpqoKyOv/0agafYraQnNXQvsrW
    ASIEG68rZgdXdQlwnoDpRFzJWb491Y+v+37f8kxzw5xma8logvBCUg4uIKsRrhQz/kJ22PSyQL4H
    0IhBWTyH5Vf5q5wlVFrYNdf+1X62oWK0tpOL80mIQBLQKAEQReaMZh0wQ6XZZXECF8H6Br0qmWEA
    JVmXluQPVWD1dBtgVnyXBCo9on3MTpZQw5ieM7gErpuSmzl2kXv2pBNCilExIobfENazVjxRAT2S
    UYEziWbFduTS7YGB2kwrXnLXGU8jC0gWyKl+b/3OBceE6cPwiTIUUxKkiIUJpwiKopBe1YIV4fPD
    /eOJ1zx25W/nk0C8tNEnz84tfmZZr+QAiT+O8Va2Mdkzb+Pjuy3Lw2div21gnNgzFddI04zxshJj
    Ndo6IjGpPptJPGpcJN6oC7Tp+FT2mg2uxgXtyfxJENPyHCL83isS5jW/xsGHplhyZ0Y2CA4nO3aF
    Qh9Q1vGF5nVWP6Qoi1IuL9F7jUvlujLjDvBKxcPs4ZEnNIMvF6fdGoPeK1x2jf8HsrJwC7+KJ7tn
    k6WhUMDP6s9cFRN0an4O2OssZp9C4+PDINqs4c90kiaR2drUy3xhQyVm0vwThvhcnnSVYlkcjHC7
    Z9sgtm59xqBtRvxybmvwcCDDdAMaQlSK03/UvUnmLHfe3UBFqzhzHJ22IcK0g1ZVO/+71yxAG3tW
    jz0iH1LiM7PQ40qcqoBZ5ESq1i8Kg3oP4NpGau7d/SwV4PdYRp9QaRSoLKICde+c5pL+PeFot3SJ
    4BdiP7K25b+TLUcrnnzCfn+qT1pYHlIum8w/siL/BZmiXCjivQiAG03aiKY63yj91yZuar5C5SZ6
    MwiGCubxtQz2sBEnd29UrYgA3/a3+973onXg+I9NrzOWXqkXvpomw5Kual5nNHPd7Or4DF6sGvjX
    hzk/+vByL47b1z7nlEu+/usKf3KSAo369izsy21XCEdLLFYVFxJiCXhapu4cSqHJ2FxiojfYhQ==
  </Signature>
</Certificate>







|


|



|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|


17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
    THE ASSOCIATED SOFTWARE MAY NOT WORK PROPERLY IF THIS FILE IS ALTERED.
-->
<Certificate xmlns="https://eagle.to/2011/harpy"
             xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
             xmlns:xsd="http://www.w3.org/2001/XMLSchema">
  <Protocol>None</Protocol>
  <Vendor>Mistachkin Systems</Vendor>
  <Id>46bd3e67-77bb-4fa4-a28a-7c83625d9f52</Id>
  <HashAlgorithm>SHA512</HashAlgorithm>
  <EntityType>Script</EntityType>
  <TimeStamp>2016-08-17T22:22:41.5866719Z</TimeStamp>
  <Duration>-1.00:00:00</Duration>
  <Key>0x2c322765603b5278</Key>
  <Signature>
    kiflSRFIfVS0IVzQik8SIGNV/yYXrO2DU2W2+1ASqsGuQSN5oh2Cct7xJGmlXla7WveaqcgzrcmX
    zGhZ1V/YV5sehvJO7066ov2199BgjIIce3YnU9/miVxcULdl2dun5KdzMMFI0WoSvpeOnGWiWE1x
    RUlCPG5DM+Z3WGuwC5GCK9PeXMMGMs5rrxFqh27lAyhvvt0Ehcls1aIv/tT1aTrfGT0945X3SA9u
    dp9U/zx+AAO4juihAlGNBbGOTShFzDXO9X6qmWH1Ld0PGweccpgdlW95uPftA4tA0cobtW6sYm9n
    uGdcQZTzVgtYrk2KmOHqI5iNFqrNyjkLxUD2fnvfUZeUVchxz8yP0RnUGoEpirQCozqg9Ms7zKsm
    CBlsJCPI1RMLMETJVE773JZaSgc6jbzOD7LOlMOWspDwhYv6w9jR3nXkEyECkixzMaJAS0JtW2sw
    vnQiKeFLnSnnQMeAmmkXexiBAZSDgcElXa8rO3rC0PplKp6hNHCQ6q25fZjW4ihKewA7a64dijr9
    0Zzlaf/4iuTg+0us796aFshMwAo3sxUgGP6jHTTxPyJ2IV2nW2WQ9XzzYKoOZylMJG45fO5NZAGQ
    2PISU49fbnBgxyGT8GqTl5gB/86qrU/wLyEfdX8p/IFYmD7EHM1A11LxTw+CAvozdV3QyojklRfP
    lgHFPNQSux3FXIiJudXOmxte0GA7wTXzaNMcaAR6ei7I9wSH5j5nrr5c4vlrvANMa5TDbjJ9py5K
    m0ebc4U/3meNJD1UPjcRwN5XW6G/yya+Vv+hnFgAKvE79H6dQqZ7f0/6wnvp/qMeQByP2Gl2cZ5H
    sr1rIJax8h7280YMb9rl8N8w7zZRNyWjMP1E8LIVwaBcBDRnbNjOSwAzOkLJB8QhzsYYc/kFhAPq
    nKZ/9ffkQmvmrDnbMFQNDAFGKcI0gDzHrnXPNE/KQZ5B+qaEaQM4OpyLgpr4G9ojUmz0k7A+Fql3
    eeHblQSXnwy0OH/Ctme7wNfHoF7hedi7rGYyqrDq/xMRuOQisi6bysl1qQkPl9Fjn9lmqop59gTL
    z8Er6nAgBCKK+lAqUiTd/dd27tKtj9eyObfhmlfZA2hnyIlPol5kfyiYnZ4GCUBK1qOV0t7SGpAG
    sBuSQ3IzArokA98HqsUdYTsyCMUgqyARj9WSjFOtpmaYRMQ1P0ICFpO2+s2x82bj34Fc+UhPwtTZ
    2TgWDvGNJ1/buq9F84p8vW5IVKuQt0OpWYo0mBBwax62dhZb0UkfmqieD3IBsORezSxKXL0O6by7
    DsOGtwaymJ84LTj5RC7HcKTGUXS/2CArSpiu7Fec3+rjlM3V4YsK9fGmDd6mSHCfjFYUbHk8Eg==
  </Signature>
</Certificate>

Modified client/pkgr.settings.eagle from [1984c373bb] to [7cd0c55238].

10
11
12
13
14
15
16



17
18
19
# See the file "license.terms" for information on usage and redistribution of
# this file, and for a DISCLAIMER OF ALL WARRANTIES.
#
# RCS: @(#) $Id: $
#
###############################################################################




variable strictUnknownLanguage false
variable verboseUnknownResult true
variable verboseUriDownload true







>
>
>



10
11
12
13
14
15
16
17
18
19
20
21
22
# See the file "license.terms" for information on usage and redistribution of
# this file, and for a DISCLAIMER OF ALL WARRANTIES.
#
# RCS: @(#) $Id: $
#
###############################################################################

# TODO: Set this to your list of API keys.
# set ::pkgr_api_keys [list 0000000000000000000000000000000000000000]

variable strictUnknownLanguage false
variable verboseUnknownResult true
variable verboseUriDownload true

Modified client/pkgr.settings.eagle.harpy from [a9632ba307] to [1a274d21f0].

17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
    THE ASSOCIATED SOFTWARE MAY NOT WORK PROPERLY IF THIS FILE IS ALTERED.
-->
<Certificate xmlns="https://eagle.to/2011/harpy"
             xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
             xmlns:xsd="http://www.w3.org/2001/XMLSchema">
  <Protocol>None</Protocol>
  <Vendor>Mistachkin Systems</Vendor>
  <Id>32fce62e-9899-4d81-b1d8-2fac61bb26fb</Id>
  <HashAlgorithm>SHA512</HashAlgorithm>
  <EntityType>Script</EntityType>
  <TimeStamp>2016-08-17T19:24:49.1950703Z</TimeStamp>
  <Duration>-1.00:00:00</Duration>
  <Key>0x2c322765603b5278</Key>
  <Signature>
    Y39+6r8dzwDCn6Ze2DrONO0bDIzV2h+QXR2QlUN7iA5UK0PvN3TjvvhHhJOSxcEAuxthZySu2dkP
    bieKV0gFN51x2Q9bJajyzKVJW1L79b8DdTE0jTX/Lr3R92w3DZVX6bi8nZreuKhN37PEJ1IkQhVw
    /2YqRDFOAH6vC5ig7ujOsL74jaUTiyA6dBz7WFuu4IUDcSnkMJxnf50DuH0U40/1BICc525HFrA+
    U6OhoYEthUl/fUzZ9xXBc76hfTkdkgF+r8C1JNPuX6Gz5EcBLu1SEWumszq7zTnN5Rk1/rf6KJb5
    3XXGyqncpOK8chlJdGW13ck929P/lJxzjM2GvwzTlSEQeKZXIET67P3al8U0yTLeQlgG/DGKz8WO
    06Iktkp4FQPvOIFB07Po6ADZw8MNK/A3sTei2md9RVVJzWrMY34S3BfMHYhDUQQUzGRF4OjLhuWU
    giyNTXIvqa0Kx+JBnQ4uQP0Z7lhoLM+0rI1yDYFVfpKERud+KDDfBqoxfTVMIdJw1NX9uVe23SLK
    vw0FPHRF+bDjM2AhLxF4APG3pmPW6fJAkTJaLoKq38JoAleVeKyGa4ygdSkMqmI+Q8PSlqlhxL87
    pB9g0N9Ffq/UuZbeXycdw3VeBEEhtAAgozm22Gxhjc0HIywnBLWyF+PhKOoNJFLw3L4BfaSQmnSu
    yWTXZhHWvUU6dyyWORLqpwwo94AHxGmMUqIZrp1EhC2Zmb4wouw0RUjEbbjBwkFYC38w0kikrzhZ
    i/+CG9XC6HoCQM0FUu+28zvm+CNP7W+b8YfxV/k8HH4HehY3w/xwYYWGC3uSwKhg4rofvct8tFmL
    PfMsWjRkefmi5YJMXaaUva/WyUmU6s3NbgcTxMgH2TwACHCLvhLTjufuUsoew3o6uYvsThOEam4Y
    YpZ3/ssOlwduavNYqhjfFVOtp531LGzikNOAwcnQ7tb8NbMmN0JD/GsAPUrpgQK+F3enWI/X9pmf
    LN4ZRseSiIMJA4DvQYQ1NAw2q/WrrVNWYCpRjEhfB3AsXJB9OXZvlvA2+UnA5SDuaTGyb9R7N1sg
    BRYfGccH2NcH6fjghLNlhXIgAQiHPHLw8xAMXaqxC5VL6D3srSiELztXcSN2yQoj1FURDGJcQ0Po
    NZINy+XLrHHeGY3GW7jZNEXk+lHIWJv1oiKGsvxSxeQ9dLPgn8NyVomlM7SOunUfTfNaCVMZJ1jH
    Z4dc17ubAEQfMR7B0wBuuTnbzgtc/3m21dqN9uXovD/bYPqszZGoye23q7ArhI0Axtz0yb+R7/7f
    AL1ypFUQG/JTxceySoL0j1RwxlBsbUuNk92yUkt5dymUATV7LkTHBIyyt/JIxbTTyJGJ4uving==
  </Signature>
</Certificate>







|


|



|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|


17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
    THE ASSOCIATED SOFTWARE MAY NOT WORK PROPERLY IF THIS FILE IS ALTERED.
-->
<Certificate xmlns="https://eagle.to/2011/harpy"
             xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
             xmlns:xsd="http://www.w3.org/2001/XMLSchema">
  <Protocol>None</Protocol>
  <Vendor>Mistachkin Systems</Vendor>
  <Id>b44b4ef2-76ad-4786-b4b7-e1d604e15e8b</Id>
  <HashAlgorithm>SHA512</HashAlgorithm>
  <EntityType>Script</EntityType>
  <TimeStamp>2016-08-17T22:22:56.6608906Z</TimeStamp>
  <Duration>-1.00:00:00</Duration>
  <Key>0x2c322765603b5278</Key>
  <Signature>
    efFtWFrnFkJeMBafjl1MxA1lygnogjoQHoS8qP4ptK+GuB7mvyJbSgtjYyUVJ0Nj9W88qJ0eGtQ3
    5yd2fZrTX7nXmEkXaRFcSBiB/S6dtUrc6GGDO1PlOB7w3JGfSkh/4MgfRTrZyN+sRN6ODWPjFU4s
    m1+HXSXynBUKyPaJ8qNd/0foXvNC/rGbHyZ+Z4FkbAfYZZSTiIz57kv9ZvlmxjSoZNffYpOGD0kQ
    mFXkvDkoM4JxE3b19M/VFcKJ6NIn7o6Vqc3Xt40+9W5OTKjLVfpeV8gK01rU1d9+KuBnC3hQWyqZ
    V0fF2mkyGnxO0LAZpOiQ82b8Myld/vl79iGcMLb9F5+SdnYeqBrT8VFRaiZz12MS+8BP+3JItBqn
    WNFjKVWFXG5SI6aTaqbTDtiKRADqoJyb6HN5imfZll2tcK2ruICy4zYo79mDAolBEnwp4TnNcwKA
    h5oQTnc44dQht8xeZdT5Ah2SNRBx0GA3nHmJO9AP68JMYbPWLABQQ6hZf2b6u6zB3ZzU8RN/+NIa
    3Y5jfKVD/f2BCJumU1jWh2R4785SNXfFT5Id5U0II9I9WhTdiylFXP3hiN/dNW0GAWq9v6TLG+pi
    vfJrr/26RQfEwIiNa8keQkfJ/HgTmille05ct7DycbHu9Edq9NxWgfTtWDsAnlERTG+WhRc5hZyc
    VegPWnHpoXeUHgEe5d4bkmmRfePnH+eWeibRveMErlv16jeTv4H28ftp3Vq8n0n+hkVHpYOHMV6i
    J3/RhJ4G1Se/adEPdVUQRfYrP5HwI/szeR5DQoZ+zAsB34cfwWn0hsj21FeqitSE/rQ0j8pcD3yy
    OIH07uf/sOqQ8hSEFnxVPTvQYp9H7QTBxFAxaMbpIUTpB6DyroPWzi4uSa+JXWSkf5sQOo2SLCoX
    t3w7tpZ6o2FZNd3O519FiX3+cM78vyfIMkbT4ZFEHpFkccuG6g9nVgUDCTgMwNldSKQAC7JtwjOZ
    tSQ9YjRTgZSGcJ+TjLnXJfWo8u0SM+J3K9o+zRcN+6zDZsCAo6inrxgICEFN+lTabJxyWas6MYeX
    hkq7CnGT9nsDtynLniiF4FUsKTVlgHfR1ZVPwWGb0Ow/L4PdPMTlzPVttsE4bcrii6xnf85O9ijU
    zfgBhDtRsst9TLXb514J8t4zT54AQPLav2DjXjDjChbm+/JF8ywAfq/v8/A0B3PIeDPgmRTouH48
    0MFanzDYI3r75OC0ZMuS8EoseqkcC2C3IvJY9ZtsgnuIPbpxzsdooCCaHXUWL2mHZ+QOk8Q+jn7J
    1V0BeUNi0hU9SZeAai1co8ehsCw3vUkOPUoYginn2ry5ALf/jEBHW+1CX3+jlT/snSZba0GPDg==
  </Signature>
</Certificate>