+x wrapper scripts, so they work during post-install

This commit is contained in:
Adam Vandenberg 2013-12-12 08:21:22 -08:00
parent 5c18054341
commit 7516cee374

View File

@ -377,22 +377,27 @@ class Pathname
targets.flatten! targets.flatten!
if targets.empty? if targets.empty?
opoo "tried to write exec scripts to #{self} for an empty list of targets" opoo "tried to write exec scripts to #{self} for an empty list of targets"
return
end end
targets.each do |target| targets.each do |target|
target = Pathname.new(target) # allow pathnames or strings target = Pathname.new(target) # allow pathnames or strings
(self+target.basename()).write <<-EOS.undent (self+target.basename()).write <<-EOS.undent
#!/bin/bash #!/bin/bash
exec "#{target}" "$@" exec "#{target}" "$@"
EOS EOS
# +x here so this will work during post-install as well
(self+target.basename()).chmod 0644
end end
end end
# Writes an exec script that invokes a java jar # Writes an exec script that invokes a java jar
def write_jar_script target_jar, script_name, java_opts="" def write_jar_script target_jar, script_name, java_opts=""
(self+script_name).write <<-EOS.undent (self+script_name).write <<-EOS.undent
#!/bin/bash #!/bin/bash
exec java #{java_opts} -jar #{target_jar} "$@" exec java #{java_opts} -jar #{target_jar} "$@"
EOS EOS
# +x here so this will work during post-install as well
(self+script_name).chmod 0644
end end
def install_metafiles from=nil def install_metafiles from=nil