Changes On Branch 3982962147646498
Not logged in

Changes In Branch pending Through [3982962147] Excluding Merge-Ins

This is equivalent to a diff from b2ec485564 to 3982962147

2020-03-27
20:58
Various fixes related to package version checking and OpenPGP integration. check-in: 1ba61d8533 user: mistachkin tags: trunk
2020-03-25
17:14
By default, prevent the 'getPackageFile' procedure from returning the content of a Fossil error page. check-in: 778b91ce22 user: mistachkin tags: pending
2020-03-24
23:46
More fixes to the 'probeForOpenPgpInstallation' procedure. check-in: 3982962147 user: mistachkin tags: pending
23:23
The 'probeForOpenPgpInstallation' procedure should check all names in 'openPgpFileNamesOnly'. Also, the 'probeForOpenPgpInstallation' procedure should recognize the new directory layout used by Windows GPG installations. The 'setupRepositoryOpenPgpVars' procedure should honor its 'force' argument. check-in: 071382dcf8 user: mistachkin tags: pending
2019-12-02
22:06
Fix typos in the Harpy 'sign' tool. check-in: b2ec485564 user: mistachkin tags: trunk
2019-11-06
16:08
Regenerate the documentation. check-in: 2fa0ad12f0 user: mistachkin tags: trunk

Modified client/1.0/neutral/pkgr.eagle from [8f2d9374a1] to [dd293526a1].

415
416
417
418
419
420
421
422
423


424
425
426
427
428
429

430
431
432
433

434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449








450
451

452
453
454
455


456
457
458










459
460
461
462
463
464
465
415
416
417
418
419
420
421


422
423
424
425
426
427
428

429
430
431
432

433
434
435
436
437
438
439
440
441
442
443
444





445
446
447
448
449
450
451
452
453

454




455
456
457


458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474







-
-
+
+





-
+



-
+











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

-
+
-
-
-
-
+
+

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







  #       OpenPGP installation directory was successfully detected and added
  #       to the PATH -OR- detecting and adding it was not necessary because
  #       it already appeared to be available for use.
  #
  # <internal>
  proc probeForOpenPgpInstallation {} {
    global env
    variable openPgpFileNameOnly
    variable openPgpInstalledDirectory
    variable openPgpFileNamesOnly
    variable openPgpInstalledDirectories

    if {[catch {openPgpMustBeInstalled}] == 0} then {
      return true
    }

    if {![info exists openPgpFileNameOnly]} then {
    if {![info exists openPgpFileNamesOnly]} then {
      return false
    }

    if {![info exists openPgpInstalledDirectory]} then {
    if {![info exists openPgpInstalledDirectories]} then {
      return false
    }

    if {[isWindows]} then {
      if {[info exists env(ProgramFiles(x86))]} then {
        set programFiles $env(ProgramFiles\(x86\))
      } elseif {[info exists env(ProgramFiles)]} then {
        set programFiles $env(ProgramFiles)
      } else {
        return false
      }

      set directory [file join $programFiles $openPgpInstalledDirectory]
    } else {
      set directory $openPgpInstalledDirectory
    }
    }

    foreach directory $openPgpInstalledDirectories {
      if {[isWindows]} then {
        set subDirectory [file join $programFiles $directory]
      } else {
        set subDirectory $directory
      }

    if {![file isdirectory $directory]} then {
      if {[file isdirectory $subDirectory]} then {
      return false
    }

    set fileName [file join $directory $openPgpFileNameOnly]
        foreach fileNameOnly $openPgpFileNamesOnly {
          set fileName [file join $subDirectory $fileNameOnly]

    if {[file exists $fileName] && [file isfile $fileName]} then {
      return [addToPath $directory]
          if {[file exists $fileName] && [file isfile $fileName]} then {
            pkgLog [appendArgs \
                "the OpenPGP directory is being initialized to \"" \
                $subDirectory "\" based on OpenPGP file name \"" \
                $fileNameOnly \"]

            return [addToPath $subDirectory]
          }
        }
      }
    }

    return false
  }

  #
  # NOTE: This procedure attempts to verify that a configured implementation
483
484
485
486
487
488
489
490

491
492
493
494
495
496
497
492
493
494
495
496
497
498

499
500
501
502
503
504
505
506







-
+








      Alternatively, it may be possible to install GNU Privacy Guard (GPG) via
      the package management subsystem included with your operating system.
    }

    set found false

    foreach fileName $openPgpFileNamesOnly {
    foreach fileNameOnly $openPgpFileNamesOnly {
      if {[isEagle]} then {
        if {[catch {
          eval exec -success Success [subst $openPgpInstalledCommand]
        } result] == 0} then {
          set found true; break
        }
      } else {
509
510
511
512
513
514
515
516

517
518
519

520
521

522
523
524
525
526
527




528

529
530
531
532
533
534
535
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







-
+


-
+

-
+






+
+
+
+
-
+







      #       viable OpenPGP file name?
      #
      if {[info exists openPgpFileNameOnly]} then {
        #
        # NOTE: If the OpenPGP file name that we found before (?) does not
        #       match what we already have, issue a log message.
        #
        if {$fileName ne $openPgpFileNameOnly} then {
        if {$fileNameOnly ne $openPgpFileNameOnly} then {
          pkgLog [appendArgs \
              "the OpenPGP file name is being changed from \"" \
              $openPgpFileNameOnly "\" to \"" $fileName \"]
              $openPgpFileNameOnly "\" to \"" $fileNameOnly \"]

          set openPgpFileNameOnly $fileName
          set openPgpFileNameOnly $fileNameOnly
        }
      } else {
        #
        # NOTE: Configure the OpenPGP file name to the one that was just
        #       found.
        #
        pkgLog [appendArgs \
            "the OpenPGP file name is being initialized to \"" \
            $fileNameOnly \"]

        set openPgpFileNameOnly $fileName
        set openPgpFileNameOnly $fileNameOnly
      }
    } else {
      #
      # NOTE: If no viable OpenPGP file name was found, raise the error
      #       message.
      #
      error $message
2296
2297
2298
2299
2300
2301
2302
2303

2304
2305

2306
2307


2308
2309


2310
2311
2312
2313
2314
2315
2316
2317
2318
2319
2320

2321
2322
2323
2324
2325
2326
2327
2328
2329
2330
2331
2332
2333
2334
2335
2336
2337
2338
2339
2340
2341

2342
2343
2344
2345
2346
2347
2348
2349
2350
2351
2352
2353

2354
2355
2356
2357
2358
2359
2360
2361
2362
2363
2364
2365


2366
2367
2368
2369
2370
2371
2372
2373
2374
2375

2376
2377
2378
2379
2380
2381
2382
2383
2384
2385
2386

2387
2388
2389
2390
2391
2392
2393
2394
2395
2396
2397
2398

2399
2400
2401
2402
2403
2404
2405
2309
2310
2311
2312
2313
2314
2315

2316
2317

2318
2319

2320
2321
2322

2323
2324
2325
2326
2327
2328
2329
2330
2331
2332
2333
2334

2335
2336
2337
2338
2339
2340
2341
2342
2343
2344
2345
2346
2347
2348
2349
2350
2351
2352
2353
2354
2355

2356
2357
2358
2359
2360
2361
2362
2363
2364
2365
2366
2367

2368
2369
2370
2371
2372
2373
2374
2375
2376
2377
2378


2379
2380
2381
2382
2383
2384
2385
2386
2387
2388
2389

2390
2391
2392
2393
2394
2395
2396
2397
2398
2399
2400

2401
2402
2403
2404
2405
2406
2407
2408
2409
2410
2411
2412

2413
2414
2415
2416
2417
2418
2419
2420







-
+

-
+

-
+
+

-
+
+










-
+




















-
+











-
+










-
-
+
+









-
+










-
+











-
+







  #
  proc setupRepositoryOpenPgpVars { force } {
    #
    # NOTE: This is the name of the sub-directory containing the OpenPGP
    #       implementation.  It is platform-specific.  On Windows, this
    #       sub-directory is relative to the "Program Files" directory.
    #
    variable openPgpInstalledDirectory; # DEFAULT: [file join GNU GnuPG]
    variable openPgpInstalledDirectories; # DEFAULT: [list ...]

    if {![info exists openPgpInstalledDirectory]} then {
    if {$force || ![info exists openPgpInstalledDirectories]} then {
      if {[isWindows]} then {
        set openPgpInstalledDirectory [file join GNU GnuPG]
        set openPgpInstalledDirectories [list \
            [file join gnupg bin] [file join GNU GnuPG]]
      } else {
        set openPgpInstalledDirectory [file join / usr bin]
        set openPgpInstalledDirectories [list \
            [file join / usr bin]]
      }
    }

    #
    # NOTE: These are the candidate names of the executable file used to
    #       invoke the OpenPGP implementation, possibly without a file
    #       extension.
    #
    variable openPgpFileNamesOnly; # DEFAULT: [list gpg2 gpg]

    if {![info exists openPgpFileNamesOnly]} then {
    if {$force || ![info exists openPgpFileNamesOnly]} then {
      if {[isWindows]} then {
        set openPgpFileNamesOnly [list gpg2.exe gpg.exe]
      } else {
        set openPgpFileNamesOnly [list gpg2 gpg]
      }
    }

    #
    # NOTE: This is the name of the executable file used to invoke the
    #       OpenPGP implementation, possibly without a file extension.
    #
    variable openPgpFileNameOnly; # DEFAULT: <unset>

    #
    # NOTE: The command to use when attempting to import an OpenPGP key
    #       file.  This must be configured according to the implementation
    #       of OpenPGP in use.
    #
    variable openPgpImportCommand; # DEFAULT: gpg2 --import

    if {![info exists openPgpImportCommand]} then {
    if {$force || ![info exists openPgpImportCommand]} then {
      set openPgpImportCommand \
          {{${openPgpFileNameOnly}} --import {${fileName}}}
    }

    #
    # NOTE: The regular expression pattern used when attempting to verify
    #       that OpenPGP successfully imported one or more keys.  This must
    #       be configured according to the implementation of OpenPGP in use.
    #
    variable openPgpImportPattern; # DEFAULT: ^gpg: Total number processed...

    if {![info exists openPgpImportPattern]} then {
    if {$force || ![info exists openPgpImportPattern]} then {
      set openPgpImportPattern {^gpg: Total number processed: [1-9]\d*$}
    }

    #
    # NOTE: The command to use when attempting to verify that OpenPGP is
    #       installed locally.  This must be configured according to the
    #       implementation of OpenPGP in use.
    #
    variable openPgpInstalledCommand; # DEFAULT: gpg2 --version --homedir {}

    if {![info exists openPgpInstalledCommand]} then {
      set openPgpInstalledCommand {{${fileName}} --version --homedir {}}
    if {$force || ![info exists openPgpInstalledCommand]} then {
      set openPgpInstalledCommand {{${fileNameOnly}} --version --homedir {}}
    }

    #
    # NOTE: The regular expression pattern used when attempting to verify
    #       that OpenPGP is installed locally.  This must be configured
    #       according to the implementation of OpenPGP in use.
    #
    variable openPgpInstalledPattern; # DEFAULT: ^gpg \(GnuPG\) 2\.[0123]\.

    if {![info exists openPgpInstalledPattern]} then {
    if {$force || ![info exists openPgpInstalledPattern]} then {
      set openPgpInstalledPattern {^gpg \(GnuPG\) 2\.[0123]\.}
    }

    #
    # NOTE: The command to use when verifying OpenPGP signatures for the
    #       downloaded package scripts.  This must be configured according
    #       to the implementation of OpenPGP in use.
    #
    variable openPgpVerifyCommand; # DEFAULT: gpg2 --verify {${fileName}}

    if {![info exists openPgpVerifyCommand]} then {
    if {$force || ![info exists openPgpVerifyCommand]} then {
      set openPgpVerifyCommand \
          {{${openPgpFileNameOnly}} --verify {${fileName}}}
    }

    #
    # NOTE: The command to use when creating OpenPGP signatures for the
    #       downloaded package scripts.  This must be configured according
    #       to the implementation of OpenPGP in use.
    #
    variable openPgpSignCommand; # DEFAULT: gpg2 --detach-sign ...

    if {![info exists openPgpSignCommand]} then {
    if {$force || ![info exists openPgpSignCommand]} then {
      set openPgpSignCommand ""

      append openPgpSignCommand \
          {{${openPgpFileNameOnly}} --detach-sign --armor}

      append openPgpSignCommand \
          { --passphrase-file [formatExecArgument [getOpenPgpPassphraseFile]]}