Always chmod +x binary stanzas.

This commit is contained in:
Markus Reiter 2017-03-08 16:35:02 +01:00
parent ef02414888
commit 88bc68f3b5
3 changed files with 19 additions and 1 deletions

View File

@ -6,6 +6,11 @@ module Hbc
def install_phase def install_phase
super if CLI.binaries? super if CLI.binaries?
end end
def link(artifact_spec)
super(artifact_spec)
FileUtils.chmod "+x", source
end
end end
end end
end end

View File

@ -35,7 +35,7 @@ module Hbc
altnames = "(#{altnames})" altnames = "(#{altnames})"
# Some packges are shipped as u=rx (e.g. Bitcoin Core) # Some packges are shipped as u=rx (e.g. Bitcoin Core)
@command.run!("/bin/chmod", args: ["--", "u=rwx", file.to_s, file.realpath.to_s]) @command.run!("/bin/chmod", args: ["--", "u+rw", file.to_s, file.realpath.to_s])
@command.run!("/usr/bin/xattr", @command.run!("/usr/bin/xattr",
args: ["-w", ALT_NAME_ATTRIBUTE, altnames, file.to_s], args: ["-w", ALT_NAME_ATTRIBUTE, altnames, file.to_s],

View File

@ -9,9 +9,11 @@ describe Hbc::Artifact::Binary, :cask do
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
end end
after(:each) do after(:each) do
FileUtils.rm expected_path if expected_path.exist? FileUtils.rm expected_path if expected_path.exist?
end end
@ -24,6 +26,17 @@ 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
expect(FileUtils).to receive(:chmod).with("+x", cask.staged_path.join("binary"))
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
it "avoids clobbering an existing binary by linking over it" do it "avoids clobbering an existing binary by linking over it" do
FileUtils.touch expected_path FileUtils.touch expected_path