From 5f864cf3fa78f27d68b55b9b5f82bf7e7e8d36dd Mon Sep 17 00:00:00 2001 From: Jacob Vosmaer Date: Wed, 12 Feb 2014 17:10:31 +0100 Subject: [PATCH] Create gitlab-shell wrappers using ERB --- config/software/gitlab-shell.rb | 16 ++++------------ config/templates/gitlab-shell/ruby_script_wrapper.erb | 5 +++++ 2 files changed, 9 insertions(+), 12 deletions(-) create mode 100644 config/templates/gitlab-shell/ruby_script_wrapper.erb diff --git a/config/software/gitlab-shell.rb b/config/software/gitlab-shell.rb index 85b4d74..24ab394 100644 --- a/config/software/gitlab-shell.rb +++ b/config/software/gitlab-shell.rb @@ -28,18 +28,10 @@ build do block do env_shebang = "#!/usr/bin/env ruby" `grep -r -l '^#{env_shebang}' #{project_dir}`.split("\n").each do |ruby_script| - File.open(ruby_script, "r+") do |file| - script = file.read - file.rewind - file.truncate(0) - file.print <<-EOH -#!/opt/gitlab/embedded/bin/ruby -# Fix the PATH so that gitlab-shell can find git-upload-pack and friends. -ENV['PATH'] = '/opt/gitlab/bin:/opt/gitlab/embedded/bin:' + ENV['PATH'] - - EOH - file.print script.gsub(/^#{env_shebang}\s*/, "") - end + script = File.read(ruby_script) + erb :dest => ruby_script, + :source => "ruby_script_wrapper.erb", + :mode => 0755 end end command "mkdir -p #{install_dir}/embedded/service/gitlab-shell" diff --git a/config/templates/gitlab-shell/ruby_script_wrapper.erb b/config/templates/gitlab-shell/ruby_script_wrapper.erb new file mode 100644 index 0000000..50ef0ad --- /dev/null +++ b/config/templates/gitlab-shell/ruby_script_wrapper.erb @@ -0,0 +1,5 @@ +#!<%= install_dir %>/embedded/bin/ruby +# Fix the PATH so that gitlab-shell can find git-upload-pack and friends. +ENV['PATH'] = '<%= install_dir %>/bin:<%= install_dir %>/embedded/bin:' + ENV['PATH'] + +<%= script %> -- libgit2 0.21.2