Module: Pkg::Util::Gpg
- Defined in:
- lib/packaging/util/gpg.rb
Class Method Summary collapse
-
.key ⇒ Object
Please note that this method is not used in determining what key is used to sign the debian repos.
- .keychain ⇒ Object
- .kill_keychain ⇒ Object
- .load_keychain ⇒ Object
- .sign_file(file) ⇒ Object
- .start_keychain ⇒ Object
Class Method Details
.key ⇒ Object
Please note that this method is not used in determining what key is used to sign the debian repos. That is defined in the freight config that lives on our internal repo staging host. The debian conf/distribution files that are generated with this repo use the default gpg key to reflect that.
9 10 11 12 |
# File 'lib/packaging/util/gpg.rb', line 9 def key fail "You need to set `gpg_key` in your build defaults." unless Pkg::Config.gpg_key && !Pkg::Config.gpg_key.empty? Pkg::Config.gpg_key end |
.keychain ⇒ Object
14 15 16 17 18 19 20 |
# File 'lib/packaging/util/gpg.rb', line 14 def keychain if @keychain.nil? @keychain = Pkg::Util::Tool.find_tool('keychain') else @keychain end end |
.kill_keychain ⇒ Object
32 33 34 35 36 37 |
# File 'lib/packaging/util/gpg.rb', line 32 def kill_keychain if keychain stdout, _, _ = Pkg::Util::Execution.capture3("#{keychain} -k mine") stdout end end |
.load_keychain ⇒ Object
22 23 24 25 26 27 28 29 30 |
# File 'lib/packaging/util/gpg.rb', line 22 def load_keychain unless @keychain_loaded unless ENV['RPM_GPG_AGENT'] kill_keychain start_keychain end @keychain_loaded = true end end |
.sign_file(file) ⇒ Object
50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 |
# File 'lib/packaging/util/gpg.rb', line 50 def sign_file(file) gpg ||= Pkg::Util::Tool.find_tool('gpg') if gpg if File.exist? "#{file}.asc" warn "Signature on #{file} exists, skipping..." return true end use_tty = "--no-tty --use-agent" if ENV['RPM_GPG_AGENT'] stdout, _, _ = Pkg::Util::Execution.capture3("#{gpg} #{use_tty} --armor --detach-sign -u #{key} #{file}") stdout else fail "No gpg available. Cannot sign #{file}." end end |
.start_keychain ⇒ Object
39 40 41 42 43 44 45 46 47 48 |
# File 'lib/packaging/util/gpg.rb', line 39 def start_keychain if keychain keychain_output, _, _ = Pkg::Util::Execution.capture3("#{keychain} -q --agents gpg --eval #{key}") keychain_output.chomp! new_env = keychain_output.match(/GPG_AGENT_INFO=([^;]*)/) ENV["GPG_AGENT_INFO"] = new_env[1] else fail "Keychain is not installed, it is required to autosign using gpg." end end |