Merge pull request #2512 from commitay/cask-binary
Replace `FileUtils.chmod` with `/bin/chmod` for cask binaries.
This commit is contained in:
commit
cd110b467d
@ -9,7 +9,12 @@ module Hbc
|
|||||||
|
|
||||||
def link
|
def link
|
||||||
super
|
super
|
||||||
FileUtils.chmod "+x", source
|
return if source.executable?
|
||||||
|
if source.writable?
|
||||||
|
FileUtils.chmod "+x", source
|
||||||
|
else
|
||||||
|
@command.run!("/bin/chmod", args: ["+x", source], sudo: true)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@ -6,9 +6,7 @@ describe Hbc::Artifact::Binary, :cask do
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
}
|
}
|
||||||
let(:expected_path) {
|
let(:expected_path) { Hbc.binarydir.join("binary") }
|
||||||
Hbc.binarydir.join("binary")
|
|
||||||
}
|
|
||||||
|
|
||||||
before(:each) do
|
before(:each) do
|
||||||
Hbc.binarydir.mkpath
|
Hbc.binarydir.mkpath
|
||||||
@ -26,15 +24,28 @@ describe Hbc::Artifact::Binary, :cask do
|
|||||||
expect(expected_path.readlink).to exist
|
expect(expected_path.readlink).to exist
|
||||||
end
|
end
|
||||||
|
|
||||||
it "makes the binary executable" do
|
context "when the binary is not executable" do
|
||||||
expect(FileUtils).to receive(:chmod).with("+x", cask.staged_path.join("binary"))
|
let(:cask) {
|
||||||
|
Hbc::CaskLoader.load_from_file(TEST_FIXTURE_DIR/"cask/Casks/with-non-executable-binary.rb").tap do |cask|
|
||||||
|
shutup do
|
||||||
|
InstallHelper.install_without_artifacts(cask)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
}
|
||||||
|
|
||||||
shutup do
|
let(:expected_path) { Hbc.binarydir.join("naked_non_executable") }
|
||||||
Hbc::Artifact::Binary.new(cask).install_phase
|
|
||||||
|
it "makes the binary executable" do
|
||||||
|
expect(FileUtils).to receive(:chmod)
|
||||||
|
.with("+x", cask.staged_path.join("naked_non_executable")).and_call_original
|
||||||
|
|
||||||
|
shutup do
|
||||||
|
Hbc::Artifact::Binary.new(cask).install_phase
|
||||||
|
end
|
||||||
|
|
||||||
|
expect(expected_path).to be_a_symlink
|
||||||
|
expect(expected_path.readlink).to be_executable
|
||||||
end
|
end
|
||||||
|
|
||||||
expect(expected_path).to be_a_symlink
|
|
||||||
expect(expected_path.readlink).to be_executable
|
|
||||||
end
|
end
|
||||||
|
|
||||||
it "avoids clobbering an existing binary by linking over it" do
|
it "avoids clobbering an existing binary by linking over it" do
|
||||||
|
|||||||
@ -0,0 +1,9 @@
|
|||||||
|
cask 'with-non-executable-binary' do
|
||||||
|
version '1.2.3'
|
||||||
|
sha256 'd5b2dfbef7ea28c25f7a77cd7fa14d013d82b626db1d82e00e25822464ba19e2'
|
||||||
|
|
||||||
|
url "file://#{TEST_FIXTURE_DIR}/cask/naked_non_executable"
|
||||||
|
homepage 'http://example.com/with-binary'
|
||||||
|
|
||||||
|
binary "naked_non_executable"
|
||||||
|
end
|
||||||
@ -0,0 +1,2 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
exit 0
|
||||||
Loading…
x
Reference in New Issue
Block a user