diff options
| author | Mike McQuaid | 2014-01-04 12:49:38 +0000 |
|---|---|---|
| committer | Mike McQuaid | 2014-01-04 13:19:20 +0000 |
| commit | cdbc7c9e53dccc17e65bb6f7f7a95a34dadf3b58 (patch) | |
| tree | 0ed0f13419682aa2c7adae48cc3a2399468d582f | |
| parent | 996c7bd7d11035cd19a824e448b2bc940823bb3a (diff) | |
| download | brew-cdbc7c9e53dccc17e65bb6f7f7a95a34dadf3b58.tar.bz2 | |
Pathname: add methods to write env scripts.
| -rw-r--r-- | Library/Homebrew/extend/pathname.rb | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/Library/Homebrew/extend/pathname.rb b/Library/Homebrew/extend/pathname.rb index afb60610b..3c024e77d 100644 --- a/Library/Homebrew/extend/pathname.rb +++ b/Library/Homebrew/extend/pathname.rb @@ -383,6 +383,27 @@ class Pathname end end + # Writes an exec script that sets environment variables + def write_env_script target, env + env_export = '' + env.each {|key, value| env_export += "#{key}=\"#{value}\" "} + self.write <<-EOS.undent + #!/bin/bash + #{env_export}exec "#{target}" "$@" + EOS + end + + # Writes a wrapper env script and moves all files to the dst + def env_script_all_files dst, env + dst.mkpath + Dir["#{self}/*"].each do |file| + file = Pathname.new(file) + dst.install_p file + new_file = dst+file.basename + file.write_env_script(new_file, env) + end + end + # Writes an exec script that invokes a java jar def write_jar_script target_jar, script_name, java_opts="" (self+script_name).write <<-EOS.undent |
