Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove the accessibility_access stanza. #5056

Merged
merged 2 commits into from
Oct 8, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 0 additions & 1 deletion Library/Homebrew/cask/cask.rb
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,6 @@ def to_h
"depends_on" => depends_on,
"conflicts_with" => conflicts_with.to_a,
"container" => container,
"accessibility_access" => accessibility_access,
"auto_updates" => auto_updates,
}
end
Expand Down
2 changes: 0 additions & 2 deletions Library/Homebrew/cask/cmd/upgrade.rb
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,6 @@ def run
new_cask_installer.install_artifacts
new_artifacts_installed = true

new_cask_installer.enable_accessibility_access

# If successful, wipe the old Cask from staging
old_cask_installer.finalize_upgrade
rescue CaskError => e
Expand Down
5 changes: 0 additions & 5 deletions Library/Homebrew/cask/dsl.rb
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@ class DSL
].freeze

DSL_METHODS = Set.new [
:accessibility_access,
:appcast,
:artifacts,
:auto_updates,
Expand Down Expand Up @@ -251,10 +250,6 @@ def caveats(*strings, &block)
@caveats
end

def accessibility_access(accessibility_access = nil)
set_unique_stanza(:accessibility_access, accessibility_access.nil?) { accessibility_access }
end

def auto_updates(auto_updates = nil)
set_unique_stanza(:auto_updates, auto_updates.nil?) { auto_updates }
end
Expand Down
65 changes: 0 additions & 65 deletions Library/Homebrew/cask/installer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,6 @@ def install
opoo "macOS's Gatekeeper has been disabled for this Cask" unless quarantine?
stage
install_artifacts
enable_accessibility_access

unless @cask.tap&.private?
::Utils::Analytics.report_event("cask_install", @cask.token)
Expand Down Expand Up @@ -365,67 +364,6 @@ def print_caveats
self.class.print_caveats(@cask)
end

# TODO: logically could be in a separate class
def enable_accessibility_access
return unless @cask.accessibility_access

ohai "Enabling accessibility access"
if MacOS.version <= :mountain_lion
@command.run!(
"/usr/bin/touch",
args: [MacOS.pre_mavericks_accessibility_dotfile],
sudo: true,
)
elsif MacOS.version <= :yosemite
@command.run!(
"/usr/bin/sqlite3",
args: [
MacOS.tcc_db,
"INSERT OR REPLACE INTO access " \
"VALUES('kTCCServiceAccessibility','#{bundle_identifier}',0,1,1,NULL);",
],
sudo: true,
)
elsif MacOS.version <= :el_capitan
@command.run!(
"/usr/bin/sqlite3",
args: [
MacOS.tcc_db,
"INSERT OR REPLACE INTO access " \
"VALUES('kTCCServiceAccessibility','#{bundle_identifier}',0,1,1,NULL,NULL);",
],
sudo: true,
)
else
opoo <<~EOS
Accessibility access cannot be enabled automatically on this version of macOS.
See System Preferences to enable it manually.
EOS
end
rescue => e
purge_versioned_files
raise e
end

def disable_accessibility_access
return unless @cask.accessibility_access

if MacOS.version >= :mavericks && MacOS.version <= :el_capitan
ohai "Disabling accessibility access"
@command.run!("/usr/bin/sqlite3",
args: [
MacOS.tcc_db,
"DELETE FROM access WHERE client='#{bundle_identifier}';",
],
sudo: true)
else
opoo <<~EOS
Accessibility access cannot be disabled automatically on this version of macOS.
See System Preferences to disable it manually.
EOS
end
end

def save_caskfile
old_savedir = @cask.metadata_timestamped_path

Expand All @@ -438,7 +376,6 @@ def save_caskfile

def uninstall
oh1 "Uninstalling Cask #{Formatter.identifier(@cask)}"
disable_accessibility_access
uninstall_artifacts(clear: true)
purge_versioned_files
purge_caskroom_path if force?
Expand All @@ -447,7 +384,6 @@ def uninstall
def start_upgrade
oh1 "Starting upgrade for Cask #{Formatter.identifier(@cask)}"

disable_accessibility_access
uninstall_artifacts
backup
end
Expand All @@ -471,7 +407,6 @@ def revert_upgrade
opoo "Reverting upgrade for Cask #{@cask}"
restore_backup
install_artifacts
enable_accessibility_access
end

def finalize_upgrade
Expand Down
23 changes: 0 additions & 23 deletions Library/Homebrew/cask/staged.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,29 +2,6 @@

module Cask
module Staged
def info_plist_file(index = 0)
index = 0 if index == :first
index = 1 if index == :second
index = -1 if index == :last
@cask.artifacts.select { |a| a.is_a?(Artifact::App) }.at(index).target.join("Contents", "Info.plist")
end

def plist_exec(cmd)
@command.run!("/usr/libexec/PlistBuddy", args: ["-c", cmd, info_plist_file])
end

def plist_set(key, value)
plist_exec("Set #{key} #{value}")
rescue => e
raise CaskError, "#{@cask.token}: 'plist_set' failed with: #{e}"
end

def bundle_identifier
plist_exec("Print CFBundleIdentifier").stdout.chomp
rescue => e
raise CaskError, "#{@cask.token}: 'bundle_identifier' failed with: #{e}"
end

def set_permissions(paths, permissions_str)
full_paths = remove_nonexistent(paths)
return if full_paths.empty?
Expand Down
4 changes: 4 additions & 0 deletions Library/Homebrew/compat/cask/dsl.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@ def gpg(*)
def license(*)
odisabled "the `license` stanza"
end

def accessibility_access(*)
odeprecated "the `accessibility_access` stanza"
end
end

prepend Compat
Expand Down
83 changes: 0 additions & 83 deletions Library/Homebrew/test/cask/accessibility_spec.rb

This file was deleted.

14 changes: 0 additions & 14 deletions Library/Homebrew/test/cask/staged_spec.rb

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -21,30 +21,6 @@
staged.system_command("echo", args: ["homebrew-cask", "rocks!"])
end

it "can get the Info.plist file for the primary app" do
expect(staged.info_plist_file).to eq Cask::Config.global.appdir.join("TestCask.app/Contents/Info.plist")
end

it "can execute commands on the Info.plist file" do
allow(staged).to receive(:bundle_identifier).and_return("com.example.BasicCask")

FakeSystemCommand.expects_command(
["/usr/libexec/PlistBuddy", "-c", "Print CFBundleIdentifier", staged.info_plist_file],
)

staged.plist_exec("Print CFBundleIdentifier")
end

it "can set a key in the Info.plist file" do
allow(staged).to receive(:bundle_identifier).and_return("com.example.BasicCask")

FakeSystemCommand.expects_command(
["/usr/libexec/PlistBuddy", "-c", "Set :JVMOptions:JVMVersion 1.6+", staged.info_plist_file],
)

staged.plist_set(":JVMOptions:JVMVersion", "1.6+")
end

it "can set the permissions of a file" do
fake_pathname = existing_path
allow(staged).to receive(:Pathname).and_return(fake_pathname)
Expand Down