Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

- improve the error message when you give an invalid target or source

- clenaed up unused code in target/puppet
  • Loading branch information...
commit 3219b8e65174cf71ad36665acc02636e3e768f49 1 parent a5d9702
@jordansissel authored
Showing with 18 additions and 35 deletions.
  1. +15 −6 lib/fpm/builder.rb
  2. +3 −29 lib/fpm/target/puppet.rb
View
21 lib/fpm/builder.rb
@@ -29,6 +29,9 @@ def garbage
attr_reader :source
def initialize(settings, paths=[])
+ @logger = Logger.new(STDERR)
+ @logger.level = $DEBUG ? Logger::DEBUG : Logger::WARN
+
@working_dir = Dir.pwd
root = settings.chdir || '.'
paths = ['.'] if paths.empty?
@@ -135,23 +138,29 @@ def make_builddir!
# TODO: [Jay] make this better.
private
def package_class_for(type)
- type = FPM::Target::constants.find { |c| c.downcase.to_s == type }
- if !type
+ realtype = FPM::Target.constants.find { |c| c.downcase.to_s == type }
+ if !realtype
+ valid_types = FPM::Target.constants.collect { |c| c.downcase }
+ @logger.fatal("No such package target type #{type.inspect}; " \
+ "Valid types: #{valid_types.join(", ")}")
raise ArgumentError, "unknown package type #{type.inspect}"
end
- return FPM::Target.const_get(type)
+ return FPM::Target.const_get(realtype)
end
# TODO: [Jay] make this better.
private
def source_class_for(type)
- type = FPM::Source::constants.find { |c| c.downcase.to_s == type }
- if !type
+ realtype = FPM::Source::constants.find { |c| c.downcase.to_s == type }
+ if !realtype
+ valid_types = FPM::Source.constants.collect { |c| c.downcase }
+ @logger.fatal("No such package source type #{type.inspect}; " \
+ "Valid types: #{valid_types.join(", ")}")
raise ArgumentError, "unknown package type #{type.inspect}"
end
- return FPM::Source.const_get(type)
+ return FPM::Source.const_get(realtype)
end
private
View
32 lib/fpm/target/puppet.rb
@@ -5,19 +5,6 @@
require "etc"
require "ftools"
-#class ::Dir
- #class << self
- #alias :orig_mkdir :mkdir
-#
- #def mkdir(*args)
- ##p :mkdir => { :args => args, :caller => caller }
- #orig_mkdir(*args)
- #end
- #end
-#end
-
-require "fileutils" # for FileUtils
-
# TODO(sissel): Add dependency checking support.
# IIRC this has to be done as a 'checkinstall' step.
class FPM::Target::Puppet < FPM::Package
@@ -29,10 +16,6 @@ def architecture
return @architecture
end # def architecture
- def specfile(builddir)
- "#{builddir}/package.pp"
- end # def specfile
-
# Default specfile generator just makes one specfile, whatever that is for
# this package.
def generate_specfile(builddir)
@@ -64,18 +47,6 @@ def generate_specfile(builddir)
end
end # def generate_specfile
- # Override render_spec so we can generate multiple files for puppet.
- # The package.pp, package/remove.pp,
- def render_spec
- # find all files in paths given.
- paths = []
- @source.paths.each do |path|
- Find.find(path) { |p| paths << p }
- end
- #@logger.info(:paths => paths.sort)
- template.result(binding)
- end # def render_spec
-
def unpack_data_to
"files"
end
@@ -117,12 +88,14 @@ def default_output
name
end # def default_output
+ # This method is used by the puppet manifest template
def puppetsort(hash)
# TODO(sissel): Implement sorting that follows the puppet style guide
# Such as, 'ensure' goes first, etc.
return hash.to_a
end # def puppetsort
+ # Helper for user lookup
def uid2user(uid)
begin
pwent = Etc.getpwuid(uid)
@@ -134,6 +107,7 @@ def uid2user(uid)
end
end # def uid2user
+ # Helper for group lookup
def gid2group(gid)
begin
grent = Etc.getgrgid(gid)
Please sign in to comment.
Something went wrong with that request. Please try again.