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 {
|