2021-03-11 19:13:27 +05:30
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2017-08-17 22:00:37 +05:30
|
|
|
namespace :gitlab do
|
|
|
|
namespace :gitaly do
|
2020-03-13 15:44:24 +05:30
|
|
|
desc 'GitLab | Gitaly | Install or upgrade gitaly'
|
2018-11-20 20:47:30 +05:30
|
|
|
task :install, [:dir, :storage_path, :repo] => :gitlab_environment do |t, args|
|
2017-08-17 22:00:37 +05:30
|
|
|
warn_user_is_not_gitlab
|
2018-03-17 18:26:18 +05:30
|
|
|
|
2018-11-20 20:47:30 +05:30
|
|
|
unless args.dir.present? && args.storage_path.present?
|
|
|
|
abort %(Please specify the directory where you want to install gitaly and the path for the default storage
|
|
|
|
Usage: rake "gitlab:gitaly:install[/installation/dir,/storage/path]")
|
2017-08-17 22:00:37 +05:30
|
|
|
end
|
2018-03-17 18:26:18 +05:30
|
|
|
|
2017-08-17 22:00:37 +05:30
|
|
|
args.with_defaults(repo: 'https://gitlab.com/gitlab-org/gitaly.git')
|
|
|
|
|
|
|
|
version = Gitlab::GitalyClient.expected_server_version
|
|
|
|
|
2020-05-24 23:13:21 +05:30
|
|
|
checkout_or_clone_version(version: version, repo: args.repo, target_dir: args.dir, clone_opts: %w[--depth 1])
|
2018-03-17 18:26:18 +05:30
|
|
|
|
2018-11-20 20:47:30 +05:30
|
|
|
storage_paths = { 'default' => args.storage_path }
|
2020-04-22 19:07:51 +05:30
|
|
|
Gitlab::SetupHelper::Gitaly.create_configuration(args.dir, storage_paths)
|
2021-04-29 21:17:54 +05:30
|
|
|
|
|
|
|
# In CI we run scripts/gitaly-test-build
|
|
|
|
next if ENV['CI'].present?
|
|
|
|
|
2017-08-17 22:00:37 +05:30
|
|
|
Dir.chdir(args.dir) do
|
2021-04-29 21:17:54 +05:30
|
|
|
Bundler.with_original_env do
|
|
|
|
env = { "RUBYOPT" => nil, "BUNDLE_GEMFILE" => nil }
|
|
|
|
|
|
|
|
if Rails.env.test?
|
|
|
|
env["GEM_HOME"] = Bundler.bundle_path.to_s
|
|
|
|
env["BUNDLE_DEPLOYMENT"] = 'false'
|
|
|
|
end
|
|
|
|
|
|
|
|
Gitlab::Popen.popen([make_cmd], nil, env)
|
2017-09-10 17:25:29 +05:30
|
|
|
end
|
2017-08-17 22:00:37 +05:30
|
|
|
end
|
|
|
|
end
|
2021-04-29 21:17:54 +05:30
|
|
|
|
|
|
|
def make_cmd
|
|
|
|
_, status = Gitlab::Popen.popen(%w[which gmake])
|
|
|
|
status == 0 ? 'gmake' : 'make'
|
|
|
|
end
|
2017-08-17 22:00:37 +05:30
|
|
|
end
|
|
|
|
end
|