diff options
| author | James Turnbull <james@lovedthanlost.net> | 2008-07-08 08:53:42 +1000 |
|---|---|---|
| committer | James Turnbull <james@lovedthanlost.net> | 2008-07-08 08:53:42 +1000 |
| commit | 56525beb26d8371533a17667e6ebcae0cda9a6f6 (patch) | |
| tree | f240643693d4180c0a8efd8961363e6e7015a03c /lib | |
| parent | 1fe0660f6b468b8637ac60cd73a033e7726ef838 (diff) | |
| parent | 667fac18cc3682374de991bb740ae834d8c17bee (diff) | |
| download | puppet-56525beb26d8371533a17667e6ebcae0cda9a6f6.tar.gz puppet-56525beb26d8371533a17667e6ebcae0cda9a6f6.tar.xz puppet-56525beb26d8371533a17667e6ebcae0cda9a6f6.zip | |
Merge branch 'tickets/0.24.x/1226' of git://github.com/lak/puppet into 0.24.x
Diffstat (limited to 'lib')
| -rwxr-xr-x | lib/puppet/provider/package/gem.rb | 45 |
1 files changed, 33 insertions, 12 deletions
diff --git a/lib/puppet/provider/package/gem.rb b/lib/puppet/provider/package/gem.rb index bb09bc5b0..133243c86 100755 --- a/lib/puppet/provider/package/gem.rb +++ b/lib/puppet/provider/package/gem.rb @@ -1,9 +1,12 @@ require 'puppet/provider/package' +require 'uri' # Ruby gems support. Puppet::Type.type(:package).provide :gem, :parent => Puppet::Provider::Package do - desc "Ruby Gem support. By default uses remote gems, but you can specify - the path to a local gem via ``source``." + desc "Ruby Gem support. If a URL is passed via ``source``, then that URL is used as the + remote gem repository; if a source is present but is not a valid URL, it will be + interpreted as the path to a local gem file. If source is not present at all, + the gem will be installed from the default gem repositories." has_feature :versionable @@ -65,20 +68,38 @@ Puppet::Type.type(:package).provide :gem, :parent => Puppet::Provider::Package d end def install(useversion = true) - command = ["install"] - if (! @resource.should(:ensure).is_a? Symbol) and useversion - command << "-v" << @resource.should(:ensure) + command = [command(:gemcmd), "install"] + if (! resource[:ensure].is_a? Symbol) and useversion + command << "-v" << resource[:ensure] end # Always include dependencies command << "--include-dependencies" - if source = @resource[:source] - command << source + if source = resource[:source] + begin + uri = URI.parse(source) + rescue => detail + fail "Invalid source '%s': %s" % [uri, detail] + end + + case uri.scheme + when nil: + # no URI scheme => interpret the source as a local file + command << source + when /file/i + command << uri.path + when 'puppet' + # we don't support puppet:// URLs (yet) + raise Puppet::Error.new("puppet:// URLs are not supported as gem sources") + else + # interpret it as a gem repository + command << "--source" << "#{source}" << resource[:name] + end else - command << @resource[:name] + command << resource[:name] end - output = gemcmd(*command) + output = execute(command) # Apparently some stupid gem versions don't exit non-0 on failure if output.include?("ERROR") self.fail "Could not install: %s" % output.chomp @@ -87,17 +108,17 @@ Puppet::Type.type(:package).provide :gem, :parent => Puppet::Provider::Package d def latest # This always gets the latest version available. - hash = self.class.gemlist(:justme => @resource[:name]) + hash = self.class.gemlist(:justme => resource[:name]) return hash[:ensure] end def query - self.class.gemlist(:justme => @resource[:name], :local => true) + self.class.gemlist(:justme => resource[:name], :local => true) end def uninstall - gemcmd "uninstall", "-x", "-a", @resource[:name] + gemcmd "uninstall", "-x", "-a", resource[:name] end def update |
