Skip to content

Commit

Permalink
Deprecate gpg stanza.
Browse files Browse the repository at this point in the history
  • Loading branch information
reitermarkus committed Sep 3, 2018
1 parent 61ace27 commit 89dd608
Show file tree
Hide file tree
Showing 23 changed files with 31 additions and 339 deletions.
1 change: 0 additions & 1 deletion Library/Homebrew/cask/lib/hbc/cask.rb
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,6 @@ def to_h
"depends_on" => depends_on,
"conflicts_with" => conflicts_with.to_a,
"container" => container,
"gpg" => gpg,
"accessibility_access" => accessibility_access,
"auto_updates" => auto_updates,
}
Expand Down
6 changes: 0 additions & 6 deletions Library/Homebrew/cask/lib/hbc/dsl.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
require "hbc/dsl/conflicts_with"
require "hbc/dsl/container"
require "hbc/dsl/depends_on"
require "hbc/dsl/gpg"
require "hbc/dsl/postflight"
require "hbc/dsl/preflight"
require "hbc/dsl/uninstall_postflight"
Expand Down Expand Up @@ -64,7 +63,6 @@ class DSL
:conflicts_with,
:container,
:depends_on,
:gpg,
:homepage,
:language,
:languages,
Expand Down Expand Up @@ -179,10 +177,6 @@ def appcast(*args)
set_unique_stanza(:appcast, args.empty?) { DSL::Appcast.new(*args) }
end

def gpg(*args)
set_unique_stanza(:gpg, args.empty?) { DSL::Gpg.new(*args) }
end

def container(*args)
set_unique_stanza(:container, args.empty?) do
DSL::Container.new(*args)
Expand Down
47 changes: 0 additions & 47 deletions Library/Homebrew/cask/lib/hbc/dsl/gpg.rb

This file was deleted.

30 changes: 12 additions & 18 deletions Library/Homebrew/cask/lib/hbc/installer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,6 @@ class Installer
include Staged
include Verify

PERSISTENT_METADATA_SUBDIRS = ["gpg"].freeze

def initialize(cask, command: SystemCommand, force: false,
skip_cask_deps: false, binaries: true, verbose: false,
require_sha: false, upgrade: false,
Expand Down Expand Up @@ -504,12 +502,12 @@ def zap

def backup_path
return if @cask.staged_path.nil?
Pathname.new "#{@cask.staged_path}.upgrading"
Pathname("#{@cask.staged_path}.upgrading")
end

def backup_metadata_path
return if @cask.metadata_versioned_path.nil?
Pathname.new "#{@cask.metadata_versioned_path}.upgrading"
Pathname("#{@cask.metadata_versioned_path}.upgrading")
end

def gain_permissions_remove(path)
Expand All @@ -520,15 +518,13 @@ def purge_backed_up_versioned_files
ohai "Purging files for version #{@cask.version} of Cask #{@cask}"

# versioned staged distribution
gain_permissions_remove(backup_path) if !backup_path.nil? && backup_path.exist?
gain_permissions_remove(backup_path) if backup_path&.exist?

# Homebrew-Cask metadata
if backup_metadata_path.directory?
backup_metadata_path.children.each do |subdir|
unless PERSISTENT_METADATA_SUBDIRS.include?(subdir.basename)
gain_permissions_remove(subdir)
end
end
return unless backup_metadata_path.directory?

backup_metadata_path.children.each do |subdir|
gain_permissions_remove(subdir)
end
backup_metadata_path.rmdir_if_possible
end
Expand All @@ -537,18 +533,16 @@ def purge_versioned_files
ohai "Purging files for version #{@cask.version} of Cask #{@cask}"

# versioned staged distribution
gain_permissions_remove(@cask.staged_path) if !@cask.staged_path.nil? && @cask.staged_path.exist?
gain_permissions_remove(@cask.staged_path) if @cask.staged_path&.exist?

# Homebrew-Cask metadata
if @cask.metadata_versioned_path.respond_to?(:children) &&
@cask.metadata_versioned_path.exist?
if @cask.metadata_versioned_path.directory?
@cask.metadata_versioned_path.children.each do |subdir|
unless PERSISTENT_METADATA_SUBDIRS.include?(subdir.basename)
gain_permissions_remove(subdir)
end
gain_permissions_remove(subdir)
end

@cask.metadata_versioned_path.rmdir_if_possible
end
@cask.metadata_versioned_path.rmdir_if_possible
@cask.metadata_master_container_path.rmdir_if_possible unless upgrade?

# toplevel staged distribution
Expand Down
4 changes: 1 addition & 3 deletions Library/Homebrew/cask/lib/hbc/verify.rb
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
require "hbc/verify/checksum"
require "hbc/verify/gpg"

module Hbc
module Verify
module_function

def verifications
[
Hbc::Verify::Checksum
# TODO: Hbc::Verify::Gpg
Hbc::Verify::Checksum,
]
end

Expand Down
4 changes: 2 additions & 2 deletions Library/Homebrew/cask/lib/hbc/verify/checksum.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ def initialize(cask, downloaded_path)

def verify
return unless self.class.me?(cask)
ohai "Verifying checksum for Cask #{cask}"
ohai "Verifying SHA-256 checksum for Cask '#{cask}'."
verify_checksum
end

Expand All @@ -36,7 +36,7 @@ def verify_checksum
raise CaskSha256MissingError.new(cask.token, expected, computed) if expected.nil? || expected.empty?

if expected == computed
odebug "SHA256 checksums match"
odebug "SHA-256 checksums match."
else
ohai 'Note: running "brew update" may fix sha256 checksum errors'
raise CaskSha256MismatchError.new(cask.token, expected, computed, downloaded_path)
Expand Down
64 changes: 0 additions & 64 deletions Library/Homebrew/cask/lib/hbc/verify/gpg.rb

This file was deleted.

6 changes: 5 additions & 1 deletion Library/Homebrew/compat/hbc/dsl.rb
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
module Hbc
class DSL
module Compat
def gpg(*)
odeprecated "the `gpg` stanza", disable_on: Time.new(2018, 12, 31)
end

def license(*)
odisabled "Hbc::DSL#license"
odisabled "the `license` stanza"
end
end

Expand Down
2 changes: 1 addition & 1 deletion Library/Homebrew/test/cask/cli/install_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
it "displays the installation progress" do
output = Regexp.new <<~EOS
==> Downloading file:.*caffeine.zip
==> Verifying checksum for Cask local-caffeine
==> Verifying SHA-256 checksum for Cask 'local-caffeine'.
==> Installing Cask local-caffeine
==> Moving App 'Caffeine.app' to '.*Caffeine.app'.
.*local-caffeine was successfully installed!
Expand Down
14 changes: 7 additions & 7 deletions Library/Homebrew/test/cask/cli/internal_stanza_spec.rb
Original file line number Diff line number Diff line change
@@ -1,40 +1,40 @@
describe Hbc::CLI::InternalStanza, :cask do
it "shows stanza of the Specified Cask" do
command = described_class.new("gpg", "with-gpg")
command = described_class.new("homepage", "local-caffeine")
expect {
command.run
}.to output("https://example.com/gpg-signature.asc\n").to_stdout
}.to output("https://example.com/local-caffeine\n").to_stdout
end

it "raises an exception when stanza is unknown/unsupported" do
expect {
described_class.new("this_stanza_does_not_exist", "with-gpg")
described_class.new("this_stanza_does_not_exist", "local-caffeine")
}.to raise_error(%r{Unknown/unsupported stanza})
end

it "raises an exception when normal stanza is not present on cask" do
command = described_class.new("caveats", "with-gpg")
command = described_class.new("caveats", "local-caffeine")
expect {
command.run
}.to raise_error(/no such stanza/)
end

it "raises an exception when artifact stanza is not present on cask" do
command = described_class.new("zap", "with-gpg")
command = described_class.new("zap", "local-caffeine")
expect {
command.run
}.to raise_error(/no such stanza/)
end

it "raises an exception when 'depends_on' stanza is not present on cask" do
command = described_class.new("depends_on", "with-gpg")
command = described_class.new("depends_on", "local-caffeine")
expect {
command.run
}.to raise_error(/no such stanza/)
end

it "shows all artifact stanzas when using 'artifacts' keyword" do
command = described_class.new("artifacts", "with-gpg")
command = described_class.new("artifacts", "local-caffeine")
expect {
command.run
}.to output(/Caffeine\.app/).to_stdout
Expand Down
4 changes: 2 additions & 2 deletions Library/Homebrew/test/cask/cli/reinstall_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@

output = Regexp.new <<~EOS
==> Downloading file:.*caffeine.zip
Already downloaded: .*caffeine.zip
==> Verifying checksum for Cask local-caffeine
Already downloaded: .*--caffeine.zip
==> Verifying SHA-256 checksum for Cask 'local-caffeine'.
==> Uninstalling Cask local-caffeine
==> Backing App 'Caffeine.app' up to '.*Caffeine.app'.
==> Removing App '.*Caffeine.app'.
Expand Down
Loading

0 comments on commit 89dd608

Please sign in to comment.