Merge pull request #5804 from reitermarkus/executable-path
Use same logic for `installer script:` and `uninstall script:`.
This commit is contained in:
commit
0b2eaa29fe
@ -20,6 +20,24 @@ module Cask
|
|||||||
@dirmethod ||= "#{dsl_key}dir".to_sym
|
@dirmethod ||= "#{dsl_key}dir".to_sym
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def staged_path_join_executable(path)
|
||||||
|
path = Pathname(path)
|
||||||
|
|
||||||
|
absolute_path = if path.absolute?
|
||||||
|
path
|
||||||
|
else
|
||||||
|
cask.staged_path.join(path)
|
||||||
|
end
|
||||||
|
|
||||||
|
FileUtils.chmod "+x", absolute_path if absolute_path.exist? && !absolute_path.executable?
|
||||||
|
|
||||||
|
if absolute_path.exist?
|
||||||
|
absolute_path
|
||||||
|
else
|
||||||
|
path
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
def <=>(other)
|
def <=>(other)
|
||||||
return unless other.class < AbstractArtifact
|
return unless other.class < AbstractArtifact
|
||||||
return 0 if self.class == other.class
|
return 0 if self.class == other.class
|
||||||
|
@ -243,9 +243,10 @@ module Cask
|
|||||||
ohai "Running uninstall script #{executable}"
|
ohai "Running uninstall script #{executable}"
|
||||||
raise CaskInvalidError.new(cask, "#{stanza} :#{directive_name} without :executable.") if executable.nil?
|
raise CaskInvalidError.new(cask, "#{stanza} :#{directive_name} without :executable.") if executable.nil?
|
||||||
|
|
||||||
executable_path = cask.staged_path.join(executable)
|
executable_path = staged_path_join_executable(executable)
|
||||||
|
|
||||||
unless executable_path.exist?
|
if (executable_path.absolute? && !executable_path.exist?) ||
|
||||||
|
(!executable_path.absolute? && (which executable_path).nil?)
|
||||||
message = "uninstall script #{executable} does not exist"
|
message = "uninstall script #{executable} does not exist"
|
||||||
raise CaskError, "#{message}." unless force
|
raise CaskError, "#{message}." unless force
|
||||||
|
|
||||||
@ -253,7 +254,6 @@ module Cask
|
|||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
command.run("/bin/chmod", args: ["--", "+x", executable_path])
|
|
||||||
command.run(executable_path, script_arguments)
|
command.run(executable_path, script_arguments)
|
||||||
sleep 1
|
sleep 1
|
||||||
end
|
end
|
||||||
|
@ -26,22 +26,10 @@ module Cask
|
|||||||
def install_phase(command: nil, **_)
|
def install_phase(command: nil, **_)
|
||||||
ohai "Running #{self.class.dsl_key} script '#{path}'"
|
ohai "Running #{self.class.dsl_key} script '#{path}'"
|
||||||
|
|
||||||
absolute_path = if path.absolute?
|
executable_path = staged_path_join_executable(path)
|
||||||
path
|
|
||||||
else
|
|
||||||
cask.staged_path.join(path)
|
|
||||||
end
|
|
||||||
|
|
||||||
FileUtils.chmod "+x", absolute_path if absolute_path.exist? && !absolute_path.executable?
|
|
||||||
|
|
||||||
executable = if absolute_path.exist?
|
|
||||||
absolute_path
|
|
||||||
else
|
|
||||||
path
|
|
||||||
end
|
|
||||||
|
|
||||||
command.run!(
|
command.run!(
|
||||||
executable,
|
executable_path,
|
||||||
**args,
|
**args,
|
||||||
env: { "PATH" => PATH.new(
|
env: { "PATH" => PATH.new(
|
||||||
HOMEBREW_PREFIX/"bin", HOMEBREW_PREFIX/"sbin", ENV["PATH"]
|
HOMEBREW_PREFIX/"bin", HOMEBREW_PREFIX/"sbin", ENV["PATH"]
|
||||||
|
@ -228,11 +228,6 @@ shared_examples "#uninstall_phase or #zap_phase" do
|
|||||||
it "is supported" do
|
it "is supported" do
|
||||||
allow(fake_system_command).to receive(:run).with(any_args).and_call_original
|
allow(fake_system_command).to receive(:run).with(any_args).and_call_original
|
||||||
|
|
||||||
expect(fake_system_command).to receive(:run).with(
|
|
||||||
"/bin/chmod",
|
|
||||||
args: ["--", "+x", script_pathname],
|
|
||||||
)
|
|
||||||
|
|
||||||
expect(fake_system_command).to receive(:run).with(
|
expect(fake_system_command).to receive(:run).with(
|
||||||
cask.staged_path.join("MyFancyPkg", "FancyUninstaller.tool"),
|
cask.staged_path.join("MyFancyPkg", "FancyUninstaller.tool"),
|
||||||
args: ["--please"],
|
args: ["--please"],
|
||||||
|
Loading…
x
Reference in New Issue
Block a user