lib/buildrdeb/package.rb in buildrdeb-1.0.0 vs lib/buildrdeb/package.rb in buildrdeb-1.0.1
- old
+ new
@@ -34,14 +34,19 @@
raise "no control file was defined when packaging as a deb file" if filename == "control"
else
raise "Cannot find #{filename}: #{file} doesn't exist" if !File.exists? file
target = File.join(root, "DEBIAN", filename)
contents = File.read(file)
- # Replace version if we are looking at control.
- contents.gsub!(/^Version: .*$/, "Version: #{@version}") if (filename == "control" && !@version.nil?)
- File.open(target, "w+") {|t|
- t.write eval("\"#{contents}\"")
- }
+ # Replace version and use ERB to evaluate the control file, in case there are variables to pass.
+ if (filename == "control" && !@version.nil?)
+ contents.gsub!(/^Version: .*$/, "Version: #{@version}")
+ File.open(target, "w") {|t|
+ t.write ERB.new(contents).result
+ }
+ else
+ cp file.to_s, target
+ end
+
File.chmod 0755, target
end
end
file_map.each do |path, content|
_path = File.join(root, path)
\ No newline at end of file