diff options
| author | Reinhard Pointner | 2017-05-10 23:18:42 +0800 |
|---|---|---|
| committer | Reinhard Pointner | 2017-05-10 23:18:42 +0800 |
| commit | 3668a7abb1af9350b7a2c3816859f5be067a0487 (patch) | |
| tree | 41d1a0f05c66d8f7cd563f74ee046e2ccdb1fe0f /Library | |
| parent | f1d4c4be78905be0d5fd83922ff1262ed92ba4e8 (diff) | |
| download | brew-3668a7abb1af9350b7a2c3816859f5be067a0487.tar.bz2 | |
Support GPG (signed data) container in Homebrew Cask
Diffstat (limited to 'Library')
| -rw-r--r-- | Library/Homebrew/cask/lib/hbc/container.rb | 2 | ||||
| -rw-r--r-- | Library/Homebrew/cask/lib/hbc/container/gpg.rb | 41 |
2 files changed, 43 insertions, 0 deletions
diff --git a/Library/Homebrew/cask/lib/hbc/container.rb b/Library/Homebrew/cask/lib/hbc/container.rb index 961e31968..93e825e03 100644 --- a/Library/Homebrew/cask/lib/hbc/container.rb +++ b/Library/Homebrew/cask/lib/hbc/container.rb @@ -6,6 +6,7 @@ require "hbc/container/criteria" require "hbc/container/dmg" require "hbc/container/executable" require "hbc/container/generic_unar" +require "hbc/container/gpg" require "hbc/container/gzip" require "hbc/container/lzma" require "hbc/container/naked" @@ -40,6 +41,7 @@ module Hbc Gzip, # pure gzip Lzma, # pure lzma Xz, # pure xz + Gpg, # GnuPG signed data Executable, ] # for explicit use only (never autodetected): diff --git a/Library/Homebrew/cask/lib/hbc/container/gpg.rb b/Library/Homebrew/cask/lib/hbc/container/gpg.rb new file mode 100644 index 000000000..d9504f5cb --- /dev/null +++ b/Library/Homebrew/cask/lib/hbc/container/gpg.rb @@ -0,0 +1,41 @@ +require "tmpdir" + +require "hbc/container/base" + +module Hbc + class Container + class Gpg < Base + def self.me?(criteria) + criteria.extension(/GPG/n) + end + + def import_key + if @cask.gpg.nil? + raise CaskError, "Expected to find gpg public key in formula. Cask '#{@cask}' must add: key_id or key_url" + end + + args = if @cask.gpg.key_id + ["--recv-keys", @cask.gpg.key_id] + elsif @cask.gpg.key_url + ["--fetch-key", @cask.gpg.key_url.to_s] + end + + @command.run!("gpg", args: args) + end + + def extract + if (gpg = which("gpg")).nil? + raise CaskError, "Expected to find gpg executable. Cask '#{@cask}' must add: depends_on formula: 'gpg'" + end + + import_key + + Dir.mktmpdir do |unpack_dir| + @command.run!(gpg, args: ["--batch", "--yes", "--output", Pathname(unpack_dir).join(File.basename(@path.basename)), "--decrypt", @path]) + + extract_nested_inside(unpack_dir) + end + end + end + end +end |
