Also keep app directories with "brew reinstall".
This commit is contained in:
parent
5c9fa845a8
commit
dcc4ae76e8
@ -270,8 +270,8 @@ module Cask
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def uninstall_login_item(*login_items, command: nil, upgrade: false, **_)
|
def uninstall_login_item(*login_items, command: nil, upgrade_or_reinstall: false, **_)
|
||||||
return if upgrade
|
return if upgrade_or_reinstall
|
||||||
|
|
||||||
apps = cask.artifacts.select { |a| a.class.dsl_key == :app }
|
apps = cask.artifacts.select { |a| a.class.dsl_key == :app }
|
||||||
derived_login_items = apps.map { |a| { path: a.target } }
|
derived_login_items = apps.map { |a| { path: a.target } }
|
||||||
|
@ -35,13 +35,14 @@ module Cask
|
|||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
def move(adopt: false, force: false, verbose: false, upgrade: false, command: nil, **options)
|
def move(adopt: false, force: false, verbose: false, upgrade_or_reinstall: false, reinstall: false,
|
||||||
|
command: nil, **options)
|
||||||
unless source.exist?
|
unless source.exist?
|
||||||
raise CaskError, "It seems the #{self.class.english_name} source '#{source}' is not there."
|
raise CaskError, "It seems the #{self.class.english_name} source '#{source}' is not there."
|
||||||
end
|
end
|
||||||
|
|
||||||
if Utils.path_occupied?(target)
|
if Utils.path_occupied?(target)
|
||||||
if upgrade && target.directory? && target.children.empty?
|
if upgrade_or_reinstall && target.directory? && target.children.empty?
|
||||||
# An upgrade removed the directory contents but left the directory itself (see below).
|
# An upgrade removed the directory contents but left the directory itself (see below).
|
||||||
unless source.directory?
|
unless source.directory?
|
||||||
if target.parent.writable? && !force
|
if target.parent.writable? && !force
|
||||||
@ -148,13 +149,13 @@ module Cask
|
|||||||
delete(target, force: force, command: command, **options)
|
delete(target, force: force, command: command, **options)
|
||||||
end
|
end
|
||||||
|
|
||||||
def delete(target, force: false, upgrade: false, command: nil, **_)
|
def delete(target, force: false, upgrade_or_reinstall: false, command: nil, **_)
|
||||||
ohai "Removing #{self.class.english_name} '#{target}'"
|
ohai "Removing #{self.class.english_name} '#{target}'"
|
||||||
raise CaskError, "Cannot remove undeletable #{self.class.english_name}." if MacOS.undeletable?(target)
|
raise CaskError, "Cannot remove undeletable #{self.class.english_name}." if MacOS.undeletable?(target)
|
||||||
|
|
||||||
return unless Utils.path_occupied?(target)
|
return unless Utils.path_occupied?(target)
|
||||||
|
|
||||||
if upgrade && target.directory?
|
if upgrade_or_reinstall && target.directory?
|
||||||
# If an app folder is deleted, macOS considers the app uninstalled and removes some data.
|
# If an app folder is deleted, macOS considers the app uninstalled and removes some data.
|
||||||
# Remove only the contents to handle this case.
|
# Remove only the contents to handle this case.
|
||||||
target.children.each do |child|
|
target.children.each do |child|
|
||||||
|
@ -41,6 +41,7 @@ module Cask
|
|||||||
force: force,
|
force: force,
|
||||||
skip_cask_deps: skip_cask_deps,
|
skip_cask_deps: skip_cask_deps,
|
||||||
require_sha: require_sha,
|
require_sha: require_sha,
|
||||||
|
reinstall: true,
|
||||||
quarantine: quarantine,
|
quarantine: quarantine,
|
||||||
zap: zap,
|
zap: zap,
|
||||||
}.compact
|
}.compact
|
||||||
@ -48,7 +49,7 @@ module Cask
|
|||||||
options[:quarantine] = true if options[:quarantine].nil?
|
options[:quarantine] = true if options[:quarantine].nil?
|
||||||
|
|
||||||
casks.each do |cask|
|
casks.each do |cask|
|
||||||
Installer.new(cask, **options).reinstall
|
Installer.new(cask, **options).install
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -22,7 +22,7 @@ module Cask
|
|||||||
|
|
||||||
def initialize(cask, command: SystemCommand, force: false, adopt: false,
|
def initialize(cask, command: SystemCommand, force: false, adopt: false,
|
||||||
skip_cask_deps: false, binaries: true, verbose: false,
|
skip_cask_deps: false, binaries: true, verbose: false,
|
||||||
zap: false, require_sha: false, upgrade: false,
|
zap: false, require_sha: false, upgrade: false, reinstall: false,
|
||||||
installed_as_dependency: false, quarantine: true,
|
installed_as_dependency: false, quarantine: true,
|
||||||
verify_download_integrity: true, quiet: false)
|
verify_download_integrity: true, quiet: false)
|
||||||
@cask = cask
|
@cask = cask
|
||||||
@ -34,7 +34,7 @@ module Cask
|
|||||||
@verbose = verbose
|
@verbose = verbose
|
||||||
@zap = zap
|
@zap = zap
|
||||||
@require_sha = require_sha
|
@require_sha = require_sha
|
||||||
@reinstall = false
|
@reinstall = reinstall
|
||||||
@upgrade = upgrade
|
@upgrade = upgrade
|
||||||
@installed_as_dependency = installed_as_dependency
|
@installed_as_dependency = installed_as_dependency
|
||||||
@quarantine = quarantine
|
@quarantine = quarantine
|
||||||
@ -143,17 +143,11 @@ on_request: true)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def reinstall
|
|
||||||
odebug "Cask::Installer#reinstall"
|
|
||||||
@reinstall = true
|
|
||||||
install
|
|
||||||
end
|
|
||||||
|
|
||||||
def uninstall_existing_cask
|
def uninstall_existing_cask
|
||||||
return unless @cask.installed?
|
return unless @cask.installed?
|
||||||
|
|
||||||
# Always force uninstallation, ignore method parameter
|
# Always force uninstallation, ignore method parameter
|
||||||
cask_installer = Installer.new(@cask, verbose: verbose?, force: true, upgrade: upgrade?)
|
cask_installer = Installer.new(@cask, verbose: verbose?, force: true, upgrade: upgrade?, reinstall: true)
|
||||||
zap? ? cask_installer.zap : cask_installer.uninstall
|
zap? ? cask_installer.zap : cask_installer.uninstall
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -234,7 +228,8 @@ on_request: true)
|
|||||||
|
|
||||||
next if artifact.is_a?(Artifact::Binary) && !binaries?
|
next if artifact.is_a?(Artifact::Binary) && !binaries?
|
||||||
|
|
||||||
artifact.install_phase(command: @command, verbose: verbose?, adopt: adopt?, force: force?, upgrade: upgrade?)
|
artifact.install_phase(command: @command, verbose: verbose?, adopt: adopt?, force: force?,
|
||||||
|
upgrade_or_reinstall: upgrade? || reinstall?)
|
||||||
already_installed_artifacts.unshift(artifact)
|
already_installed_artifacts.unshift(artifact)
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -461,7 +456,11 @@ on_request: true)
|
|||||||
if artifact.respond_to?(:uninstall_phase)
|
if artifact.respond_to?(:uninstall_phase)
|
||||||
odebug "Uninstalling artifact of class #{artifact.class}"
|
odebug "Uninstalling artifact of class #{artifact.class}"
|
||||||
artifact.uninstall_phase(
|
artifact.uninstall_phase(
|
||||||
command: @command, verbose: verbose?, skip: clear, force: force?, upgrade: upgrade?,
|
command: @command,
|
||||||
|
verbose: verbose?,
|
||||||
|
skip: clear,
|
||||||
|
force: force?,
|
||||||
|
upgrade_or_reinstall: upgrade? || reinstall?,
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -469,7 +468,11 @@ on_request: true)
|
|||||||
|
|
||||||
odebug "Post-uninstalling artifact of class #{artifact.class}"
|
odebug "Post-uninstalling artifact of class #{artifact.class}"
|
||||||
artifact.post_uninstall_phase(
|
artifact.post_uninstall_phase(
|
||||||
command: @command, verbose: verbose?, skip: clear, force: force?, upgrade: upgrade?,
|
command: @command,
|
||||||
|
verbose: verbose?,
|
||||||
|
skip: clear,
|
||||||
|
force: force?,
|
||||||
|
upgrade_or_reinstall: upgrade? || reinstall?,
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -323,13 +323,13 @@ describe Cask::Artifact::App, :cask do
|
|||||||
inode = target_path.stat.ino
|
inode = target_path.stat.ino
|
||||||
expect(contents_path).to exist
|
expect(contents_path).to exist
|
||||||
|
|
||||||
app.uninstall_phase(command: command, force: force, upgrade: true)
|
app.uninstall_phase(command: command, force: force, upgrade_or_reinstall: true)
|
||||||
|
|
||||||
expect(target_path).to exist
|
expect(target_path).to exist
|
||||||
expect(target_path.children).to be_empty
|
expect(target_path.children).to be_empty
|
||||||
expect(contents_path).not_to exist
|
expect(contents_path).not_to exist
|
||||||
|
|
||||||
app.install_phase(command: command, adopt: adopt, force: force, upgrade: true)
|
app.install_phase(command: command, adopt: adopt, force: force, upgrade_or_reinstall: true)
|
||||||
expect(target_path).to exist
|
expect(target_path).to exist
|
||||||
expect(target_path.stat.ino).to eq(inode)
|
expect(target_path.stat.ino).to eq(inode)
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user