Commit 5f864cf3fa78f27d68b55b9b5f82bf7e7e8d36dd

Authored by Jacob Vosmaer
1 parent 6dec05ff

Create gitlab-shell wrappers using ERB

config/software/gitlab-shell.rb
@@ -28,18 +28,10 @@ build do @@ -28,18 +28,10 @@ build do
28 block do 28 block do
29 env_shebang = "#!/usr/bin/env ruby" 29 env_shebang = "#!/usr/bin/env ruby"
30 `grep -r -l '^#{env_shebang}' #{project_dir}`.split("\n").each do |ruby_script| 30 `grep -r -l '^#{env_shebang}' #{project_dir}`.split("\n").each do |ruby_script|
31 - File.open(ruby_script, "r+") do |file|  
32 - script = file.read  
33 - file.rewind  
34 - file.truncate(0)  
35 - file.print <<-EOH  
36 -#!/opt/gitlab/embedded/bin/ruby  
37 -# Fix the PATH so that gitlab-shell can find git-upload-pack and friends.  
38 -ENV['PATH'] = '/opt/gitlab/bin:/opt/gitlab/embedded/bin:' + ENV['PATH']  
39 -  
40 - EOH  
41 - file.print script.gsub(/^#{env_shebang}\s*/, "")  
42 - end 31 + script = File.read(ruby_script)
  32 + erb :dest => ruby_script,
  33 + :source => "ruby_script_wrapper.erb",
  34 + :mode => 0755
43 end 35 end
44 end 36 end
45 command "mkdir -p #{install_dir}/embedded/service/gitlab-shell" 37 command "mkdir -p #{install_dir}/embedded/service/gitlab-shell"
config/templates/gitlab-shell/ruby_script_wrapper.erb 0 → 100644
@@ -0,0 +1,5 @@ @@ -0,0 +1,5 @@
  1 +#!<%= install_dir %>/embedded/bin/ruby
  2 +# Fix the PATH so that gitlab-shell can find git-upload-pack and friends.
  3 +ENV['PATH'] = '<%= install_dir %>/bin:<%= install_dir %>/embedded/bin:' + ENV['PATH']
  4 +
  5 +<%= script %>