︙ | | |
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
140
141
142
143
144
145
146
147
148
149
150
151
152
153
|
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
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
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
|
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
+
+
-
+
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
+
+
+
+
+
+
+
-
+
+
-
-
+
+
|
return $value
} else {
return $list
}
}
#
# NOTE: This procedure counts the common path components for two paths. The
# count is returned, zero if there are no common path components. The
# path1 and path2 arguments are the paths to compare. This procedure
# may not raise script errors.
#
proc countCommonPathParts { path1 path2 } {
set parts1 [file split $path1]
set length1 [llength $parts1]
set parts2 [file split $path2]
set length2 [llength $parts2]
set length [expr {min($length1, $length2)}]
for {set index 0} {$index < $length} {incr index} {
set part1 [lindex $parts1 $index]
set part2 [lindex $parts2 $index]
if {$part1 ne $part2} then {
return $index
}
}
return $length
}
#
# NOTE: This procedure processes a list of qualified file names and tries
# to determine their common containing directory, if any. The
# NOTE: This procedure processes a list of (fully?) qualified file names and
# tries to determine their common containing directory, if any. The
# fileNames argument is the list of (fully?) qualified file names to
# process.
# process. This procedure may not raise script errors. If there is
# no common containing directory, an empty string is returned.
#
proc getContainingDirectory { fileNames } {
set result ""
set resultParts [list]
foreach fileName $fileNames {
set directory [file dirname $fileName]
set directoryParts [file split $directory]
if {[llength $resultParts] == 0 || \
[llength $directoryParts] < [llength $resultParts]} then {
set result $directory
set resultParts $directoryParts
} elseif {[llength $directoryParts] == [llength $resultParts] && \
$directory ne $result} then {
set result [file dirname $directory]
set resultParts [file split $result]
proc getCommonContainingDirectory { fileNames } {
set length [llength $fileNames]
if {$length == 0} then {
return ""
}
set oldFileName [lindex $fileNames 0]
if {$length == 1} then {
return [file dirname $oldFileName]
}
set minimumCount 0
for {set index 1} {$index < $length} {incr index} {
set newFileName [lindex $fileNames $index]
set newCount [countCommonPathParts $oldFileName $newFileName]
if {$newCount == 0} then {
return ""
}
if {$minimumCount == 0 || $newCount < $minimumCount} then {
set oldFileName $newFileName
set minimumCount $newCount
}
}
if {$minimumCount == 0} then {
return $result
return ""
}
incr minimumCount -1
return [eval file join [lrange [file split $oldFileName] 0 $minimumCount]]
}
#
# NOTE: This procedure attempts to process a list of (fully?) qualified file
# names and return the corresponding list of relative file names. The
# fileNames argument is the list of (fully?) qualified file names to
# process. The maximumLevels argument is the maximum path depth that
# process. This procedure may raise script errors.
# is allowed for all file names. This procedure may raise script
# errors.
#
proc getRelativeFileNames { fileNames } {
set directory [getContainingDirectory $fileNames]
proc getRelativeFileNames { fileNames maximumLevels } {
set directory [getCommonContainingDirectory $fileNames]
set directoryParts [file split $directory]
set fileNameIndex [expr {[llength $directoryParts] - 1}]
if {$fileNameIndex < 0} then {
error [appendArgs \
"invalid containing directory \"" $directory \
"\": cannot go up one level"]
|
︙ | | |
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
|
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
|
-
-
+
+
-
+
|
}
#
# NOTE: This procedure attempts to create a script chunk that appends the
# specified list of file names to a list variable. The fileNames
# argument is the list of (fully?) qualified file names to append to
# the list variable. The maximumLevels argument is the maximum path
# depth allowed for all file names. This procedure may raise script
# errors.
# depth that is allowed for all file names. This procedure may raise
# script errors.
#
proc getScriptChunkForFileNames { fileNames maximumLevels } {
set result ""
set relativeFileNames [getRelativeFileNames $fileNames]
set relativeFileNames [getRelativeFileNames $fileNames $maximumLevels]
foreach relativeFileName $relativeFileNames {
if {[string length $result] > 0} then {
append result \n
}
append result { lappend fileNames [file join }
|
︙ | | |
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
|
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
|
+
-
-
+
-
|
# empty string -OR- one of the literal strings "neutral", "win32-arm",
# "win32-x86", "win64-arm64", "win64-ia64", or "win64-x64". The
# fileNames argument is the list of (fully?) qualified file names to
# be downloaded when the associated package is being provided. The
# options argument is reserved for future use, it should be an empty
# list.
#
# <public>
proc createRepositoryScript { language version platform fileNames options } {
::PackageDownloader::verifyLanguageAndVersion $language $version isClient
::PackageDownloader::verifyPlatform $platform platform
return [string trim [string map [list \r\n \n \
%language% [formatStringMapValue $language] \
%version% [formatStringMapValue $version] \
%platform% [formatStringMapValue $platform] \
%backslash% \\ %ns% ::PackageDownloader %fileNames% \
[getScriptChunkForFileNames \
[getScriptChunkForFileNames $fileNames 2]] {
$fileNames 2]] {
apply [list [list] {
package require Eagle.Package.Downloader
%ns%::resetCookieAndLoginSimple
set fileNames [list]
|
︙ | | |
250
251
252
253
254
255
256
257
258
259
260
261
262
263
|
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
|
+
|
}
#
# NOTE: This procedure attempts to stage the specified package files using
# Fossil. The fileNames argument is a list of (fully?) qualified
# local file names to stage.
#
# <public>
proc stagePackageFiles { language version platform fileNames } {
variable checkoutDirectory
variable fossilAddCommand
set relativeFileNames [getRelativeFileNames $fileNames]
set savedPwd [pwd]; cd $checkoutDirectory
|
︙ | | |
296
297
298
299
300
301
302
303
304
305
306
307
308
309
|
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
|
+
|
#
# NOTE: This procedure attempts to commit the staged package files to the
# remote package file repository using Fossil. The varName argument
# is the name of a scalar variable in the context of the immediate
# caller that will receive the resulting Fossil check-in identifier.
#
# <public>
proc commitPackageFiles { varName } {
variable checkoutDirectory
variable fossilCommitCommand
variable fossilCommitPattern
set branch ""; # TODO: Figure out a good branch.
set comment ""; # TODO: Figure out a good comment.
|
︙ | | |