Check-in [b868c01046]
Not logged in
Overview
Comment:Rename the package 'IfNeeded' piece of metadata to simply 'Script', since it may or may not actually be a real 'package ifneeded' script.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: b868c010468ae1fbf691971661dc6f94441c18d2
User & Date: mistachkin on 2016-08-17 20:06:54
Other Links: manifest | tags
Context
2016-08-17
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
19:32
Fix multi-pass 'package unknown' integration in native Tcl. check-in: cdb1e4e5a3 user: mistachkin tags: trunk
Changes

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

317
318
319
320
321
322
323
324

325
326
327


328
329
330
331
332
333
334
317
318
319
320
321
322
323

324
325


326
327
328
329
330
331
332
333
334







-
+

-
-
+
+







    }

    #
    # NOTE: Grab the package script.  If it is an empty string, then the
    #       package cannot be loaded and there is nothing to do.  In that
    #       case, just raise an error.
    #
    set ifNeeded [getDictionaryValue $result IfNeeded]
    set script [getDictionaryValue $result Script]

    if {[string length $ifNeeded] == 0} then {
      error "missing ifneeded script"
    if {[string length $script] == 0} then {
      error "missing script"
    }

    #
    # NOTE: Grab the package script certificate.  If it is an empty string
    #       then the package script is unsigned, which is not allowed by
    #       this client.  In that case, just raise an error.
    #
363
364
365
366
367
368
369
370

371
372
373
374
375
376
377
363
364
365
366
367
368
369

370
371
372
373
374
375
376
377







-
+







    # 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(ifNeeded) $ifNeeded
      set metadata(script) $script
      set metadata(certificate) $certificate
    }
  }

  proc tclMustBeReady {} {
    #
    # NOTE: This procedure is not allowed to actually load a native Tcl
443
444
445
446
447
448
449
450
451


452
453
454
455
456
457
458
443
444
445
446
447
448
449


450
451
452
453
454
455
456
457
458







-
-
+
+







    if {![info exists metadata(language)]} then {
      error "missing language"
    }

    #
    # NOTE: If the package script is mising, fail.
    #
    if {![info exists metadata(ifNeeded)]} then {
      error "missing ifneeded script"
    if {![info exists metadata(script)]} then {
      error "missing script"
    }

    #
    # NOTE: If the package script certificate is mising, fail.
    #
    if {![info exists metadata(certificate)]} then {
      error "missing script certificate"
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
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







-
+


-
+




















-
+







      #
      set script(outer) [string map [list \
          %metadata% $newVarName(1) %cleanup% $newVarName(2) \
          %eagleHasSecurity% $newProcName(1) %getFileTempName% \
          $newProcName(2) %tclMustBeReady% $newProcName(3)] {
        try {
          #
          # NOTE: If there is no package ifneeded script, there is nothing we
          # NOTE: If there is no package script, there is nothing we
          #       can do here.
          #
          if {[string length ${%metadata%(ifNeeded)}] > 0} then {
          if {[string length ${%metadata%(script)}] > 0} then {
            #
            # NOTE: Save the security state for the interpreter.  Then, attempt
            #       to enable it.  This will fail if one of the needed plugins
            #       cannot be loaded.
            #
            set savedSecurity [{%eagleHasSecurity%}]
            if {!$savedSecurity} then {source enableSecurity}

            try {
              #
              # NOTE: Figure out temporary file name for the downloaded script
              #       and its associated script certificate.
              #
              set fileName(1) [{%getFileTempName%}]
              set fileName(2) [appendArgs $fileName(1) .harpy]

              try {
                #
                # NOTE: Write downloaded script to a temporary file.
                #
                writeFile $fileName(1) ${%metadata%(ifNeeded)}
                writeFile $fileName(1) ${%metadata%(script)}

                #
                # NOTE: Write downloaded script certificate to a temporary
                #       file.
                #
                if {[string length ${%metadata%(certificate)}] > 0} then {
                  writeFile $fileName(2) ${%metadata%(certificate)}
648
649
650
651
652
653
654
655

656
657
658

659
660
661
662
663
664
665
666
667
668
669

670
671
672
673
674
675
676
648
649
650
651
652
653
654

655
656
657

658
659
660
661
662
663
664
665
666
667
668

669
670
671
672
673
674
675
676







-
+


-
+










-
+







        eagle [list proc $newProcName(3) {} [info body [appendArgs \
            [namespace current] ::tclMustBeReady]]]

        return [eagle $script(outer)]
      }
    } elseif {[isPgpSignature $metadata(certificate)]} then {
      #
      # NOTE: If there is no package ifneeded script, there is nothing we
      # NOTE: If there is no package script, there is nothing we
      #       can do here.
      #
      if {[string length $metadata(ifNeeded)] > 0} then {
      if {[string length $metadata(script)] > 0} then {
        #
        # NOTE: Figure out temporary file name for the downloaded script
        #       and its associated PGP signature.
        #
        set fileName(1) [getFileTempName]
        set fileName(2) [appendArgs $fileName(1) .asc]

        #
        # NOTE: Write downloaded script to a temporary file.
        #
        writeFile $fileName(1) $metadata(ifNeeded)
        writeFile $fileName(1) $metadata(script)

        #
        # NOTE: Write downloaded script PGP signature a temporary file.
        #
        if {[string length $metadata(certificate)] > 0} then {
          writeFile $fileName(2) $metadata(certificate)
        }
698
699
700
701
702
703
704
705

706
707
708
709
710
711
712
698
699
700
701
702
703
704

705
706
707
708
709
710
711
712







-
+







          error "bad PGP signature"
        }

        #
        # NOTE: The PGP signature was verified; use the downloaded package
        #       script verbatim.
        #
        set script(inner) $metadata(ifNeeded)
        set script(inner) $metadata(script)

        #
        # NOTE: Determine the target language for the package script, which
        #       may or may not be the language that is currently evaluating
        #       this script (Eagle).  The default language, when one was not
        #       explicitly specified, is Eagle.  In the future, this may be
        #       changed, e.g. to use the file extension of the client script.
870
871
872
873
874
875
876
877

878
879
880
881

882
883
884
885
886
887
888
870
871
872
873
874
875
876

877
878
879
880

881
882
883
884
885
886
887
888







-
+



-
+








      set command [list package present $package]
      if {[string length $version] > 0} then {lappend command $version}

      if {[catch $command] == 0} then {
        pkgLog [appendArgs \
            "package \"" [formatPackageName $package $version] \
            "\" was loaded."]
            "\" was loaded"]
      } else {
        pkgLog [appendArgs \
            "package \"" [formatPackageName $package $version] \
            "\" was not loaded."]
            "\" was not loaded"]
      }
    }
  }

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

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

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
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>78255941-0cb7-4f55-8dd9-abe50e72170a</Id>
  <Id>3568d473-0bb6-4f90-be5f-8b450f8736d7</Id>
  <HashAlgorithm>SHA512</HashAlgorithm>
  <EntityType>Script</EntityType>
  <TimeStamp>2016-08-17T19:22:59.0896016Z</TimeStamp>
  <TimeStamp>2016-08-17T20:05:49.0964375Z</TimeStamp>
  <Duration>-1.00:00:00</Duration>
  <Key>0x2c322765603b5278</Key>
  <Signature>
    AO5Ui99nCZseAfy2JXw9WN3RIbruAfskm9wJGLYlCjDoqCrCVLh6MHEvpMaLgGPjEGxJkkTjD8EV
    XUtZrmVIGYClw0wwyUkFTMAAu+QHAe0UU0E1+QQ791zsb6jN0VX1ttLqlRWsP1BS+CerNd9HceAF
    tHQNphNrveIKvW4dZBQO1AYfYMUT6c5P/Zjix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s9cFRN0an4O2OssZp9C4+PDINqs4c90kiaR2drUy3xhQyVm0vwThvhcnnSVYlkcjHC7
    Z9sgtm59xqBtRvxybmvwcCDDdAMaQlSK03/UvUnmLHfe3UBFqzhzHJ22IcK0g1ZVO/+71yxAG3tW
    jz0iH1LiM7PQ40qcqoBZ5ESq1i8Kg3oP4NpGau7d/SwV4PdYRp9QaRSoLKICde+c5pL+PeFot3SJ
    4BdiP7K25b+TLUcrnnzCfn+qT1pYHlIum8w/siL/BZmiXCjivQiAG03aiKY63yj91yZuar5C5SZ6
    MwiGCubxtQz2sBEnd29UrYgA3/a3+973onXg+I9NrzOWXqkXvpomw5Kual5nNHPd7Or4DF6sGvjX
    hzk/+vByL47b1z7nlEu+/usKf3KSAo369izsy21XCEdLLFYVFxJiCXhapu4cSqHJ2FxiojfYhQ==
  </Signature>
</Certificate>