-
-
Notifications
You must be signed in to change notification settings - Fork 9.9k
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
Properly upgrade Casks with version :latest #3492
Changes from 6 commits
10a0662
f3355b2
8386b93
2ff114b
9458e98
9227c8f
5840b2f
63961ac
657d4ea
ab62be5
96187ad
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -31,7 +31,7 @@ def initialize(cask, command: SystemCommand, force: false, skip_cask_deps: false | |
@upgrade = upgrade | ||
end | ||
|
||
attr_predicate :binaries?, :force?, :skip_cask_deps?, :require_sha?, :upgrade?, :verbose? | ||
attr_predicate :binaries?, :force?, :skip_cask_deps?, :require_sha?, :upgrade?, :verbose?, :backed_up? | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is not needed anymore. |
||
|
||
def self.print_caveats(cask) | ||
odebug "Printing caveats" | ||
|
@@ -378,16 +378,30 @@ def start_upgrade | |
|
||
disable_accessibility_access | ||
uninstall_artifacts | ||
backup | ||
end | ||
|
||
def backup | ||
@cask.staged_path.rename backup_path | ||
end | ||
|
||
def restore_backup | ||
return unless backup_path.directory? | ||
|
||
Pathname.new(@cask.staged_path).rmtree if @cask.staged_path.exist? | ||
|
||
backup_path.rename @cask.staged_path | ||
end | ||
|
||
def revert_upgrade | ||
opoo "Reverting upgrade for Cask #{@cask}" | ||
restore_backup | ||
install_artifacts | ||
enable_accessibility_access | ||
end | ||
|
||
def finalize_upgrade | ||
purge_versioned_files | ||
purge_backed_versioned_files | ||
|
||
puts summary | ||
end | ||
|
@@ -420,19 +434,43 @@ def zap | |
purge_caskroom_path | ||
end | ||
|
||
def backup_path | ||
return nil if @cask.staged_path.nil? | ||
Pathname.new "#{@cask.staged_path}.upgrading" | ||
end | ||
|
||
def version_is_latest? | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This can now be removed. |
||
@cask.versions.include?("latest") | ||
end | ||
|
||
def gain_permissions_remove(path) | ||
Utils.gain_permissions_remove(path, command: @command) | ||
end | ||
|
||
def purge_backed_versioned_files | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
ohai "Purging files for version #{@cask.version} of Cask #{@cask}" | ||
|
||
# versioned staged distribution | ||
gain_permissions_remove(backup_path) if !backup_path.nil? && backup_path.exist? | ||
|
||
# Homebrew-Cask metadata | ||
purge_metadata | ||
end | ||
|
||
def purge_versioned_files | ||
ohai "Purging files for version #{@cask.version} of Cask #{@cask}" | ||
|
||
# versioned staged distribution | ||
gain_permissions_remove(@cask.staged_path) if [email protected]_path.nil? && @cask.staged_path.exist? | ||
|
||
# Homebrew-Cask metadata | ||
purge_metadata | ||
end | ||
|
||
def purge_metadata | ||
if @cask.metadata_versioned_path.respond_to?(:children) && | ||
@cask.metadata_versioned_path.exist? | ||
@cask.metadata_versioned_path.exist? && | ||
!(upgrade? && version_is_latest?) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do we still need There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, the backup mechanism doesn't involve the Cask's metadata; if the version is There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. On second thoughts, I'll just go ahead with two fully separate methods and get rid of that line. |
||
@cask.metadata_versioned_path.children.each do |subdir| | ||
unless PERSISTENT_METADATA_SUBDIRS.include?(subdir.basename) | ||
gain_permissions_remove(subdir) | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
cask 'version-latest' do | ||
version :latest | ||
sha256 :no_check | ||
|
||
url "file://#{TEST_FIXTURE_DIR}/cask/caffeines.zip" | ||
homepage 'http://example.com/local-caffeine' | ||
|
||
app 'Caffeine Mini.app' | ||
app 'Caffeine Pro.app' | ||
end |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
cask 'version-latest' do | ||
version :latest | ||
sha256 :no_check | ||
|
||
url "file://#{TEST_FIXTURE_DIR}/cask/caffeines.zip" | ||
homepage 'http://example.com/local-caffeine' | ||
|
||
app 'Caffeine Mini.app' | ||
app 'Caffeine Pro.app' | ||
end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove this completely. We don‘t need to add this when moving it back, actually.