Index: client/1.0/neutral/pkgr.eagle ================================================================== --- client/1.0/neutral/pkgr.eagle +++ client/1.0/neutral/pkgr.eagle @@ -394,12 +394,12 @@ # it already appeared to be available for use. # # proc probeForOpenPgpInstallation {} { global env + variable openPgpFileNameOnly variable openPgpInstalledDirectory - variable openPgpInstalledFileName if {[catch {openPgpMustBeInstalled}] == 0} then { return true } @@ -419,11 +419,11 @@ if {![file isdirectory $directory]} then { return false } - set fileName [file join $directory $openPgpInstalledFileName] + set fileName [file join $directory $openPgpFileNameOnly] if {[file exists $fileName] && [file isfile $fileName]} then { return [addToPath $directory] } @@ -436,10 +436,11 @@ # errors are raised if any problems are found. The return value is # undefined. # # proc openPgpMustBeInstalled {} { + variable openPgpFileNameOnly variable openPgpInstalledCommand variable openPgpInstalledPattern set message { Cannot use OpenPGP: it does not appear to be installed. @@ -452,17 +453,17 @@ the package management subsystem included with your operating system. } if {[isEagle]} then { if {[catch { - eval exec -success Success $openPgpInstalledCommand + eval exec -success Success [subst $openPgpInstalledCommand] } result]} then { error $message } } else { if {[catch { - eval exec $openPgpInstalledCommand + eval exec [subst $openPgpInstalledCommand] } result]} then { error $message } } @@ -482,10 +483,11 @@ # the fully qualified path and file name of the OpenPGP signature # file to verify. # # proc verifyOpenPgpSignature { fileName } { + variable openPgpFileNameOnly variable openPgpVerifyCommand if {[isEagle]} then { set fileName [formatExecArgument $fileName] @@ -587,10 +589,11 @@ # qualified path and file name of the file to be signed. # # proc createOpenPgpSignature { fileName } { global env + variable openPgpFileNameOnly variable openPgpSignCommand if {[isEagle]} then { set fileName [formatExecArgument $fileName] @@ -620,10 +623,11 @@ # "pkgr_setup.eagle" tool script and may go away in later versions # of this package. # # proc importOpenPgpKeyFile { fileName varName } { + variable openPgpFileNameOnly variable openPgpImportCommand variable openPgpImportPattern if {[string length $varName] > 0} then { upvar 1 $varName result @@ -2067,10 +2071,123 @@ uplevel 1 [list source $fileName] } } } + # + # NOTE: This procedure sets up the default values for all configuration + # parameters used to interact with the OpenPGP implementation. + # There are no arguments. + # + proc setupRepositoryOpenPgpVars {} { + # + # 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] + + if {![info exists openPgpInstalledDirectory]} then { + if {[isWindows]} then { + set openPgpInstalledDirectory [file join GNU GnuPG] + } else { + set openPgpInstalledDirectory [file join / usr bin] + } + } + + # + # NOTE: This is the name of the executable file used to invoke the + # OpenPGP implementation, possibly without a file extension. + # + variable openPgpFileNameOnly; # DEFAULT: gpg2[.exe] + + if {![info exists openPgpFileNameOnly]} then { + if {[isWindows]} then { + set openPgpFileNameOnly gpg2.exe + } else { + set openPgpFileNameOnly gpg2 + } + } + + # + # 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 { + 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: 1$ + + if {![info exists openPgpImportPattern]} then { + set openPgpImportPattern {^gpg: Total number processed: 1$} + } + + # + # 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 + + if {![info exists openPgpInstalledCommand]} then { + set openPgpInstalledCommand \ + {{${openPgpFileNameOnly}} --version} + } + + # + # 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\.[012]\. + + if {![info exists openPgpInstalledPattern]} then { + set openPgpInstalledPattern {^gpg \(GnuPG\) 2\.[012]\.} + } + + # + # 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 { + 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 { + set openPgpSignCommand "" + + append openPgpSignCommand \ + {{${openPgpFileNameOnly}} --detach-sign --armor} + + append openPgpSignCommand \ + { --passphrase-file [formatExecArgument [getOpenPgpPassphraseFile]]} + + append openPgpSignCommand { --batch --yes {${fileName}}} + } + } + # # NOTE: This procedure sets up the default values for all configuration # parameters used by the package repository client. There are no # arguments. # @@ -2130,112 +2247,10 @@ } else { set autoRequireGaruda false } } - # - # 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] - - if {![info exists openPgpInstalledDirectory]} then { - if {[isWindows]} then { - set openPgpInstalledDirectory [file join GNU GnuPG] - } else { - set openPgpInstalledDirectory [file join / usr bin] - } - } - - # - # NOTE: This is the name of the executable file used to invoke the - # OpenPGP implementation, without an extension. - # - variable openPgpInstalledFileName; # DEFAULT: gpg2 - - if {![info exists openPgpInstalledFileName]} then { - if {[isWindows]} then { - set openPgpInstalledFileName gpg2.exe - } else { - set openPgpInstalledFileName gpg2 - } - } - - # - # 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 { - set openPgpImportCommand {gpg2 --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: 1$ - - if {![info exists openPgpImportPattern]} then { - set openPgpImportPattern {^gpg: Total number processed: 1$} - } - - # - # 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 - - if {![info exists openPgpInstalledCommand]} then { - set openPgpInstalledCommand {gpg2 --version} - } - - # - # 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\.[01]\. - - if {![info exists openPgpInstalledPattern]} then { - set openPgpInstalledPattern {^gpg \(GnuPG\) 2\.[01]\.} - } - - # - # 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 { - set openPgpVerifyCommand {gpg2 --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 { - set openPgpSignCommand "" - - append openPgpSignCommand {gpg2 --detach-sign --armor} - - append openPgpSignCommand \ - { --passphrase-file [formatExecArgument [getOpenPgpPassphraseFile]]} - - append openPgpSignCommand { --batch --yes {${fileName}}} - } - # # NOTE: The command to use when creating Harpy signatures for downloaded # package scripts. # variable harpySignCommand; # DEFAULT: {${shellFileName}} -file ... @@ -2383,10 +2398,16 @@ # used by this script. # setupRepositoryServerVars false setupRepositoryUriVars false + # + # NOTE: Setup the OpenPGP implementation related variables, in this + # namespace, that are used by this script. + # + setupRepositoryOpenPgpVars + # # NOTE: Setup the variables, within this namespace, used by this script. # setupPackageUnknownVars