Stage to a different directory if upgrading Casks w/version :latest
This commit is contained in:
parent
10a0662dc0
commit
f3355b2a2c
@ -55,14 +55,14 @@ module Hbc
|
|||||||
|
|
||||||
new_cask_installer.fetch
|
new_cask_installer.fetch
|
||||||
|
|
||||||
new_cask_installer.stage
|
|
||||||
|
|
||||||
# Move the old Cask's artifacts back to staging
|
# Move the old Cask's artifacts back to staging
|
||||||
old_cask_installer.start_upgrade
|
old_cask_installer.start_upgrade
|
||||||
# And flag it so in case of error
|
# And flag it so in case of error
|
||||||
started_upgrade = true
|
started_upgrade = true
|
||||||
|
|
||||||
# Install the new Cask
|
# Install the new Cask
|
||||||
|
new_cask_installer.stage
|
||||||
|
|
||||||
new_cask_installer.install_artifacts
|
new_cask_installer.install_artifacts
|
||||||
new_artifacts_installed = true
|
new_artifacts_installed = true
|
||||||
|
|
||||||
|
|||||||
@ -378,10 +378,26 @@ module Hbc
|
|||||||
|
|
||||||
disable_accessibility_access
|
disable_accessibility_access
|
||||||
uninstall_artifacts
|
uninstall_artifacts
|
||||||
|
backup if version_is_latest?
|
||||||
|
end
|
||||||
|
|
||||||
|
def backup
|
||||||
|
@cask.staged_path.rename backup_path(@cask.staged_path)
|
||||||
|
end
|
||||||
|
|
||||||
|
def restore_backup
|
||||||
|
path = backup_path(@cask.staged_path)
|
||||||
|
|
||||||
|
return unless path.directory?
|
||||||
|
|
||||||
|
Pathname.new(@cask.staged_path).rmtree if @cask.staged_path.exist?
|
||||||
|
|
||||||
|
path.rename @cask.staged_path
|
||||||
end
|
end
|
||||||
|
|
||||||
def revert_upgrade
|
def revert_upgrade
|
||||||
opoo "Reverting upgrade for Cask #{@cask}"
|
opoo "Reverting upgrade for Cask #{@cask}"
|
||||||
|
restore_backup if version_is_latest?
|
||||||
install_artifacts
|
install_artifacts
|
||||||
enable_accessibility_access
|
enable_accessibility_access
|
||||||
end
|
end
|
||||||
@ -420,6 +436,14 @@ module Hbc
|
|||||||
purge_caskroom_path
|
purge_caskroom_path
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def backup_path(path)
|
||||||
|
Pathname.new "#{path}.upgrading" unless path.nil?
|
||||||
|
end
|
||||||
|
|
||||||
|
def version_is_latest?
|
||||||
|
@cask.versions.include?("latest")
|
||||||
|
end
|
||||||
|
|
||||||
def gain_permissions_remove(path)
|
def gain_permissions_remove(path)
|
||||||
Utils.gain_permissions_remove(path, command: @command)
|
Utils.gain_permissions_remove(path, command: @command)
|
||||||
end
|
end
|
||||||
@ -428,11 +452,15 @@ module Hbc
|
|||||||
ohai "Purging files for version #{@cask.version} of Cask #{@cask}"
|
ohai "Purging files for version #{@cask.version} of Cask #{@cask}"
|
||||||
|
|
||||||
# versioned staged distribution
|
# versioned staged distribution
|
||||||
gain_permissions_remove(@cask.staged_path) if !@cask.staged_path.nil? && @cask.staged_path.exist?
|
staged_path = version_is_latest? ?
|
||||||
|
backup_path(@cask.staged_path) : @cask.staged_path
|
||||||
|
|
||||||
|
gain_permissions_remove(staged_path) if !staged_path.nil? && staged_path.exist?
|
||||||
|
|
||||||
# Homebrew-Cask metadata
|
# Homebrew-Cask metadata
|
||||||
if @cask.metadata_versioned_path.respond_to?(:children) &&
|
if @cask.metadata_versioned_path.respond_to?(:children) &&
|
||||||
@cask.metadata_versioned_path.exist?
|
@cask.metadata_versioned_path.exist? &&
|
||||||
|
!version_is_latest?
|
||||||
@cask.metadata_versioned_path.children.each do |subdir|
|
@cask.metadata_versioned_path.children.each do |subdir|
|
||||||
unless PERSISTENT_METADATA_SUBDIRS.include?(subdir.basename)
|
unless PERSISTENT_METADATA_SUBDIRS.include?(subdir.basename)
|
||||||
gain_permissions_remove(subdir)
|
gain_permissions_remove(subdir)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user