Diff
Not logged in

Differences From Artifact [d48f797d43]:

To Artifact [e00eecc8fc]:


64
65
66
67
68
69
70
71

72
73
74












75
76
77
78
79
80
81
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







-
+

-
-
+
+
+
+
+
+
+
+
+
+
+
+







    if {![info exists downloadUri]} then {
      set downloadUri {${baseUri}?download&ci=trunk&filename=${fileName}}
    }

    #
    # NOTE: The root directory where any persistent packages will be saved.
    #
    variable persistentDirectory; # DEFAULT: [getPersistentRootDirectory]
    variable persistentRootDirectory; # DEFAULT: [getPersistentRootDirectory]

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

    #
    # NOTE: The root directory where any temporary packages will be written.
    #
    variable temporaryRootDirectory; # DEFAULT: [getFileTempDirectory PKGD_TEMP]

    if {![info exists temporaryRootDirectory]} then {
      set temporaryRootDirectory \
          [::PackageRepository::getFileTempDirectory PKGD_TEMP]
    }
  }

  #
  # 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.
94
95
96
97
98
99
100
101

102
103
104
105
106
107
108
104
105
106
107
108
109
110

111
112
113
114
115
116
117
118







-
+







  #       the file to check, which may or may not exist.
  #
  proc isPgpSignatureFileName { fileName } {
    if {[string length $fileName] == 0} then {
      return false
    }

    set extension [file extension]
    set extension [file extension $fileName]

    if {$extension eq ".asc"} then {
      if {[file exists $fileName]} then {
        return [::PackageRepository::isPgpSignature [readFile $fileName]]
      } else {
        return true
      }
117
118
119
120
121
122
123
124

125
126
127
128
129
130
131
127
128
129
130
131
132
133

134
135
136
137
138
139
140
141







-
+







  #       of the file to check, which may or may not exist.
  #
  proc isHarpyCertificateFileName { fileName } {
    if {[string length $fileName] == 0} then {
      return false
    }

    set extension [file extension]
    set extension [file extension $fileName]

    if {$extension eq ".harpy"} then {
      if {[file exists $fileName]} then {
        return [::PackageRepository::isHarpyCertificate [readFile $fileName]]
      } else {
        return true
      }
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
229
230
231
232
233
234
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







-
-
+
+




+
+
+
+








-
+
+



-
+
+







  #
  proc downloadOneFile { language version fileName localFileName usePgp } {
    variable baseUri
    variable downloadUri
    variable quiet

    #
    # NOTE: First, build the full relative file name to download from the
    #       remote package repository.
    # NOTE: First, build the full relative file name to download from
    #       the remote package repository.
    #
    set fileName [file join $language $version $fileName]
    set uri [subst $downloadUri]

    #
    # NOTE: Then, in one step, download the file from the package file
    #       server and write it to the specified local file.
    #
    if {[isEagle]} then {
      writeFile $localFileName [interp readorgetscriptfile -- "" $uri]
    } else {
      writeFile $localFileName \
          [::PackageRepository::getFileViaHttp $uri 10 stdout $quiet]
    }

    #
    #
    # NOTE: Is use of OpenPGP for signature verification enabled?  Also,
    #       did we just download an OpenPGP signature file?
    #
    if {$usePgp && [isPgpSignatureFileName $localFileName]} then {
      #
      #
      # NOTE: Attempt to verify the OpenPGP signature.  If this fails,
      #       an error is raised.
      #
      if {![::PackageRepository::verifyPgpSignature $localFileName]} then {
        error [appendArgs \
            "bad PGP signature \"" $localFileName \"]
      }
    }
  }
250
251
252
253
254
255
256
257
258
259
260
261
262


263
264
265
266
267
268
269
266
267
268
269
270
271
272


273



274
275
276
277
278
279
280
281
282







-
-

-
-
-
+
+







  #       useAutoPath argument should be non-zero to modify the auto-path
  #       to include the temporary or persistent directories containing
  #       the downloaded files.
  #
  # <public>
  proc downloadFiles {
          language version fileNames persistent usePgp useAutoPath } {
    global env
    variable baseUri
    variable clientDirectory
    variable downloadUri
    variable persistentDirectory
    variable quiet
    variable persistentRootDirectory
    variable temporaryRootDirectory

    set client false

    if {[string length $language] == 0 || $language eq "eagle"} then {
      if {$version ne "1.0"} then {
        error "unsupported Eagle version"
      }
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
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
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







-
-
-
-
-
-
-
-
-
-




-
-
-
-
-
+
+
+
+
-
-
-


















-
+


-
-
+
+

+
+

-
+








-


-
+
+

-
+
-



-
+
+
+






+
+

-
+
+

+

+
+
+

+

-
+







      }

      set client true
    } else {
      error "unsupported language"
    }

    if {[info exists env(PKGD_TEMP)]} then {
      set temporaryRootDirectory $env(PKGD_TEMP)
    } elseif {[info exists env(TEMP)]} then {
      set temporaryRootDirectory $env(TEMP)
    } elseif {[info exists env(TMP)]} then {
      set temporaryRootDirectory $env(TMP)
    } else {
      error "please set PKGD_TEMP (via environment) to temporary directory"
    }

    set temporaryDirectory [file join $temporaryRootDirectory \
        [appendArgs pkgd_ [string trim [pid] -] _ [string trim \
        [clock seconds] -]]]

    if {$persistent} then {
      if {$client} then {
        set downloadRootDirectory $clientDirectory
      } else {
        set downloadRootDirectory $persistentDirectory
    if {$client} then {
      set persistentDirectory $clientDirectory
    } else {
      set persistentDirectory $persistentRootDirectory
      }
    } else {
      set downloadRootDirectory $temporaryDirectory
    }

    set downloadedFileNames [list]

    foreach fileName $fileNames {
      if {[string length $fileName] == 0 || \
          [file pathtype $fileName] ne "relative"} then {
        error [appendArgs \
            "bad file name \"" $fileName "\", not relative"]
      }

      set directoryParts [file split [file dirname $fileName]]

      if {[llength $directoryParts] == 0} then {
        error [appendArgs \
            "bad file name \"" $fileName "\", no directory parts"]
      }

      set downloadDirectory(temporary) [file normalize [eval \
      set directory(temporary) [file normalize [eval \
          file join [list $temporaryDirectory] $directoryParts]]

      set downloadDirectory(persistent) [file normalize [eval \
          file join [list $downloadRootDirectory] $directoryParts]]
      set directory(persistent) [file normalize [eval \
          file join [list $persistentDirectory] $directoryParts]]

      set fileNameOnly [file tail $fileName]

      set downloadFileName [file normalize [file join \
          $downloadDirectory(temporary) [file tail $fileName]]]
          $directory(temporary) $fileNameOnly]]

      if {[file exists $downloadFileName]} then {
        error [appendArgs \
            "temporary file name \"" $downloadFileName \
            "\" already exists"]
      }

      file mkdir [file dirname $downloadFileName]

      downloadOneFile $language $version $fileName $downloadFileName $usePgp

      lappend downloadedFileNames $downloadFileName
      lappend downloadedFileNames [list \
          $fileNameOnly $directory(temporary) $directory(persistent)]

      if {$usePgp && ![isPgpSignatureFileName $downloadFileName] && \
      if {$usePgp && ![isPgpSignatureFileName $downloadFileName]} then {
          ![isHarpyCertificateFileName $downloadFileName]} then {
        downloadOneFile $language $version [appendArgs $fileName .asc] \
            [appendArgs $downloadFileName .asc] $usePgp

        lappend downloadedFileNames [appendArgs $downloadFileName .asc]
        lappend downloadedFileNames [list \
            [appendArgs $fileNameOnly .asc] $directory(temporary) \
            $directory(persistent)]
      }
    }

    set downloadDirectories [list]

    foreach downloadedFileName $downloadedFileNames {
      set directory(temporary) [lindex $downloadedFileName 1]

      if {$persistent} then {

        set fileNameOnly [lindex $downloadedFileName 0]
        set directory(persistent) [lindex $downloadedFileName 2]

        file mkdir $directory(persistent)

        file copy -- \
            [file join $directory(temporary) $fileNameOnly] \
            [file join $directory(persistent) $fileNameOnly]

        lappend downloadDirectories $directory(persistent)
      } else {
        lappend downloadDirectories [file dirname $downloadedFileName]
        lappend downloadDirectories $directory(temporary)
      }
    }

    set downloadDirectories [lsort -unique $downloadDirectories]

    if {$useAutoPath} then {
      foreach downloadDirectory $downloadDirectories {