[Pkg-puppet-devel] [SCM] Puppet packaging for Debian branch, upstream, updated. puppet-0.24.5-rc3-1456-g2f0b1e5
James Turnbull
james at lovedthanlost.net
Tue Oct 27 17:06:13 UTC 2009
The following commit has been merged in the upstream branch:
commit f47a70f46baa8b3c71c7e23471827a43abbbe598
Author: Markus Roberts <Markus at reality.com>
Date: Mon Oct 19 09:34:40 2009 -0700
Ticket #2665: Regexp exception on ++ in package names
This affects several providers:
dpkg, rug, up2date, urpmi
Fixed by escaping the package names with Regexp.escape
Patch by Jesse Wolf
Signed-off-by: Markus Roberts <Markus at reality.com>
diff --git a/lib/puppet/provider/package/dpkg.rb b/lib/puppet/provider/package/dpkg.rb
index a4c3982..d6ec56a 100755
--- a/lib/puppet/provider/package/dpkg.rb
+++ b/lib/puppet/provider/package/dpkg.rb
@@ -83,7 +83,7 @@ Puppet::Type.type(:package).provide :dpkg, :parent => Puppet::Provider::Package
def latest
output = dpkg_deb "--show", @resource[:source]
matches = /^(\S+)\t(\S+)$/.match(output).captures
- unless matches[0].match(@resource[:name])
+ unless matches[0].match( Regexp.escape(@resource[:name]) )
warning "source doesn't contain named package, but %s" % matches[0]
end
matches[1]
diff --git a/lib/puppet/provider/package/rug.rb b/lib/puppet/provider/package/rug.rb
index b68ec30..ca27cbb 100644
--- a/lib/puppet/provider/package/rug.rb
+++ b/lib/puppet/provider/package/rug.rb
@@ -36,7 +36,7 @@ Puppet::Type.type(:package).provide :rug, :parent => :rpm do
#rug can only get a list of *all* available packages?
output = rug "list-updates"
- if output =~ /#{@resource[:name]}\s*\|\s*([0-9\.\-]+)/
+ if output =~ /#{Regexp.escape @resource[:name]}\s*\|\s*([0-9\.\-]+)/
return $1
else
# rug didn't find updates, pretend the current
diff --git a/lib/puppet/provider/package/up2date.rb b/lib/puppet/provider/package/up2date.rb
index d8a1265..284bbaf 100644
--- a/lib/puppet/provider/package/up2date.rb
+++ b/lib/puppet/provider/package/up2date.rb
@@ -25,7 +25,7 @@ Puppet::Type.type(:package).provide :up2date, :parent => :rpm, :source => :rpm d
#up2date can only get a list of *all* available packages?
output = up2date "--showall"
- if output =~ /^#{@resource[:name]}-(\d+.*)\.\w+/
+ if output =~ /^#{Regexp.escape @resource[:name]}-(\d+.*)\.\w+/
return $1
else
# up2date didn't find updates, pretend the current
diff --git a/lib/puppet/provider/package/urpmi.rb b/lib/puppet/provider/package/urpmi.rb
index a958352..a79e962 100644
--- a/lib/puppet/provider/package/urpmi.rb
+++ b/lib/puppet/provider/package/urpmi.rb
@@ -43,7 +43,7 @@ Puppet::Type.type(:package).provide :urpmi, :parent => :rpm, :source => :rpm do
def latest
output = urpmq "-S", @resource[:name]
- if output =~ /^#{@resource[:name]}\s+:\s+.*\(\s+(\S+)\s+\)/
+ if output =~ /^#{Regexp.escape @resource[:name]}\s+:\s+.*\(\s+(\S+)\s+\)/
return $1
else
# urpmi didn't find updates, pretend the current
diff --git a/spec/unit/provider/package/dpkg.rb b/spec/unit/provider/package/dpkg.rb
index 08aaca8..0c5c9b5 100755
--- a/spec/unit/provider/package/dpkg.rb
+++ b/spec/unit/provider/package/dpkg.rb
@@ -149,6 +149,13 @@ describe provider do
@provider.expects(:warning)
@provider.latest
end
+
+ it "should cope with names containing ++" do
+ @resource = stub 'resource', :[] => "asdf++"
+ @provider = provider.new(@resource)
+ @provider.expects(:dpkg_deb).returns "asdf++\t1.0"
+ @provider.latest.should == "1.0"
+ end
end
it "should use 'dpkg -r' to uninstall" do
--
Puppet packaging for Debian
More information about the Pkg-puppet-devel
mailing list