143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
|
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
|
-
+
-
-
+
+
-
+
|
}
}
return false
}
proc getLookupVarNamePrefix {} {
return ::rpkg_; # TODO: Make non-global?
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 getLookupApiKey {} {
set varName [appendArgs [getLookupVarNamePrefix] api_key]
proc getLookupApiKeys {} {
set varName [appendArgs [getLookupVarNamePrefix] api_keys]
if {[info exists $varName]} then {
return [set $varName]
}
global env
set varName [string trim $varName :]
if {[info exists env($varName)]} then {
return $env($varName)
}
return ""; # NOTE: System default, which is "public".
return [list]; # NOTE: System default, which is "public-only".
}
proc getLookupBaseUri {} {
set varName [appendArgs [getLookupVarNamePrefix] base_uri]
if {[info exists $varName]} then {
return [set $varName]
|
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
|
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
|
+
+
+
+
+
+
+
|
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]
|
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
|
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
|
-
+
-
+
|
#
# NOTE: Create common cleanup script block that deletes any temporary
# files created for the script verification process.
#
set script(cleanup) {
if {[string length $fileName(2)] > 0 && \
[file exists $fileName(2)]} then {
if {![info exists ::env(rpkg_keep_files)]} then {
if {![info exists ::env(pkgr_keep_files)]} then {
catch {file delete $fileName(2)}
}
unset -nocomplain fileName(2)
}
if {[string length $fileName(1)] > 0 && \
[file exists $fileName(1)]} then {
if {![info exists ::env(rpkg_keep_files)]} then {
if {![info exists ::env(pkgr_keep_files)]} then {
catch {file delete $fileName(1)}
}
unset -nocomplain fileName(1)
}
}
#
|
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
|
922
923
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
|
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
-
-
+
+
+
+
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
|
# is called?
#
variable verboseUnknownResult; # DEFAULT: false
if {![info exists verboseUnknownResult]} then {
set verboseUnknownResult false
}
}
#
# NOTE: Emit diagnostic messages when a URI is fetched?
#
variable verboseUriDownload; # DEFAULT: false
if {![info exists verboseUriDownload]} then {
set verboseUriDownload true
}
}
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 ""
foreach apiKey $apiKeys {
#
# NOTE: Issue the lookup request to the remote package repository.
#
set data [getLookupData \
[getLookupApiKey] $package [getLookupVersion $version]]
# NOTE: Issue the lookup request to the remote package repository.
#
set data [getLookupData \
$apiKey $package [getLookupVersion $version]]
#
# NOTE: Attempt to grab the lookup code from the response data.
#
set code [getLookupCodeFromData $data]
#
# NOTE: Attempt to grab the lookup code from the response data.
#
set code [getLookupCodeFromData $data]
#
# NOTE: Did the lookup operation fail?
#
if {[isLookupCodeOk $code]} then {
break
}
}
#
# NOTE: Attempt to grab the lookup data from the response data.
# Upon failure, this should contain the error message.
#
set result [getLookupResultFromData $data]
|