Skip to content
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

Install pkg before app. #6642

Merged
merged 2 commits into from Oct 25, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
8 changes: 5 additions & 3 deletions Library/Homebrew/cask/artifact/abstract_artifact.rb
Expand Up @@ -50,6 +50,11 @@ def <=>(other)
# depend on other artifacts still being installed.
Uninstall,
Installer,
# `pkg` should be run before `binary`, so
# targets are created prior to linking.
# `pkg` should be run before `app`, since an `app` could
# contain a nested installer (e.g. `wireshark`).
Pkg,
[
App,
Suite,
Expand All @@ -67,9 +72,6 @@ def <=>(other)
Vst3Plugin,
ScreenSaver,
],
# `pkg` should be run before `binary`, so
# targets are created prior to linking.
Pkg,
Binary,
Manpage,
PostflightBlock,
Expand Down
4 changes: 4 additions & 0 deletions Library/Homebrew/cask/artifact/moved.rb
Expand Up @@ -54,10 +54,14 @@ def move(force: false, command: nil, **options)
command.run!("/bin/mv", args: [source, target], sudo: true)
end

FileUtils.ln_sf target, source

add_altname_metadata(target, source.basename, command: command)
end

def move_back(skip: false, force: false, command: nil, **options)
FileUtils.rm source if source.symlink? && source.dirname.join(source.readlink) == target

if Utils.path_occupied?(source)
message = "It seems there is already #{self.class.english_article} " \
"#{self.class.english_name} at '#{source}'"
Expand Down
11 changes: 9 additions & 2 deletions Library/Homebrew/cask/installer.rb
Expand Up @@ -94,6 +94,8 @@ def install
fetch
uninstall_existing_cask if reinstall?

backup if force? && @cask.staged_path.exist? && @cask.metadata_versioned_path.exist?

oh1 "Installing Cask #{Formatter.identifier(@cask)}"
opoo "macOS's Gatekeeper has been disabled for this Cask" unless quarantine?
stage
Expand All @@ -104,7 +106,12 @@ def install

::Utils::Analytics.report_event("cask_install", @cask.token) unless @cask.tap&.private?

purge_backed_up_versioned_files

puts summary
rescue
restore_backup
raise
end

def check_conflicts
Expand Down Expand Up @@ -411,6 +418,8 @@ def revert_upgrade
end

def finalize_upgrade
ohai "Purging files for version #{@cask.version} of Cask #{@cask}"

purge_backed_up_versioned_files

puts summary
Expand Down Expand Up @@ -471,8 +480,6 @@ def gain_permissions_remove(path)
end

def purge_backed_up_versioned_files
ohai "Purging files for version #{@cask.version} of Cask #{@cask}"

# versioned staged distribution
gain_permissions_remove(backup_path) if backup_path&.exist?

Expand Down
6 changes: 3 additions & 3 deletions Library/Homebrew/test/cask/artifact/alt_target_spec.rb
Expand Up @@ -24,7 +24,7 @@
install_phase

expect(target_path).to be_a_directory
expect(source_path).not_to exist
expect(source_path).to be_a_symlink
end

describe "when app is in a subdirectory" do
Expand All @@ -45,7 +45,7 @@
install_phase

expect(target_path).to be_a_directory
expect(appsubdir.join("Caffeine.app")).not_to exist
expect(appsubdir.join("Caffeine.app")).to be_a_symlink
end
end

Expand All @@ -56,7 +56,7 @@
install_phase

expect(target_path).to be_a_directory
expect(source_path).not_to exist
expect(source_path).to be_a_symlink

expect(cask.config.appdir.join("Caffeine Deluxe.app")).not_to exist
expect(cask.staged_path.join("Caffeine Deluxe.app")).to be_a_directory
Expand Down
12 changes: 6 additions & 6 deletions Library/Homebrew/test/cask/artifact/app_spec.rb
Expand Up @@ -21,7 +21,7 @@
install_phase

expect(target_path).to be_a_directory
expect(source_path).not_to exist
expect(source_path).to be_a_symlink
end

describe "when app is in a subdirectory" do
Expand All @@ -42,7 +42,7 @@
install_phase

expect(target_path).to be_a_directory
expect(appsubdir.join("Caffeine.app")).not_to exist
expect(appsubdir.join("Caffeine.app")).to be_a_symlink
end
end

Expand All @@ -53,7 +53,7 @@
install_phase

expect(target_path).to be_a_directory
expect(source_path).not_to exist
expect(source_path).to be_a_symlink

expect(cask.config.appdir.join("Caffeine Deluxe.app")).not_to exist
expect(cask.staged_path.join("Caffeine Deluxe.app")).to exist
Expand Down Expand Up @@ -100,7 +100,7 @@
.to output(stdout).to_stdout
.and output(stderr).to_stderr

expect(source_path).not_to exist
expect(source_path).to be_a_symlink
expect(target_path).to be_a_directory

contents_path = target_path.join("Contents/Info.plist")
Expand Down Expand Up @@ -148,7 +148,7 @@
.to output(stdout).to_stdout
.and output(stderr).to_stderr

expect(source_path).not_to exist
expect(source_path).to be_a_symlink
expect(target_path).to be_a_directory

contents_path = target_path.join("Contents/Info.plist")
Expand Down Expand Up @@ -191,7 +191,7 @@
.to output(stdout).to_stdout
.and output(stderr).to_stderr

expect(source_path).not_to exist
expect(source_path).to be_a_symlink
expect(target_path).to be_a_directory

contents_path = target_path.join("Contents/Info.plist")
Expand Down
Expand Up @@ -30,7 +30,7 @@
install_phase.call

expect(target_path).to be_a_directory
expect(source_path).not_to exist
expect(source_path).to be_a_symlink
end

it "avoids clobbering an existing artifact" do
Expand Down
13 changes: 8 additions & 5 deletions Library/Homebrew/test/cask/artifact/two_apps_correct_spec.rb
Expand Up @@ -24,23 +24,26 @@
install_phase

expect(target_path_mini).to be_a_directory
expect(source_path_mini).not_to exist
expect(source_path_mini).to be_a_symlink

expect(target_path_pro).to be_a_directory
expect(source_path_pro).not_to exist
expect(source_path_pro).to be_a_symlink
end

describe "when apps are in a subdirectory" do
let(:cask) { Cask::CaskLoader.load(cask_path("with-two-apps-subdir")) }

let(:source_path_mini) { cask.staged_path.join("Caffeines", "Caffeine Mini.app") }
let(:source_path_pro) { cask.staged_path.join("Caffeines", "Caffeine Pro.app") }

it "installs both apps using the proper target directory" do
install_phase

expect(target_path_mini).to be_a_directory
expect(source_path_mini).not_to exist
expect(source_path_mini).to be_a_symlink

expect(target_path_pro).to be_a_directory
expect(source_path_pro).not_to exist
expect(source_path_pro).to be_a_symlink
end
end

Expand All @@ -50,7 +53,7 @@
install_phase

expect(target_path_mini).to be_a_directory
expect(source_path_mini).not_to exist
expect(source_path_mini).to be_a_symlink

expect(cask.config.appdir.join("Caffeine Deluxe.app")).not_to exist
expect(cask.staged_path.join("Caffeine Deluxe.app")).to exist
Expand Down