summaryrefslogtreecommitdiffstats
path: root/lib/puppet
diff options
context:
space:
mode:
authorLuke Kanies <luke@madstop.com>2008-07-07 16:34:53 -0500
committerLuke Kanies <luke@madstop.com>2008-07-07 16:34:53 -0500
commit71f4b02f1d3fab7ad10c6961405b0e94721e4031 (patch)
tree93810d2e6eddfc5e9a0b501ecef03c14436e3a5a /lib/puppet
parent81be1c5c3f85f514505e99fab5b8a2b2ae6fbec8 (diff)
downloadpuppet-71f4b02f1d3fab7ad10c6961405b0e94721e4031.tar.gz
puppet-71f4b02f1d3fab7ad10c6961405b0e94721e4031.tar.xz
puppet-71f4b02f1d3fab7ad10c6961405b0e94721e4031.zip
Importing Sam Quigley's work to enhance gem support for sources.
Diffstat (limited to 'lib/puppet')
-rwxr-xr-xlib/puppet/provider/package/gem.rb26
1 files changed, 21 insertions, 5 deletions
diff --git a/lib/puppet/provider/package/gem.rb b/lib/puppet/provider/package/gem.rb
index bb09bc5b0..277fc68cc 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,7 +68,7 @@ Puppet::Type.type(:package).provide :gem, :parent => Puppet::Provider::Package d
end
def install(useversion = true)
- command = ["install"]
+ command = [command(:gemcmd), "install"]
if (! @resource.should(:ensure).is_a? Symbol) and useversion
command << "-v" << @resource.should(:ensure)
end
@@ -73,12 +76,25 @@ Puppet::Type.type(:package).provide :gem, :parent => Puppet::Provider::Package d
command << "--include-dependencies"
if source = @resource[:source]
- command << source
+ scheme = URI.parse(blah).scheme rescue nil # the URI scheme if there is one, nil otherwise
+
+ if scheme.nil?
+ # no URI scheme => interpret the source as a local file
+ command << source
+ elsif scheme.downcase == "file"
+ command << source.path
+ elsif scheme.downcase == "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]
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