Merge from master; rewriting calls to safesystem().
This commit is contained in:
commit
cf7d3acb87
|
|
@ -18,7 +18,6 @@ class FPM::Program
|
|||
@settings.source = {} # source settings
|
||||
@settings.target = {} # target settings
|
||||
@settings.config_files ||= []
|
||||
@settings.inputs_path = nil # file path to read a list of paths from
|
||||
@settings.paths = [] # Paths to include in the package
|
||||
|
||||
# Maintainer scripts - https://github.com/jordansissel/fpm/issues/18
|
||||
|
|
@ -63,13 +62,13 @@ class FPM::Program
|
|||
read_from_stdin = args.length == 1 && args.first == '-'
|
||||
|
||||
ok = true
|
||||
if @settings.inputs_path
|
||||
if @settings.source[:inputs]
|
||||
if read_from_stdin
|
||||
$stderr.puts "Error: setting --inputs conflicts with passing '-' as the only argument"
|
||||
ok = false
|
||||
end
|
||||
unless File.file?(@settings.inputs_path)
|
||||
$stderr.puts "Error: '#{@settings.inputs_path}' does not exist"
|
||||
unless File.file?(@settings.source[:inputs])
|
||||
$stderr.puts "Error: '#{@settings.source[:inputs]}' does not exist"
|
||||
ok = false
|
||||
end
|
||||
end
|
||||
|
|
@ -79,8 +78,8 @@ class FPM::Program
|
|||
if read_from_stdin
|
||||
paths_iolike = $stdin
|
||||
end
|
||||
if @settings.inputs_path
|
||||
paths_iolike = File.open(@settings.inputs_path, 'r')
|
||||
if @settings.source[:inputs]
|
||||
paths_iolike = File.open(@settings.source[:inputs], 'r')
|
||||
end
|
||||
|
||||
paths = []
|
||||
|
|
@ -105,7 +104,13 @@ class FPM::Program
|
|||
fpmrc(opts)
|
||||
|
||||
# Proces normal flags now.
|
||||
remaining = opts.parse(args)
|
||||
begin
|
||||
remaining = opts.parse(args)
|
||||
rescue OptionParser::MissingArgument, OptionParser::InvalidOption
|
||||
$stderr.puts $!.to_s
|
||||
$stderr.puts opts
|
||||
exit 2
|
||||
end
|
||||
|
||||
# need to print help in a different scope
|
||||
@help = opts.help
|
||||
|
|
|
|||
|
|
@ -116,8 +116,8 @@ class FPM::Target::Deb < FPM::Package
|
|||
self.scripts.each do |name, path|
|
||||
ctrl_type, ctrl_file = CONTROL_FILES[name]
|
||||
if ctrl_file
|
||||
safesystem("cp #{path} ./#{ctrl_file}")
|
||||
safesystem("chmod a+x ./#{ctrl_file}") if ctrl_type == :script
|
||||
safesystem("cp", path, "./#{ctrl_file}")
|
||||
safesystem("chmod", "a+x", "./#{ctrl_file}") if ctrl_type == :script
|
||||
control_files << ctrl_file
|
||||
else
|
||||
raise "Unsupported script name '#{name}' (path: #{path})"
|
||||
|
|
@ -130,14 +130,13 @@ class FPM::Target::Deb < FPM::Package
|
|||
end
|
||||
|
||||
# Make the control
|
||||
safesystem("tar --numeric-owner --owner=root --group=root -zcf control.tar.gz " \
|
||||
"#{control_files.map{ |f| "./#{f}" }.join(" ")}")
|
||||
safesystem("tar", "--numeric-owner --owner=root --group=root -zcf", "control.tar.gz", *control_files)
|
||||
|
||||
# create debian-binary
|
||||
File.open("debian-binary", "w") { |f| f.puts "2.0" }
|
||||
|
||||
# pack up the .deb
|
||||
safesystem("ar -qc #{params[:output]} debian-binary control.tar.gz data.tar.gz")
|
||||
safesystem("ar", "-qc", "#{params[:output]}", "debian-binary", "control.tar.gz", "data.tar.gz")
|
||||
end # def build
|
||||
|
||||
def default_output
|
||||
|
|
|
|||
|
|
@ -20,6 +20,27 @@ class FPM::Target::Rpm < FPM::Package
|
|||
"#{builddir}/#{name}.spec"
|
||||
end
|
||||
|
||||
# Override inherited method so we can properly substitute in configuration
|
||||
# files which require special directives in the spec file.
|
||||
def render_spec
|
||||
# find all files in paths given.
|
||||
paths = []
|
||||
@source.paths.each do |path|
|
||||
Find.find(path) { |p| paths << p }
|
||||
end
|
||||
|
||||
# Ensure all paths are absolute and don't start with '.'
|
||||
paths.collect! { |p| p.gsub(/^\.\//, "/").gsub(/^[^\/]/, "/\\0") }
|
||||
@config_files.collect! { |c| c.gsub(/^\.\//, "/").gsub(/^[^\/]/, "/\\0") }
|
||||
|
||||
# Remove config files from the main path list, as files cannot be listed
|
||||
# twice (rpmbuild complains).
|
||||
paths -= @config_files
|
||||
|
||||
#@logger.info(:paths => paths.sort)
|
||||
template.result(binding)
|
||||
end # def render_spec
|
||||
|
||||
def url
|
||||
if @url.nil? || @url.empty?
|
||||
'http://nourlgiven.example.com'
|
||||
|
|
|
|||
|
|
@ -94,8 +94,8 @@ rm -rf $RPM_BUILD_ROOT
|
|||
<% end -%>
|
||||
%files
|
||||
%defattr(-,root,root,-)
|
||||
<%# Trim leading '.' from paths if they are './blah...' -%>
|
||||
<%# Also ensure paths start with '/' -%>
|
||||
<%= @source.paths.collect { |p| p.gsub(/^\.\//, "/").gsub(/^[^\/]/, "/\\0") }.join("\n") %>
|
||||
<%# Output config files and then regular files. -%>
|
||||
<%= @config_files.collect { |c| '%config ' + c }.join("\n") %>
|
||||
<%= paths.join("\n") %>
|
||||
|
||||
%changelog
|
||||
|
|
|
|||
Loading…
Reference in New Issue