Merge pull request #5056 from reitermarkus/accessibility_access
Remove the `accessibility_access` stanza.
This commit is contained in:
commit
711bb4977f
@ -135,7 +135,6 @@ module Cask
|
|||||||
"depends_on" => depends_on,
|
"depends_on" => depends_on,
|
||||||
"conflicts_with" => conflicts_with.to_a,
|
"conflicts_with" => conflicts_with.to_a,
|
||||||
"container" => container,
|
"container" => container,
|
||||||
"accessibility_access" => accessibility_access,
|
|
||||||
"auto_updates" => auto_updates,
|
"auto_updates" => auto_updates,
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|||||||
@ -83,8 +83,6 @@ module Cask
|
|||||||
new_cask_installer.install_artifacts
|
new_cask_installer.install_artifacts
|
||||||
new_artifacts_installed = true
|
new_artifacts_installed = true
|
||||||
|
|
||||||
new_cask_installer.enable_accessibility_access
|
|
||||||
|
|
||||||
# If successful, wipe the old Cask from staging
|
# If successful, wipe the old Cask from staging
|
||||||
old_cask_installer.finalize_upgrade
|
old_cask_installer.finalize_upgrade
|
||||||
rescue CaskError => e
|
rescue CaskError => e
|
||||||
|
|||||||
@ -54,7 +54,6 @@ module Cask
|
|||||||
].freeze
|
].freeze
|
||||||
|
|
||||||
DSL_METHODS = Set.new [
|
DSL_METHODS = Set.new [
|
||||||
:accessibility_access,
|
|
||||||
:appcast,
|
:appcast,
|
||||||
:artifacts,
|
:artifacts,
|
||||||
:auto_updates,
|
:auto_updates,
|
||||||
@ -251,10 +250,6 @@ module Cask
|
|||||||
@caveats
|
@caveats
|
||||||
end
|
end
|
||||||
|
|
||||||
def accessibility_access(accessibility_access = nil)
|
|
||||||
set_unique_stanza(:accessibility_access, accessibility_access.nil?) { accessibility_access }
|
|
||||||
end
|
|
||||||
|
|
||||||
def auto_updates(auto_updates = nil)
|
def auto_updates(auto_updates = nil)
|
||||||
set_unique_stanza(:auto_updates, auto_updates.nil?) { auto_updates }
|
set_unique_stanza(:auto_updates, auto_updates.nil?) { auto_updates }
|
||||||
end
|
end
|
||||||
|
|||||||
@ -93,7 +93,6 @@ module Cask
|
|||||||
opoo "macOS's Gatekeeper has been disabled for this Cask" unless quarantine?
|
opoo "macOS's Gatekeeper has been disabled for this Cask" unless quarantine?
|
||||||
stage
|
stage
|
||||||
install_artifacts
|
install_artifacts
|
||||||
enable_accessibility_access
|
|
||||||
|
|
||||||
unless @cask.tap&.private?
|
unless @cask.tap&.private?
|
||||||
::Utils::Analytics.report_event("cask_install", @cask.token)
|
::Utils::Analytics.report_event("cask_install", @cask.token)
|
||||||
@ -364,67 +363,6 @@ module Cask
|
|||||||
self.class.print_caveats(@cask)
|
self.class.print_caveats(@cask)
|
||||||
end
|
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
|
def save_caskfile
|
||||||
old_savedir = @cask.metadata_timestamped_path
|
old_savedir = @cask.metadata_timestamped_path
|
||||||
|
|
||||||
@ -437,7 +375,6 @@ module Cask
|
|||||||
|
|
||||||
def uninstall
|
def uninstall
|
||||||
oh1 "Uninstalling Cask #{Formatter.identifier(@cask)}"
|
oh1 "Uninstalling Cask #{Formatter.identifier(@cask)}"
|
||||||
disable_accessibility_access
|
|
||||||
uninstall_artifacts(clear: true)
|
uninstall_artifacts(clear: true)
|
||||||
purge_versioned_files
|
purge_versioned_files
|
||||||
purge_caskroom_path if force?
|
purge_caskroom_path if force?
|
||||||
@ -446,7 +383,6 @@ module Cask
|
|||||||
def start_upgrade
|
def start_upgrade
|
||||||
oh1 "Starting upgrade for Cask #{Formatter.identifier(@cask)}"
|
oh1 "Starting upgrade for Cask #{Formatter.identifier(@cask)}"
|
||||||
|
|
||||||
disable_accessibility_access
|
|
||||||
uninstall_artifacts
|
uninstall_artifacts
|
||||||
backup
|
backup
|
||||||
end
|
end
|
||||||
@ -470,7 +406,6 @@ module Cask
|
|||||||
opoo "Reverting upgrade for Cask #{@cask}"
|
opoo "Reverting upgrade for Cask #{@cask}"
|
||||||
restore_backup
|
restore_backup
|
||||||
install_artifacts
|
install_artifacts
|
||||||
enable_accessibility_access
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def finalize_upgrade
|
def finalize_upgrade
|
||||||
|
|||||||
@ -2,29 +2,6 @@ require "utils/user"
|
|||||||
|
|
||||||
module Cask
|
module Cask
|
||||||
module Staged
|
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)
|
def set_permissions(paths, permissions_str)
|
||||||
full_paths = remove_nonexistent(paths)
|
full_paths = remove_nonexistent(paths)
|
||||||
return if full_paths.empty?
|
return if full_paths.empty?
|
||||||
|
|||||||
@ -8,6 +8,10 @@ module Cask
|
|||||||
def license(*)
|
def license(*)
|
||||||
odisabled "the `license` stanza"
|
odisabled "the `license` stanza"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def accessibility_access(*)
|
||||||
|
odeprecated "the `accessibility_access` stanza"
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
prepend Compat
|
prepend Compat
|
||||||
|
|||||||
@ -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
|
|
||||||
@ -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
|
|
||||||
@ -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
|
|
||||||
@ -21,30 +21,6 @@ shared_examples Cask::Staged do
|
|||||||
staged.system_command("echo", args: ["homebrew-cask", "rocks!"])
|
staged.system_command("echo", args: ["homebrew-cask", "rocks!"])
|
||||||
end
|
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
|
it "can set the permissions of a file" do
|
||||||
fake_pathname = existing_path
|
fake_pathname = existing_path
|
||||||
allow(staged).to receive(:Pathname).and_return(fake_pathname)
|
allow(staged).to receive(:Pathname).and_return(fake_pathname)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user