From 9f365b19a738b1ee09712834d510de32b2a86d25 Mon Sep 17 00:00:00 2001 From: James Turnbull Date: Sat, 17 Jul 2010 01:35:44 +1000 Subject: Fixed #4258 - Added pkgutil package provider --- lib/puppet/provider/package/pkgutil.rb | 117 +++++++++++++++++++++++++++++++++ 1 file changed, 117 insertions(+) create mode 100644 lib/puppet/provider/package/pkgutil.rb (limited to 'lib') diff --git a/lib/puppet/provider/package/pkgutil.rb b/lib/puppet/provider/package/pkgutil.rb new file mode 100644 index 000000000..39c23025d --- /dev/null +++ b/lib/puppet/provider/package/pkgutil.rb @@ -0,0 +1,117 @@ +# Packaging using Peter Bonivart's pkgutil program. +Puppet::Type.type(:package).provide :pkgutil, :parent => :sun, :source => :sun do + desc "Package management using Peter Bonivartg's ``pkgutil`` command on Solaris." + pkguti = "pkgutil" + if FileTest.executable?("/opt/csw/bin/pkgutil") + pkguti = "/opt/csw/bin/pkgutil" + end + + confine :operatingsystem => :solaris + + commands :pkguti => pkguti + + # This is so stupid, but then, so is blastwave. + ENV["PAGER"] = "/usr/bin/cat" + + def self.extended(mod) + unless command(:pkguti) != "pkgutil" + raise Puppet::Error, + "The pkgutil command is missing; pkgutil packaging unavailable" + end + + unless FileTest.exists?("/var/pkg-get/admin") + Puppet.notice "It is highly recommended you create '/var/pkg-get/admin'." + Puppet.notice "See /var/pkg-get/admin-fullauto" + end + end + + def self.instances(hash = {}) + blastlist(hash).collect do |bhash| + bhash.delete(:avail) + new(bhash) + end + end + + # Turn our blastwave listing into a bunch of hashes. + def self.blastlist(hash) + command = ["-c"] + + if hash[:justme] + command << hash[:justme] + end + + output = pkguti command + + list = output.split("\n").collect do |line| + next if line =~ /^#/ + next if line =~ /^WARNING/ + next if line =~ /localrev\s+remoterev/ + next if line =~ /installed\s+catalog/ + + blastsplit(line) + end.reject { |h| h.nil? } + + if hash[:justme] + return list[0] + else + list.reject! { |h| + h[:ensure] == :absent + } + return list + end + + end + + # Split the different lines into hashes. + def self.blastsplit(line) + if line =~ /\s*(\S+)\s+((\[Not installed\])|(\S+))\s+(\S+)/ + hash = {} + hash[:name] = $1 + hash[:ensure] = if $2 == "[Not installed]" + :absent + else + $2 + end + hash[:avail] = $5 + + if hash[:avail] == "SAME" + hash[:avail] = hash[:ensure] + end + + # Use the name method, so it works with subclasses. + hash[:provider] = self.name + + return hash + else + Puppet.warning "Cannot match %s" % line + return nil + end + end + + def install + pkguti "-y", "-i", @resource[:name] + end + + # Retrieve the version from the current package file. + def latest + hash = self.class.blastlist(:justme => @resource[:name]) + hash[:avail] + end + + def query + if hash = self.class.blastlist(:justme => @resource[:name]) + hash + else + {:ensure => :absent} + end + end + + # Remove the old package, and install the new one + def update + pkguti "-y", "-i", @resource[:name] + end + + def uninstall + pkguti "-y", "-r", @resource[:name] + end +end -- cgit From fc1859119b8fad1edaabdbce48545e1583bfa24c Mon Sep 17 00:00:00 2001 From: Maciej Blizinski Date: Thu, 22 Jul 2010 12:48:53 +0200 Subject: Adding pkgutil support. --- lib/puppet/provider/package/pkgutil.rb | 111 +++++++++++++++++++++++++++++++++ 1 file changed, 111 insertions(+) create mode 100755 lib/puppet/provider/package/pkgutil.rb (limited to 'lib') diff --git a/lib/puppet/provider/package/pkgutil.rb b/lib/puppet/provider/package/pkgutil.rb new file mode 100755 index 000000000..cde7482f2 --- /dev/null +++ b/lib/puppet/provider/package/pkgutil.rb @@ -0,0 +1,111 @@ +# Packaging using pkgutil from http://pkgutil.wikidot.com/ +Puppet::Type.type(:package).provide :pkgutil, :parent => :sun, :source => :sun do + desc "Package management using ``pkgutil`` command on Solaris." + pkgutil = "pkgutil" + if FileTest.executable?("/opt/csw/bin/pkgutil") + pkgutil = "/opt/csw/bin/pkgutil" + end + + confine :operatingsystem => :solaris + + commands :pkgutil => pkgutil + + # This is so stupid, but then, so is Solaris. + ENV["PAGER"] = "/usr/bin/cat" + + def self.extended(mod) + unless command(:pkgutil) != "pkgutil" + raise Puppet::Error, + "The pkgutil command is missing; pkgutil packaging unavailable" + end + end + + def self.instances(hash = {}) + blastlist(hash).collect do |bhash| + bhash.delete(:avail) + new(bhash) + end + end + + # Turn our pkgutil listing into a bunch of hashes. + def self.blastlist(hash) + command = ["-c"] + + if hash[:justme] + command << hash[:justme] + end + + output = pkgutil command + + list = output.split("\n").collect do |line| + next if line =~ /^#/ + next if line =~ /^WARNING/ + next if line =~ /localrev\s+remoterev/ + + blastsplit(line) + end.reject { |h| h.nil? } + + if hash[:justme] + return list[0] + else + list.reject! { |h| + h[:ensure] == :absent + } + return list + end + + end + + # Split the different lines into hashes. + def self.blastsplit(line) + if line =~ /\s*(\S+)\s+((\[Not installed\])|(\S+))\s+(\S+)/ + hash = {} + hash[:name] = $1 + hash[:ensure] = if $2 == "[Not installed]" + :absent + else + $2 + end + hash[:avail] = $5 + + if hash[:avail] == "SAME" + hash[:avail] = hash[:ensure] + end + + # Use the name method, so it works with subclasses. + hash[:provider] = self.name + + return hash + else + Puppet.warning "Cannot match %s" % line + return nil + end + end + + def install + pkgutil "-y", "--install", @resource[:name] + end + + # Retrieve the version from the current package file. + def latest + hash = self.class.blastlist(:justme => @resource[:name]) + hash[:avail] + end + + def query + if hash = self.class.blastlist(:justme => @resource[:name]) + hash + else + {:ensure => :absent} + end + end + + # Remove the old package, and install the new one + def update + pkgutil "-y", "--upgrade", @resource[:name] + end + + def uninstall + pkgutil "-y", "--remove", @resource[:name] + end +end -- cgit From e02ba01613a5ce61ccd6c80c17d53134daf589ba Mon Sep 17 00:00:00 2001 From: Maciej Blizinski Date: Thu, 22 Jul 2010 12:50:29 +0200 Subject: Using --single in the pkgutil provider. --- lib/puppet/provider/package/pkgutil.rb | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'lib') diff --git a/lib/puppet/provider/package/pkgutil.rb b/lib/puppet/provider/package/pkgutil.rb index cde7482f2..c2489ccad 100755 --- a/lib/puppet/provider/package/pkgutil.rb +++ b/lib/puppet/provider/package/pkgutil.rb @@ -1,4 +1,5 @@ # Packaging using pkgutil from http://pkgutil.wikidot.com/ +# vim:set sw=4 ts=4 sts=4: Puppet::Type.type(:package).provide :pkgutil, :parent => :sun, :source => :sun do desc "Package management using ``pkgutil`` command on Solaris." pkgutil = "pkgutil" @@ -20,6 +21,7 @@ Puppet::Type.type(:package).provide :pkgutil, :parent => :sun, :source => :sun d end end + # It's a class method. Returns a list of instances of this class. def self.instances(hash = {}) blastlist(hash).collect do |bhash| bhash.delete(:avail) @@ -32,6 +34,7 @@ Puppet::Type.type(:package).provide :pkgutil, :parent => :sun, :source => :sun d command = ["-c"] if hash[:justme] + command << ["--single"] command << hash[:justme] end @@ -86,7 +89,7 @@ Puppet::Type.type(:package).provide :pkgutil, :parent => :sun, :source => :sun d pkgutil "-y", "--install", @resource[:name] end - # Retrieve the version from the current package file. + # What's the latest version of the package available? def latest hash = self.class.blastlist(:justme => @resource[:name]) hash[:avail] -- cgit From 0fc2aa65a2cf663a9fb1aec1eeb0f1f7c34aca94 Mon Sep 17 00:00:00 2001 From: Maciej Blizinski Date: Thu, 22 Jul 2010 13:12:59 +0200 Subject: pkgutil provider: Correcting a typo in a message. --- lib/puppet/provider/package/pkgutil.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lib') diff --git a/lib/puppet/provider/package/pkgutil.rb b/lib/puppet/provider/package/pkgutil.rb index 39c23025d..ec48c9455 100644 --- a/lib/puppet/provider/package/pkgutil.rb +++ b/lib/puppet/provider/package/pkgutil.rb @@ -1,6 +1,6 @@ # Packaging using Peter Bonivart's pkgutil program. Puppet::Type.type(:package).provide :pkgutil, :parent => :sun, :source => :sun do - desc "Package management using Peter Bonivartg's ``pkgutil`` command on Solaris." + desc "Package management using Peter Bonivart's ``pkgutil`` command on Solaris." pkguti = "pkgutil" if FileTest.executable?("/opt/csw/bin/pkgutil") pkguti = "/opt/csw/bin/pkgutil" -- cgit From ec2a03c5842c183963a7c5dc070f83566ec5ea30 Mon Sep 17 00:00:00 2001 From: Maciej Blizinski Date: Thu, 22 Jul 2010 13:13:30 +0200 Subject: pkgutil provider: The path to the admin file is /var/opt/csw/pkgutil/admin --- lib/puppet/provider/package/pkgutil.rb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'lib') diff --git a/lib/puppet/provider/package/pkgutil.rb b/lib/puppet/provider/package/pkgutil.rb index ec48c9455..4f6b5c240 100644 --- a/lib/puppet/provider/package/pkgutil.rb +++ b/lib/puppet/provider/package/pkgutil.rb @@ -19,9 +19,9 @@ Puppet::Type.type(:package).provide :pkgutil, :parent => :sun, :source => :sun d "The pkgutil command is missing; pkgutil packaging unavailable" end - unless FileTest.exists?("/var/pkg-get/admin") - Puppet.notice "It is highly recommended you create '/var/pkg-get/admin'." - Puppet.notice "See /var/pkg-get/admin-fullauto" + unless FileTest.exists?("/var/opt/csw/pkgutil/admin") + Puppet.notice "It is highly recommended you create '/var/opt/csw/pkgutil/admin'." + Puppet.notice "See /var/opt/csw/pkgutil" end end -- cgit From d026bb7c963f992e378ade5e0586242f506c62c7 Mon Sep 17 00:00:00 2001 From: Maciej Blizinski Date: Thu, 22 Jul 2010 13:13:58 +0200 Subject: pkgutil provider: Using the --single option which speeds up execution. --- lib/puppet/provider/package/pkgutil.rb | 3 +++ 1 file changed, 3 insertions(+) (limited to 'lib') diff --git a/lib/puppet/provider/package/pkgutil.rb b/lib/puppet/provider/package/pkgutil.rb index 4f6b5c240..b8ad54892 100644 --- a/lib/puppet/provider/package/pkgutil.rb +++ b/lib/puppet/provider/package/pkgutil.rb @@ -37,6 +37,9 @@ Puppet::Type.type(:package).provide :pkgutil, :parent => :sun, :source => :sun d command = ["-c"] if hash[:justme] + # The --single option speeds up the execution, because it queries + # the package managament system for one package only. + command << ["--single"] command << hash[:justme] end -- cgit From 69a3451cb89c819291721f810b58f3ccf08b4cc5 Mon Sep 17 00:00:00 2001 From: Dominic Cleal Date: Mon, 15 Nov 2010 22:49:46 +0000 Subject: Adding patch from Rudy Gevaert to fix not installed detection --- lib/puppet/provider/package/pkgutil.rb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'lib') diff --git a/lib/puppet/provider/package/pkgutil.rb b/lib/puppet/provider/package/pkgutil.rb index b8ad54892..05d189d0b 100755 --- a/lib/puppet/provider/package/pkgutil.rb +++ b/lib/puppet/provider/package/pkgutil.rb @@ -67,15 +67,15 @@ Puppet::Type.type(:package).provide :pkgutil, :parent => :sun, :source => :sun d # Split the different lines into hashes. def self.blastsplit(line) - if line =~ /\s*(\S+)\s+((\[Not installed\])|(\S+))\s+(\S+)/ + if line =~ /\s*(\S+)\s+(\S+)\s+(.*)/ hash = {} hash[:name] = $1 - hash[:ensure] = if $2 == "[Not installed]" + hash[:ensure] = if $2 == "notinst" :absent else $2 end - hash[:avail] = $5 + hash[:avail] = $3 if hash[:avail] == "SAME" hash[:avail] = hash[:ensure] -- cgit From 143fc744a839affd328234fca26246d49d15d3d8 Mon Sep 17 00:00:00 2001 From: Dominic Cleal Date: Mon, 15 Nov 2010 22:51:17 +0000 Subject: Ignoring lines from use_gpg and catalog fetching --- lib/puppet/provider/package/pkgutil.rb | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'lib') diff --git a/lib/puppet/provider/package/pkgutil.rb b/lib/puppet/provider/package/pkgutil.rb index 05d189d0b..a5f852dd4 100755 --- a/lib/puppet/provider/package/pkgutil.rb +++ b/lib/puppet/provider/package/pkgutil.rb @@ -50,6 +50,10 @@ Puppet::Type.type(:package).provide :pkgutil, :parent => :sun, :source => :sun d next if line =~ /^WARNING/ next if line =~ /localrev\s+remoterev/ next if line =~ /installed\s+catalog/ + next if line =~ /^Checking integrity / # use_gpg + next if line =~ /^gpg: / # gpg verification + next if line =~ /^=+> / # catalog fetch + next if line =~ /^\d+:\d+:\d+ URL:/ # wget without -q blastsplit(line) end.reject { |h| h.nil? } @@ -118,3 +122,4 @@ Puppet::Type.type(:package).provide :pkgutil, :parent => :sun, :source => :sun d pkguti "-y", "-r", @resource[:name] end end + -- cgit From 2725fb3b4821543f2e17f5eaf51d9a95fa177f38 Mon Sep 17 00:00:00 2001 From: rgevaert Date: Tue, 16 Nov 2010 12:03:52 +0100 Subject: Add comments that explain what we are ignoring in the package and remove legacy output --- lib/puppet/provider/package/pkgutil.rb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'lib') diff --git a/lib/puppet/provider/package/pkgutil.rb b/lib/puppet/provider/package/pkgutil.rb index a5f852dd4..1d699f3d2 100755 --- a/lib/puppet/provider/package/pkgutil.rb +++ b/lib/puppet/provider/package/pkgutil.rb @@ -47,9 +47,9 @@ Puppet::Type.type(:package).provide :pkgutil, :parent => :sun, :source => :sun d list = output.split("\n").collect do |line| next if line =~ /^#/ - next if line =~ /^WARNING/ - next if line =~ /localrev\s+remoterev/ - next if line =~ /installed\s+catalog/ + #next if line =~ /^WARNING/ + #next if line =~ /localrev\s+remoterev/ + next if line =~ /installed\s+catalog/ # header of package list next if line =~ /^Checking integrity / # use_gpg next if line =~ /^gpg: / # gpg verification next if line =~ /^=+> / # catalog fetch -- cgit From 300371944b29c9b4f72964e223a74e1b38bb42a7 Mon Sep 17 00:00:00 2001 From: rgevaert Date: Wed, 17 Nov 2010 20:13:41 +0100 Subject: These regular expressions will not match anything. pkgutil doesn't output anything that can be matched. --- lib/puppet/provider/package/pkgutil.rb | 2 -- 1 file changed, 2 deletions(-) (limited to 'lib') diff --git a/lib/puppet/provider/package/pkgutil.rb b/lib/puppet/provider/package/pkgutil.rb index 1d699f3d2..19a62dc1d 100755 --- a/lib/puppet/provider/package/pkgutil.rb +++ b/lib/puppet/provider/package/pkgutil.rb @@ -47,8 +47,6 @@ Puppet::Type.type(:package).provide :pkgutil, :parent => :sun, :source => :sun d list = output.split("\n").collect do |line| next if line =~ /^#/ - #next if line =~ /^WARNING/ - #next if line =~ /localrev\s+remoterev/ next if line =~ /installed\s+catalog/ # header of package list next if line =~ /^Checking integrity / # use_gpg next if line =~ /^gpg: / # gpg verification -- cgit From f50fac7a866fa6c1d546226c5c6d8651eb7ffba6 Mon Sep 17 00:00:00 2001 From: Dominic Cleal Date: Sat, 27 Nov 2010 14:09:35 +0000 Subject: Fixing wget verbose regex --- lib/puppet/provider/package/pkgutil.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lib') diff --git a/lib/puppet/provider/package/pkgutil.rb b/lib/puppet/provider/package/pkgutil.rb index 19a62dc1d..4914aa4f0 100755 --- a/lib/puppet/provider/package/pkgutil.rb +++ b/lib/puppet/provider/package/pkgutil.rb @@ -51,7 +51,7 @@ Puppet::Type.type(:package).provide :pkgutil, :parent => :sun, :source => :sun d next if line =~ /^Checking integrity / # use_gpg next if line =~ /^gpg: / # gpg verification next if line =~ /^=+> / # catalog fetch - next if line =~ /^\d+:\d+:\d+ URL:/ # wget without -q + next if line =~ /\d+:\d+:\d+ URL:/ # wget without -q blastsplit(line) end.reject { |h| h.nil? } -- cgit From 9d63171cf3d3650790bc36c149eef14724487d88 Mon Sep 17 00:00:00 2001 From: Dominic Cleal Date: Mon, 29 Nov 2010 11:33:57 +0000 Subject: Single package queries made more robust when dealing with pkgutil noise --- lib/puppet/provider/package/pkgutil.rb | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'lib') diff --git a/lib/puppet/provider/package/pkgutil.rb b/lib/puppet/provider/package/pkgutil.rb index 4914aa4f0..b80cf74ee 100755 --- a/lib/puppet/provider/package/pkgutil.rb +++ b/lib/puppet/provider/package/pkgutil.rb @@ -53,11 +53,17 @@ Puppet::Type.type(:package).provide :pkgutil, :parent => :sun, :source => :sun d next if line =~ /^=+> / # catalog fetch next if line =~ /\d+:\d+:\d+ URL:/ # wget without -q - blastsplit(line) + parsed = blastsplit(line) + + # When finding one package, ensure we picked up the package line + # itself, not any pkgutil noise. + next if hash[:justme] and parsed[:name] != hash[:justme] + + parsed end.reject { |h| h.nil? } if hash[:justme] - return list[0] + return list[-1] else list.reject! { |h| h[:ensure] == :absent -- cgit From 485ac3865d54b8a0819a75c7d2eb06f11b7daea7 Mon Sep 17 00:00:00 2001 From: Dominic Cleal Date: Mon, 29 Nov 2010 12:01:04 +0000 Subject: Changing indentation to 2-spaces as per 2.6+ style --- lib/puppet/provider/package/pkgutil.rb | 212 ++++++++++++++++----------------- 1 file changed, 106 insertions(+), 106 deletions(-) (limited to 'lib') diff --git a/lib/puppet/provider/package/pkgutil.rb b/lib/puppet/provider/package/pkgutil.rb index b80cf74ee..4e2c0d9f6 100755 --- a/lib/puppet/provider/package/pkgutil.rb +++ b/lib/puppet/provider/package/pkgutil.rb @@ -1,129 +1,129 @@ # Packaging using Peter Bonivart's pkgutil program. Puppet::Type.type(:package).provide :pkgutil, :parent => :sun, :source => :sun do - desc "Package management using Peter Bonivart's ``pkgutil`` command on Solaris." - pkguti = "pkgutil" - if FileTest.executable?("/opt/csw/bin/pkgutil") - pkguti = "/opt/csw/bin/pkgutil" - end + desc "Package management using Peter Bonivart's ``pkgutil`` command on Solaris." + pkguti = "pkgutil" + if FileTest.executable?("/opt/csw/bin/pkgutil") + pkguti = "/opt/csw/bin/pkgutil" + end - confine :operatingsystem => :solaris + confine :operatingsystem => :solaris - commands :pkguti => pkguti + commands :pkguti => pkguti - # This is so stupid, but then, so is blastwave. - ENV["PAGER"] = "/usr/bin/cat" + # This is so stupid, but then, so is blastwave. + ENV["PAGER"] = "/usr/bin/cat" - def self.extended(mod) - unless command(:pkguti) != "pkgutil" - raise Puppet::Error, - "The pkgutil command is missing; pkgutil packaging unavailable" - end + def self.extended(mod) + unless command(:pkguti) != "pkgutil" + raise Puppet::Error, + "The pkgutil command is missing; pkgutil packaging unavailable" + end - unless FileTest.exists?("/var/opt/csw/pkgutil/admin") - Puppet.notice "It is highly recommended you create '/var/opt/csw/pkgutil/admin'." - Puppet.notice "See /var/opt/csw/pkgutil" - end + unless FileTest.exists?("/var/opt/csw/pkgutil/admin") + Puppet.notice "It is highly recommended you create '/var/opt/csw/pkgutil/admin'." + Puppet.notice "See /var/opt/csw/pkgutil" end + end - def self.instances(hash = {}) - blastlist(hash).collect do |bhash| - bhash.delete(:avail) - new(bhash) - end + def self.instances(hash = {}) + blastlist(hash).collect do |bhash| + bhash.delete(:avail) + new(bhash) end + end - # Turn our blastwave listing into a bunch of hashes. - def self.blastlist(hash) - command = ["-c"] - - if hash[:justme] - # The --single option speeds up the execution, because it queries - # the package managament system for one package only. - command << ["--single"] - command << hash[:justme] - end - - output = pkguti command - - list = output.split("\n").collect do |line| - next if line =~ /^#/ - next if line =~ /installed\s+catalog/ # header of package list - next if line =~ /^Checking integrity / # use_gpg - next if line =~ /^gpg: / # gpg verification - next if line =~ /^=+> / # catalog fetch - next if line =~ /\d+:\d+:\d+ URL:/ # wget without -q - - parsed = blastsplit(line) - - # When finding one package, ensure we picked up the package line - # itself, not any pkgutil noise. - next if hash[:justme] and parsed[:name] != hash[:justme] - - parsed - end.reject { |h| h.nil? } - - if hash[:justme] - return list[-1] - else - list.reject! { |h| - h[:ensure] == :absent - } - return list - end + # Turn our blastwave listing into a bunch of hashes. + def self.blastlist(hash) + command = ["-c"] + if hash[:justme] + # The --single option speeds up the execution, because it queries + # the package managament system for one package only. + command << ["--single"] + command << hash[:justme] end - # Split the different lines into hashes. - def self.blastsplit(line) - if line =~ /\s*(\S+)\s+(\S+)\s+(.*)/ - hash = {} - hash[:name] = $1 - hash[:ensure] = if $2 == "notinst" - :absent - else - $2 - end - hash[:avail] = $3 - - if hash[:avail] == "SAME" - hash[:avail] = hash[:ensure] - end - - # Use the name method, so it works with subclasses. - hash[:provider] = self.name - - return hash - else - Puppet.warning "Cannot match %s" % line - return nil - end - end + output = pkguti command - def install - pkguti "-y", "-i", @resource[:name] - end + list = output.split("\n").collect do |line| + next if line =~ /^#/ + next if line =~ /installed\s+catalog/ # header of package list + next if line =~ /^Checking integrity / # use_gpg + next if line =~ /^gpg: / # gpg verification + next if line =~ /^=+> / # catalog fetch + next if line =~ /\d+:\d+:\d+ URL:/ # wget without -q - # Retrieve the version from the current package file. - def latest - hash = self.class.blastlist(:justme => @resource[:name]) - hash[:avail] - end + parsed = blastsplit(line) - def query - if hash = self.class.blastlist(:justme => @resource[:name]) - hash - else - {:ensure => :absent} - end - end + # When finding one package, ensure we picked up the package line + # itself, not any pkgutil noise. + next if hash[:justme] and parsed[:name] != hash[:justme] + + parsed + end.reject { |h| h.nil? } - # Remove the old package, and install the new one - def update - pkguti "-y", "-i", @resource[:name] + if hash[:justme] + return list[-1] + else + list.reject! { |h| + h[:ensure] == :absent + } + return list end - def uninstall - pkguti "-y", "-r", @resource[:name] + end + + # Split the different lines into hashes. + def self.blastsplit(line) + if line =~ /\s*(\S+)\s+(\S+)\s+(.*)/ + hash = {} + hash[:name] = $1 + hash[:ensure] = if $2 == "notinst" + :absent + else + $2 + end + hash[:avail] = $3 + + if hash[:avail] == "SAME" + hash[:avail] = hash[:ensure] + end + + # Use the name method, so it works with subclasses. + hash[:provider] = self.name + + return hash + else + Puppet.warning "Cannot match %s" % line + return nil + end + end + + def install + pkguti "-y", "-i", @resource[:name] + end + + # Retrieve the version from the current package file. + def latest + hash = self.class.blastlist(:justme => @resource[:name]) + hash[:avail] + end + + def query + if hash = self.class.blastlist(:justme => @resource[:name]) + hash + else + {:ensure => :absent} end + end + + # Remove the old package, and install the new one + def update + pkguti "-y", "-i", @resource[:name] + end + + def uninstall + pkguti "-y", "-r", @resource[:name] + end end -- cgit From f8e9155926188f66c1918b51950686d3abad8b78 Mon Sep 17 00:00:00 2001 From: Dominic Cleal Date: Mon, 29 Nov 2010 12:40:19 +0000 Subject: Removing blastwave references and unused PAGER --- lib/puppet/provider/package/pkgutil.rb | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) (limited to 'lib') diff --git a/lib/puppet/provider/package/pkgutil.rb b/lib/puppet/provider/package/pkgutil.rb index 4e2c0d9f6..b9d0ea4eb 100755 --- a/lib/puppet/provider/package/pkgutil.rb +++ b/lib/puppet/provider/package/pkgutil.rb @@ -10,9 +10,6 @@ Puppet::Type.type(:package).provide :pkgutil, :parent => :sun, :source => :sun d commands :pkguti => pkguti - # This is so stupid, but then, so is blastwave. - ENV["PAGER"] = "/usr/bin/cat" - def self.extended(mod) unless command(:pkguti) != "pkgutil" raise Puppet::Error, @@ -26,14 +23,15 @@ Puppet::Type.type(:package).provide :pkgutil, :parent => :sun, :source => :sun d end def self.instances(hash = {}) - blastlist(hash).collect do |bhash| + pkglist(hash).collect do |bhash| bhash.delete(:avail) new(bhash) end end - # Turn our blastwave listing into a bunch of hashes. - def self.blastlist(hash) + # Turn our pkgutil -c listing into a bunch of hashes. + # Supports :justme => packagename, which uses the optimised --single arg + def self.pkglist(hash) command = ["-c"] if hash[:justme] @@ -53,7 +51,7 @@ Puppet::Type.type(:package).provide :pkgutil, :parent => :sun, :source => :sun d next if line =~ /^=+> / # catalog fetch next if line =~ /\d+:\d+:\d+ URL:/ # wget without -q - parsed = blastsplit(line) + parsed = pkgsplit(line) # When finding one package, ensure we picked up the package line # itself, not any pkgutil noise. @@ -74,7 +72,7 @@ Puppet::Type.type(:package).provide :pkgutil, :parent => :sun, :source => :sun d end # Split the different lines into hashes. - def self.blastsplit(line) + def self.pkgsplit(line) if line =~ /\s*(\S+)\s+(\S+)\s+(.*)/ hash = {} hash[:name] = $1 @@ -105,12 +103,12 @@ Puppet::Type.type(:package).provide :pkgutil, :parent => :sun, :source => :sun d # Retrieve the version from the current package file. def latest - hash = self.class.blastlist(:justme => @resource[:name]) + hash = self.class.pkglist(:justme => @resource[:name]) hash[:avail] end def query - if hash = self.class.blastlist(:justme => @resource[:name]) + if hash = self.class.pkglist(:justme => @resource[:name]) hash else {:ensure => :absent} -- cgit From 3eace859f20d9ac7366382826028af44c3ab62d6 Mon Sep 17 00:00:00 2001 From: Dominic Cleal Date: Mon, 29 Nov 2010 12:41:18 +0000 Subject: Fixing indentation --- lib/puppet/provider/package/pkgutil.rb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'lib') diff --git a/lib/puppet/provider/package/pkgutil.rb b/lib/puppet/provider/package/pkgutil.rb index b9d0ea4eb..dacd70a01 100755 --- a/lib/puppet/provider/package/pkgutil.rb +++ b/lib/puppet/provider/package/pkgutil.rb @@ -47,9 +47,9 @@ Puppet::Type.type(:package).provide :pkgutil, :parent => :sun, :source => :sun d next if line =~ /^#/ next if line =~ /installed\s+catalog/ # header of package list next if line =~ /^Checking integrity / # use_gpg - next if line =~ /^gpg: / # gpg verification - next if line =~ /^=+> / # catalog fetch - next if line =~ /\d+:\d+:\d+ URL:/ # wget without -q + next if line =~ /^gpg: / # gpg verification + next if line =~ /^=+> / # catalog fetch + next if line =~ /\d+:\d+:\d+ URL:/ # wget without -q parsed = pkgsplit(line) -- cgit From 8462acd0e8021d7ea11215bee1838d4b4beddbb5 Mon Sep 17 00:00:00 2001 From: Dominic Cleal Date: Sun, 20 Feb 2011 11:36:19 +0000 Subject: * Fix exception on parse failure of pkgutil output * Fix exception when querying latest version for unknown package --- lib/puppet/provider/package/pkgutil.rb | 19 ++++++------------- 1 file changed, 6 insertions(+), 13 deletions(-) (limited to 'lib') diff --git a/lib/puppet/provider/package/pkgutil.rb b/lib/puppet/provider/package/pkgutil.rb index dacd70a01..f0900dc22 100755 --- a/lib/puppet/provider/package/pkgutil.rb +++ b/lib/puppet/provider/package/pkgutil.rb @@ -37,7 +37,7 @@ Puppet::Type.type(:package).provide :pkgutil, :parent => :sun, :source => :sun d if hash[:justme] # The --single option speeds up the execution, because it queries # the package managament system for one package only. - command << ["--single"] + command << "--single" command << hash[:justme] end @@ -51,21 +51,15 @@ Puppet::Type.type(:package).provide :pkgutil, :parent => :sun, :source => :sun d next if line =~ /^=+> / # catalog fetch next if line =~ /\d+:\d+:\d+ URL:/ # wget without -q - parsed = pkgsplit(line) - - # When finding one package, ensure we picked up the package line - # itself, not any pkgutil noise. - next if hash[:justme] and parsed[:name] != hash[:justme] - - parsed + pkgsplit(line) end.reject { |h| h.nil? } if hash[:justme] + # Ensure we picked up the package line, not any pkgutil noise. + list.reject! { |h| h[:name] != hash[:justme] } return list[-1] else - list.reject! { |h| - h[:ensure] == :absent - } + list.reject! { |h| h[:ensure] == :absent } return list end @@ -104,7 +98,7 @@ Puppet::Type.type(:package).provide :pkgutil, :parent => :sun, :source => :sun d # Retrieve the version from the current package file. def latest hash = self.class.pkglist(:justme => @resource[:name]) - hash[:avail] + hash[:avail] if hash end def query @@ -115,7 +109,6 @@ Puppet::Type.type(:package).provide :pkgutil, :parent => :sun, :source => :sun d end end - # Remove the old package, and install the new one def update pkguti "-y", "-i", @resource[:name] end -- cgit From 15a53f0ac79cb3f164750d53219d02ad6515f02c Mon Sep 17 00:00:00 2001 From: Juerg Walz Date: Tue, 22 Feb 2011 09:24:03 +0800 Subject: (#4258) pkgutil provider: misc enhancements Several enhancements and bug-fixes for the pkgutil package provider: - handle "Not in catalog" - fix "SAME" version detection - allow short package name (w/o CSW) to match (-> no need to specify a different package name for different operating systems, ex. "ruby") - use the "-u" command line switch for updates --- lib/puppet/provider/package/pkgutil.rb | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) (limited to 'lib') diff --git a/lib/puppet/provider/package/pkgutil.rb b/lib/puppet/provider/package/pkgutil.rb index f0900dc22..0e2056b54 100755 --- a/lib/puppet/provider/package/pkgutil.rb +++ b/lib/puppet/provider/package/pkgutil.rb @@ -51,12 +51,12 @@ Puppet::Type.type(:package).provide :pkgutil, :parent => :sun, :source => :sun d next if line =~ /^=+> / # catalog fetch next if line =~ /\d+:\d+:\d+ URL:/ # wget without -q - pkgsplit(line) + pkgsplit(line, hash[:justme]) end.reject { |h| h.nil? } if hash[:justme] # Ensure we picked up the package line, not any pkgutil noise. - list.reject! { |h| h[:name] != hash[:justme] } + list.reject! { |h| h[:name] !~ /#{hash[:justme]}$/ } return list[-1] else list.reject! { |h| h[:ensure] == :absent } @@ -66,8 +66,11 @@ Puppet::Type.type(:package).provide :pkgutil, :parent => :sun, :source => :sun d end # Split the different lines into hashes. - def self.pkgsplit(line) - if line =~ /\s*(\S+)\s+(\S+)\s+(.*)/ + def self.pkgsplit(line, justme) + if line == "Not in catalog" + Puppet.warning "Package not in pkgutil catalog: %s" % justme + return nil + elsif line =~ /\s*(\S+)\s+(\S+)\s+(.*)/ hash = {} hash[:name] = $1 hash[:ensure] = if $2 == "notinst" @@ -77,7 +80,7 @@ Puppet::Type.type(:package).provide :pkgutil, :parent => :sun, :source => :sun d end hash[:avail] = $3 - if hash[:avail] == "SAME" + if hash[:avail] =~ /^SAME\s*$/ hash[:avail] = hash[:ensure] end @@ -110,7 +113,7 @@ Puppet::Type.type(:package).provide :pkgutil, :parent => :sun, :source => :sun d end def update - pkguti "-y", "-i", @resource[:name] + pkguti "-y", "-u", @resource[:name] end def uninstall -- cgit From 58ac7d385ebaa8755fe44df5a3d2db98b4bf4693 Mon Sep 17 00:00:00 2001 From: Juerg Walz Date: Tue, 8 Mar 2011 12:39:25 +0800 Subject: (#4258) pkgutil provider: better handling of short package names --- lib/puppet/provider/package/pkgutil.rb | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'lib') diff --git a/lib/puppet/provider/package/pkgutil.rb b/lib/puppet/provider/package/pkgutil.rb index 0e2056b54..4a87932a8 100755 --- a/lib/puppet/provider/package/pkgutil.rb +++ b/lib/puppet/provider/package/pkgutil.rb @@ -56,7 +56,7 @@ Puppet::Type.type(:package).provide :pkgutil, :parent => :sun, :source => :sun d if hash[:justme] # Ensure we picked up the package line, not any pkgutil noise. - list.reject! { |h| h[:name] !~ /#{hash[:justme]}$/ } + list.reject! { |h| h[:name] != hash[:justme] } return list[-1] else list.reject! { |h| h[:ensure] == :absent } @@ -80,6 +80,10 @@ Puppet::Type.type(:package).provide :pkgutil, :parent => :sun, :source => :sun d end hash[:avail] = $3 + if justme !~ /^[A-Z]+/ + hash[:name].sub! /^[A-Z]+/, '' + end + if hash[:avail] =~ /^SAME\s*$/ hash[:avail] = hash[:ensure] end -- cgit From e5827098b11fd8f9922a3e9f80c8c573d302a4d4 Mon Sep 17 00:00:00 2001 From: Juerg Walz Date: Thu, 10 Mar 2011 15:44:28 +0800 Subject: (#4258) pkgutil: bug fix: if shortname is not equal to package name --- lib/puppet/provider/package/pkgutil.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'lib') diff --git a/lib/puppet/provider/package/pkgutil.rb b/lib/puppet/provider/package/pkgutil.rb index 4a87932a8..3a23796e2 100755 --- a/lib/puppet/provider/package/pkgutil.rb +++ b/lib/puppet/provider/package/pkgutil.rb @@ -80,8 +80,8 @@ Puppet::Type.type(:package).provide :pkgutil, :parent => :sun, :source => :sun d end hash[:avail] = $3 - if justme !~ /^[A-Z]+/ - hash[:name].sub! /^[A-Z]+/, '' + if justme + hash[:name] = justme end if hash[:avail] =~ /^SAME\s*$/ -- cgit From 7c99dd966845fde026178a50b62c52735b2e5a1b Mon Sep 17 00:00:00 2001 From: Dominic Cleal Date: Sat, 19 Mar 2011 00:07:30 +0000 Subject: (#4258) Use pkgutil -a to reliably determine package common names/aliases Populate instances with both the real package name ("CSWsvn") and the alias name ("subversion") from separate "pkgutil -a" call. Fixed cases where pkgutil noise was parsed as aliased package names and also breaking "not in catalog" detection. Updated pkgutil_spec test to show various edge cases. --- lib/puppet/provider/package/pkgutil.rb | 86 +++++++++++++++++++++++++--------- 1 file changed, 63 insertions(+), 23 deletions(-) (limited to 'lib') diff --git a/lib/puppet/provider/package/pkgutil.rb b/lib/puppet/provider/package/pkgutil.rb index 3a23796e2..350cacc18 100755 --- a/lib/puppet/provider/package/pkgutil.rb +++ b/lib/puppet/provider/package/pkgutil.rb @@ -23,10 +23,45 @@ Puppet::Type.type(:package).provide :pkgutil, :parent => :sun, :source => :sun d end def self.instances(hash = {}) - pkglist(hash).collect do |bhash| - bhash.delete(:avail) - new(bhash) + # Use the available pkg list (-a) to work out aliases + aliases = {} + availlist.each do |pkg| + aliases[pkg[:name]] = pkg[:alias] end + + # The -c pkglist lists installed packages + pkginsts = [] + pkglist(hash).each do |pkg| + pkg.delete(:avail) + pkginsts << new(pkg) + + # Create a second instance with the alias if it's different + pkgalias = aliases[pkg[:name]] + if pkgalias and pkg[:name] != pkgalias + apkg = Hash.new(pkg) + apkg[:name] = pkgalias + pkginsts << new(apkg) + end + end + + pkginsts + end + + # Turns a pkgutil -a listing into hashes with the common alias, full + # package name and available version + def self.availlist + output = pkguti ["-a"] + + list = output.split("\n").collect do |line| + next if line =~ /^common\s+package/ # header of package list + next if noise?(line) + + if line =~ /\s*(\S+)\s+(\S+)\s+(.*)/ + { :alias => $1, :name => $2, :avail => $3 } + else + Puppet.warning "Cannot match %s" % line + end + end.reject { |h| h.nil? } end # Turn our pkgutil -c listing into a bunch of hashes. @@ -41,36 +76,45 @@ Puppet::Type.type(:package).provide :pkgutil, :parent => :sun, :source => :sun d command << hash[:justme] end - output = pkguti command + output = pkguti(command).split("\n") - list = output.split("\n").collect do |line| - next if line =~ /^#/ + if output[-1] == "Not in catalog" + Puppet.warning "Package not in pkgutil catalog: %s" % hash[:justme] + return nil + end + + list = output.collect do |line| next if line =~ /installed\s+catalog/ # header of package list - next if line =~ /^Checking integrity / # use_gpg - next if line =~ /^gpg: / # gpg verification - next if line =~ /^=+> / # catalog fetch - next if line =~ /\d+:\d+:\d+ URL:/ # wget without -q + next if noise?(line) - pkgsplit(line, hash[:justme]) + pkgsplit(line) end.reject { |h| h.nil? } if hash[:justme] - # Ensure we picked up the package line, not any pkgutil noise. - list.reject! { |h| h[:name] != hash[:justme] } - return list[-1] + # Single queries may have been for an alias so return the name requested + if list.any? + list[-1][:name] = hash[:justme] + return list[-1] + end else list.reject! { |h| h[:ensure] == :absent } return list end + end + # Identify common types of pkgutil noise as it downloads catalogs etc + def self.noise?(line) + true if line =~ /^#/ + true if line =~ /^Checking integrity / # use_gpg + true if line =~ /^gpg: / # gpg verification + true if line =~ /^=+> / # catalog fetch + true if line =~ /\d+:\d+:\d+ URL:/ # wget without -q + false end # Split the different lines into hashes. - def self.pkgsplit(line, justme) - if line == "Not in catalog" - Puppet.warning "Package not in pkgutil catalog: %s" % justme - return nil - elsif line =~ /\s*(\S+)\s+(\S+)\s+(.*)/ + def self.pkgsplit(line) + if line =~ /\s*(\S+)\s+(\S+)\s+(.*)/ hash = {} hash[:name] = $1 hash[:ensure] = if $2 == "notinst" @@ -80,10 +124,6 @@ Puppet::Type.type(:package).provide :pkgutil, :parent => :sun, :source => :sun d end hash[:avail] = $3 - if justme - hash[:name] = justme - end - if hash[:avail] =~ /^SAME\s*$/ hash[:avail] = hash[:ensure] end -- cgit From 557ed85fd4c03cf3a5c48dce25000db6e71021a9 Mon Sep 17 00:00:00 2001 From: Dominic Cleal Date: Tue, 22 Mar 2011 22:48:39 +0000 Subject: (#4258) Fix hash duplication affecting canonical provider instance --- lib/puppet/provider/package/pkgutil.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lib') diff --git a/lib/puppet/provider/package/pkgutil.rb b/lib/puppet/provider/package/pkgutil.rb index 350cacc18..30f23e059 100755 --- a/lib/puppet/provider/package/pkgutil.rb +++ b/lib/puppet/provider/package/pkgutil.rb @@ -38,7 +38,7 @@ Puppet::Type.type(:package).provide :pkgutil, :parent => :sun, :source => :sun d # Create a second instance with the alias if it's different pkgalias = aliases[pkg[:name]] if pkgalias and pkg[:name] != pkgalias - apkg = Hash.new(pkg) + apkg = pkg.dup apkg[:name] = pkgalias pkginsts << new(apkg) end -- cgit From ef86105215a00f428e9cdc251b6a29b8e11487bb Mon Sep 17 00:00:00 2001 From: Juerg Walz Date: Tue, 5 Apr 2011 10:35:42 +0800 Subject: (#4258) Check wgetopts in pkgutil.conf --- lib/puppet/provider/package/pkgutil.rb | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'lib') diff --git a/lib/puppet/provider/package/pkgutil.rb b/lib/puppet/provider/package/pkgutil.rb index 30f23e059..08d74df29 100755 --- a/lib/puppet/provider/package/pkgutil.rb +++ b/lib/puppet/provider/package/pkgutil.rb @@ -6,6 +6,13 @@ Puppet::Type.type(:package).provide :pkgutil, :parent => :sun, :source => :sun d pkguti = "/opt/csw/bin/pkgutil" end + pkgutilconf = File.open("/etc/opt/csw/pkgutil.conf") + correct_wgetopts = false + pkgutilconf.each {|line| correct_wgetopts = true if line =~ /^\s*wgetopts\s*=.*-nv/ } + if ! correct_wgetopts + Puppet.notice "It is highly recommended that you set 'wgetopts=-nv' in your pkgutil.conf." + end + confine :operatingsystem => :solaris commands :pkguti => pkguti -- cgit From f8c2f1afa4a9ef71681a96b83b2abdc303a4b0bf Mon Sep 17 00:00:00 2001 From: Dominic Cleal Date: Wed, 13 Apr 2011 09:44:04 +0100 Subject: (#4258) Stop file and config checks from breaking spec Moved all file and config checks into healthcheck method which is then stubbed in the spec. --- lib/puppet/provider/package/pkgutil.rb | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) (limited to 'lib') diff --git a/lib/puppet/provider/package/pkgutil.rb b/lib/puppet/provider/package/pkgutil.rb index 08d74df29..760ce01db 100755 --- a/lib/puppet/provider/package/pkgutil.rb +++ b/lib/puppet/provider/package/pkgutil.rb @@ -6,19 +6,12 @@ Puppet::Type.type(:package).provide :pkgutil, :parent => :sun, :source => :sun d pkguti = "/opt/csw/bin/pkgutil" end - pkgutilconf = File.open("/etc/opt/csw/pkgutil.conf") - correct_wgetopts = false - pkgutilconf.each {|line| correct_wgetopts = true if line =~ /^\s*wgetopts\s*=.*-nv/ } - if ! correct_wgetopts - Puppet.notice "It is highly recommended that you set 'wgetopts=-nv' in your pkgutil.conf." - end - confine :operatingsystem => :solaris commands :pkguti => pkguti - def self.extended(mod) - unless command(:pkguti) != "pkgutil" + def self.healthcheck() + if pkguti == "pkgutil" raise Puppet::Error, "The pkgutil command is missing; pkgutil packaging unavailable" end @@ -27,9 +20,18 @@ Puppet::Type.type(:package).provide :pkgutil, :parent => :sun, :source => :sun d Puppet.notice "It is highly recommended you create '/var/opt/csw/pkgutil/admin'." Puppet.notice "See /var/opt/csw/pkgutil" end + + pkgutilconf = File.open("/etc/opt/csw/pkgutil.conf") + correct_wgetopts = false + pkgutilconf.each {|line| correct_wgetopts = true if line =~ /^\s*wgetopts\s*=.*-nv/ } + if ! correct_wgetopts + Puppet.notice "It is highly recommended that you set 'wgetopts=-nv' in your pkgutil.conf." + end end def self.instances(hash = {}) + healthcheck + # Use the available pkg list (-a) to work out aliases aliases = {} availlist.each do |pkg| -- cgit From 7726dc3f7d9fa45e94e748fe5679e89d96dd817f Mon Sep 17 00:00:00 2001 From: Dominic Cleal Date: Wed, 13 Apr 2011 09:50:41 +0100 Subject: (#4258) Permit variations of -nv in both pkgutil.conf files --- lib/puppet/provider/package/pkgutil.rb | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'lib') diff --git a/lib/puppet/provider/package/pkgutil.rb b/lib/puppet/provider/package/pkgutil.rb index 760ce01db..2661cedef 100755 --- a/lib/puppet/provider/package/pkgutil.rb +++ b/lib/puppet/provider/package/pkgutil.rb @@ -21,9 +21,11 @@ Puppet::Type.type(:package).provide :pkgutil, :parent => :sun, :source => :sun d Puppet.notice "See /var/opt/csw/pkgutil" end - pkgutilconf = File.open("/etc/opt/csw/pkgutil.conf") correct_wgetopts = false - pkgutilconf.each {|line| correct_wgetopts = true if line =~ /^\s*wgetopts\s*=.*-nv/ } + [ "/opt/csw/etc/pkgutil.conf", "/etc/opt/csw/pkgutil.conf" ].each do |confpath| + pkgutilconf = File.open(confpath) + pkgutilconf.each {|line| correct_wgetopts = true if line =~ /^\s*wgetopts\s*=.*(-nv|-q|--no-verbose|--quiet)/ } + end if ! correct_wgetopts Puppet.notice "It is highly recommended that you set 'wgetopts=-nv' in your pkgutil.conf." end -- cgit From fd983410d841fec2408ded0700c841bf201eafbb Mon Sep 17 00:00:00 2001 From: Dominic Cleal Date: Wed, 13 Apr 2011 10:34:40 +0100 Subject: (#4258) Fix fd leak opening pkgutil config files --- lib/puppet/provider/package/pkgutil.rb | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'lib') diff --git a/lib/puppet/provider/package/pkgutil.rb b/lib/puppet/provider/package/pkgutil.rb index 2661cedef..ab8a507f6 100755 --- a/lib/puppet/provider/package/pkgutil.rb +++ b/lib/puppet/provider/package/pkgutil.rb @@ -23,8 +23,9 @@ Puppet::Type.type(:package).provide :pkgutil, :parent => :sun, :source => :sun d correct_wgetopts = false [ "/opt/csw/etc/pkgutil.conf", "/etc/opt/csw/pkgutil.conf" ].each do |confpath| - pkgutilconf = File.open(confpath) - pkgutilconf.each {|line| correct_wgetopts = true if line =~ /^\s*wgetopts\s*=.*(-nv|-q|--no-verbose|--quiet)/ } + File.open(confpath) do |conf| + conf.each {|line| correct_wgetopts = true if line =~ /^\s*wgetopts\s*=.*(-nv|-q|--no-verbose|--quiet)/ } + end end if ! correct_wgetopts Puppet.notice "It is highly recommended that you set 'wgetopts=-nv' in your pkgutil.conf." -- cgit From cb552af357763310ca4a16bf514dd39fcbd203bf Mon Sep 17 00:00:00 2001 From: Dominic Cleal Date: Wed, 13 Apr 2011 13:10:40 +0100 Subject: (#4258) Remove superfluous command check that called pkgutil --- lib/puppet/provider/package/pkgutil.rb | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) (limited to 'lib') diff --git a/lib/puppet/provider/package/pkgutil.rb b/lib/puppet/provider/package/pkgutil.rb index ab8a507f6..a1d844f73 100755 --- a/lib/puppet/provider/package/pkgutil.rb +++ b/lib/puppet/provider/package/pkgutil.rb @@ -1,21 +1,17 @@ # Packaging using Peter Bonivart's pkgutil program. Puppet::Type.type(:package).provide :pkgutil, :parent => :sun, :source => :sun do desc "Package management using Peter Bonivart's ``pkgutil`` command on Solaris." - pkguti = "pkgutil" + + pkgutil_bin = "pkgutil" if FileTest.executable?("/opt/csw/bin/pkgutil") - pkguti = "/opt/csw/bin/pkgutil" + pkgutil_bin = "/opt/csw/bin/pkgutil" end confine :operatingsystem => :solaris - commands :pkguti => pkguti + commands :pkguti => pkgutil_bin def self.healthcheck() - if pkguti == "pkgutil" - raise Puppet::Error, - "The pkgutil command is missing; pkgutil packaging unavailable" - end - unless FileTest.exists?("/var/opt/csw/pkgutil/admin") Puppet.notice "It is highly recommended you create '/var/opt/csw/pkgutil/admin'." Puppet.notice "See /var/opt/csw/pkgutil" -- cgit