Class: ReaperMan::Signer
- Inherits:
-
Object
- Object
- ReaperMan::Signer
- Includes:
- Utils::Process
- Defined in:
- lib/reaper-man/signer.rb,
lib/reaper-man/signer/deb.rb,
lib/reaper-man/signer/rpm.rb,
lib/reaper-man/signer/rubygems.rb
Overview
File signer
Defined Under Namespace
Constant Summary collapse
- HELPER_COMMAND =
command to use for file signing
File.join( File.(File.dirname(__FILE__)), "util-scripts/auto-helper" )
Instance Attribute Summary collapse
-
#key_id ⇒ Object
readonly
Returns the value of attribute key_id.
-
#key_password ⇒ Object
readonly
Returns the value of attribute key_password.
-
#package_system ⇒ Object
readonly
Returns the value of attribute package_system.
-
#sign_chunk_size ⇒ Object
readonly
Returns the value of attribute sign_chunk_size.
-
#sign_type ⇒ Object
readonly
Returns the value of attribute sign_type.
Instance Method Summary collapse
-
#file(src, dst = nil, sign_opts = nil) ⇒ String
Sign the file.
-
#initialize(args = {}) ⇒ Signer
constructor
Create new instance.
Methods included from Utils::Process
#child_process_command, #mixlib_shellout_command, #shellout
Constructor Details
#initialize(args = {}) ⇒ Signer
Create new instance
32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/reaper-man/signer.rb', line 32 def initialize(args = {}) args = args.to_smash @key_id = args[:signing_key] @sign_chunk_size = args.fetch(:signing_chunk_size, 1) @sign_type = args.fetch(:signing_type, "origin") @key_password = args.fetch(:key_password, ENV["REAPER_KEY_PASSWORD"]) @package_system = args[:package_system] case package_system.to_sym when :deb, :apt extend Deb when :rpm, :yum extend Rpm when :gem, :rubygems extend Rubygems else raise TypeError.new "Unknown packaging type requested (#{package_system})" end end |
Instance Attribute Details
#key_id ⇒ Object (readonly)
Returns the value of attribute key_id.
12 13 14 |
# File 'lib/reaper-man/signer.rb', line 12 def key_id @key_id end |
#key_password ⇒ Object (readonly)
Returns the value of attribute key_password.
16 17 18 |
# File 'lib/reaper-man/signer.rb', line 16 def key_password @key_password end |
#package_system ⇒ Object (readonly)
Returns the value of attribute package_system.
15 16 17 |
# File 'lib/reaper-man/signer.rb', line 15 def package_system @package_system end |
#sign_chunk_size ⇒ Object (readonly)
Returns the value of attribute sign_chunk_size.
13 14 15 |
# File 'lib/reaper-man/signer.rb', line 13 def sign_chunk_size @sign_chunk_size end |
#sign_type ⇒ Object (readonly)
Returns the value of attribute sign_type.
14 15 16 |
# File 'lib/reaper-man/signer.rb', line 14 def sign_type @sign_type end |
Instance Method Details
#file(src, dst = nil, sign_opts = nil) ⇒ String
Sign the file
56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 |
# File 'lib/reaper-man/signer.rb', line 56 def file(src, dst = nil, sign_opts = nil) opts = sign_opts ? [sign_opts].flatten.compact : ["--detach-sign", "--armor"] dst ||= src.sub(/#{Regexp.escape(File.extname(src))}$/, ".gpg") opts << "--output '#{dst}'" cmd = (["gpg --default-key #{key_id}"] + opts + [src]).join(" ") if key_password shellout( "#{HELPER_COMMAND} #{cmd}", :environment => { "REAPER_KEY_PASSWORD" => key_password, }, ) else shellout(cmd) end dst end |