From c8e2657d3f34f2d36f7b83e5c8e4454155ea122e Mon Sep 17 00:00:00 2001 From: Jordan Sissel Date: Fri, 30 Mar 2012 15:06:54 -0700 Subject: [PATCH] - If no args are given, assume '.' was intended if the source is 'dir' and chdir (-C) is set. Fixes issue #187 - Abort if there's no package name known. --- lib/fpm/command.rb | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/lib/fpm/command.rb b/lib/fpm/command.rb index 6453f615bf..65c5bb7ccc 100644 --- a/lib/fpm/command.rb +++ b/lib/fpm/command.rb @@ -183,6 +183,15 @@ def execute @logger.subscribe(STDOUT) @logger.level = :warn + # Some older behavior, if you specify: + # 'fpm -s dir -t ... -C somepath' + # fpm would assume you meant to add '.' to the end of the commandline. + # Let's hack that. https://github.com/jordansissel/fpm/issues/187 + if input_type == "dir" and args.empty? and !chdir.nil? + @logger.info("No args, but -s dir and -C are given, assuming '.' as input") + args << "." + end + validator = Validator.new(self) if !validator.ok? validator.messages.each do |message| @@ -288,7 +297,7 @@ def execute # 'self.send(scriptname) == self.before_install == --before-install if !File.exists?(path) - $stderr.puts("No such file (for #{scriptname.to_s}): #{path.inspect}") + @logger.error("No such file (for #{scriptname.to_s}): #{path.inspect}") return 1 end input.scripts[scriptname] = File.read(path) @@ -299,6 +308,13 @@ def execute setscript.call(:before_remove) setscript.call(:after_remove) + # Validate the package + if input.name.nil? or input.name.empty? + @logger.fatal("No name given for this package (set name with, " \ + "for example, '-n packagename')") + return 1 + end + # Convert to the output type output = input.convert(output_class)