Merge pull request #5056 from reitermarkus/accessibility_access

Remove the `accessibility_access` stanza.
This commit is contained in:
Markus Reiter 2018-10-08 18:24:18 +02:00 committed by GitHub
commit 711bb4977f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
10 changed files with 4 additions and 228 deletions

View File

@ -135,7 +135,6 @@ module Cask
"depends_on" => depends_on,
"conflicts_with" => conflicts_with.to_a,
"container" => container,
"accessibility_access" => accessibility_access,
"auto_updates" => auto_updates,
}
end

View File

@ -83,8 +83,6 @@ module Cask
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

View File

@ -54,7 +54,6 @@ module Cask
].freeze
DSL_METHODS = Set.new [
:accessibility_access,
:appcast,
:artifacts,
:auto_updates,
@ -251,10 +250,6 @@ module Cask
@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

View File

@ -93,7 +93,6 @@ module Cask
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)
@ -364,67 +363,6 @@ module Cask
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
@ -437,7 +375,6 @@ module Cask
def uninstall
oh1 "Uninstalling Cask #{Formatter.identifier(@cask)}"
disable_accessibility_access
uninstall_artifacts(clear: true)
purge_versioned_files
purge_caskroom_path if force?
@ -446,7 +383,6 @@ module Cask
def start_upgrade
oh1 "Starting upgrade for Cask #{Formatter.identifier(@cask)}"
disable_accessibility_access
uninstall_artifacts
backup
end
@ -470,7 +406,6 @@ module Cask
opoo "Reverting upgrade for Cask #{@cask}"
restore_backup
install_artifacts
enable_accessibility_access
end
def finalize_upgrade

View File

@ -2,29 +2,6 @@ require "utils/user"
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?

View File

@ -8,6 +8,10 @@ module Cask
def license(*)
odisabled "the `license` stanza"
end
def accessibility_access(*)
odeprecated "the `accessibility_access` stanza"
end
end
prepend Compat

View File

@ -1,83 +0,0 @@
# TODO: this test should be named after the corresponding class, once
# that class is abstracted from installer.rb.
describe "Accessibility Access", :cask do
let(:cask) { Cask::CaskLoader.load(cask_path("with-accessibility-access")) }
let(:fake_system_command) { class_double(SystemCommand) }
let(:installer) { Cask::Installer.new(cask, command: fake_system_command) }
before do
allow(MacOS).to receive(:version).and_return(MacOS::Version.new(macos_version))
allow(installer).to receive(:bundle_identifier).and_return("com.example.BasicCask")
end
context "on MacOS 10.8 and below" do
let(:macos_version) { "10.8" }
it "can enable accessibility access in macOS releases prior to Mavericks" do
expect(fake_system_command).to receive(:run!).with(
"/usr/bin/touch",
args: [MacOS.pre_mavericks_accessibility_dotfile],
sudo: true,
)
installer.enable_accessibility_access
end
it "warns about disabling accessibility access on old macOS releases" do
expect {
installer.disable_accessibility_access
}.to output(
/Warning: Accessibility access cannot be disabled automatically on this version of macOS\./,
).to_stderr
end
end
context "on MacOS 10.9" do
let(:macos_version) { "10.9" }
it "can enable accessibility access" do
expect(fake_system_command).to receive(:run!).with(
"/usr/bin/sqlite3",
args: [
MacOS.tcc_db,
"INSERT OR REPLACE INTO access VALUES('kTCCServiceAccessibility','com.example.BasicCask',0,1,1,NULL);",
],
sudo: true,
)
installer.enable_accessibility_access
end
it "can disable accessibility access" do
expect(fake_system_command).to receive(:run!).with(
"/usr/bin/sqlite3",
args: [MacOS.tcc_db, "DELETE FROM access WHERE client='com.example.BasicCask';"],
sudo: true,
)
installer.disable_accessibility_access
end
end
context "on MacOS 10.12 and above" do
let(:macos_version) { "10.12" }
it "warns about enabling accessibility access on new macOS releases" do
expect {
expect {
installer.enable_accessibility_access
}.to output.to_stdout
}.to output(
/Warning: Accessibility access cannot be enabled automatically on this version of macOS\./,
).to_stderr
end
it "warns about disabling accessibility access on new macOS releases" do
expect {
installer.disable_accessibility_access
}.to output(
/Warning: Accessibility access cannot be disabled automatically on this version of macOS\./,
).to_stderr
end
end
end

View File

@ -1,14 +0,0 @@
# TODO: this test should be named after the corresponding class, once
# that class is abstracted from installer.rb. It makes little sense
# to be invoking bundle_identifier off of the installer instance.
describe "Operations on staged Casks", :cask do
describe "bundle ID" do
let(:cask) { Cask::CaskLoader.load(cask_path("local-transmission")) }
let(:installer) { Cask::Installer.new(cask) }
it "fetches the bundle ID from a staged cask" do
installer.install
expect(installer.bundle_identifier).to eq("org.m0k.transmission")
end
end
end

View File

@ -1,11 +0,0 @@
cask 'with-accessibility-access' do
version '1.2.3'
sha256 '8c62a2b791cf5f0da6066a0a4b6e85f62949cd60975da062df44adf887f4370b'
url 'https://example.com/TestCask.dmg'
homepage 'https://example.com/'
accessibility_access true
app 'TestCask.app'
end

View File

@ -21,30 +21,6 @@ shared_examples Cask::Staged do
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)