Commit ce5b43cd authored by Sebastian Reitenbach's avatar Sebastian Reitenbach Committed by Stan Hu

Fix gitaly install on systems where env doesn't support the -u flag

At least on OpenBSD, /usr/bin/env doesn't support the -u flag
and bails out. So first check if env supports it, and only use it,
when it supports it.

This makes installing gitaly work for me on OpenBSD.
parent 718a986d
...@@ -15,8 +15,7 @@ Usage: rake "gitlab:gitaly:install[/installation/dir,/storage/path]") ...@@ -15,8 +15,7 @@ Usage: rake "gitlab:gitaly:install[/installation/dir,/storage/path]")
checkout_or_clone_version(version: version, repo: args.repo, target_dir: args.dir) checkout_or_clone_version(version: version, repo: args.repo, target_dir: args.dir)
command = %w[/usr/bin/env -u RUBYOPT -u BUNDLE_GEMFILE] command = []
_, status = Gitlab::Popen.popen(%w[which gmake]) _, status = Gitlab::Popen.popen(%w[which gmake])
command << (status.zero? ? 'gmake' : 'make') command << (status.zero? ? 'gmake' : 'make')
...@@ -31,7 +30,7 @@ Usage: rake "gitlab:gitaly:install[/installation/dir,/storage/path]") ...@@ -31,7 +30,7 @@ Usage: rake "gitlab:gitaly:install[/installation/dir,/storage/path]")
Dir.chdir(args.dir) do Dir.chdir(args.dir) do
# In CI we run scripts/gitaly-test-build instead of this command # In CI we run scripts/gitaly-test-build instead of this command
unless ENV['CI'].present? unless ENV['CI'].present?
Bundler.with_original_env { run_command!(command) } Bundler.with_original_env { Gitlab::Popen.popen(command, nil, { "RUBYOPT" => nil, "BUNDLE_GEMFILE" => nil }) }
end end
end end
end end
......
...@@ -53,8 +53,6 @@ describe 'gitlab:gitaly namespace rake task' do ...@@ -53,8 +53,6 @@ describe 'gitlab:gitaly namespace rake task' do
end end
describe 'gmake/make' do describe 'gmake/make' do
let(:command_preamble) { %w[/usr/bin/env -u RUBYOPT -u BUNDLE_GEMFILE] }
before do before do
stub_env('CI', false) stub_env('CI', false)
FileUtils.mkdir_p(clone_path) FileUtils.mkdir_p(clone_path)
...@@ -69,7 +67,7 @@ describe 'gitlab:gitaly namespace rake task' do ...@@ -69,7 +67,7 @@ describe 'gitlab:gitaly namespace rake task' do
it 'calls gmake in the gitaly directory' do it 'calls gmake in the gitaly directory' do
expect(Gitlab::Popen).to receive(:popen).with(%w[which gmake]).and_return(['/usr/bin/gmake', 0]) expect(Gitlab::Popen).to receive(:popen).with(%w[which gmake]).and_return(['/usr/bin/gmake', 0])
expect(main_object).to receive(:run_command!).with(command_preamble + %w[gmake]).and_return(true) expect(Gitlab::Popen).to receive(:popen).with(%w[gmake], nil, { "BUNDLE_GEMFILE" => nil, "RUBYOPT" => nil }).and_return(true)
subject subject
end end
...@@ -82,7 +80,7 @@ describe 'gitlab:gitaly namespace rake task' do ...@@ -82,7 +80,7 @@ describe 'gitlab:gitaly namespace rake task' do
end end
it 'calls make in the gitaly directory' do it 'calls make in the gitaly directory' do
expect(main_object).to receive(:run_command!).with(command_preamble + %w[make]).and_return(true) expect(Gitlab::Popen).to receive(:popen).with(%w[make], nil, { "BUNDLE_GEMFILE" => nil, "RUBYOPT" => nil }).and_return(true)
subject subject
end end
...@@ -99,7 +97,7 @@ describe 'gitlab:gitaly namespace rake task' do ...@@ -99,7 +97,7 @@ describe 'gitlab:gitaly namespace rake task' do
end end
it 'calls make in the gitaly directory with --no-deployment flag for bundle' do it 'calls make in the gitaly directory with --no-deployment flag for bundle' do
expect(main_object).to receive(:run_command!).with(command_preamble + command).and_return(true) expect(Gitlab::Popen).to receive(:popen).with(command, nil, { "BUNDLE_GEMFILE" => nil, "RUBYOPT" => nil }).and_return(true)
subject subject
end end
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment