3 Using --parsable=0 option to obsolete pkg list -Hn |
3 Using --parsable=0 option to obsolete pkg list -Hn |
4 Fixing problem with ambiguous package names |
4 Fixing problem with ambiguous package names |
5 Wildcards support |
5 Wildcards support |
6 install_options/uninstall_options features support |
6 install_options/uninstall_options features support |
7 |
7 |
8 --- puppet-3.8.6/lib/puppet/provider/package/pkg.orig 2016-04-13 14:39:48.421008932 -0700 |
8 --- puppet-3.8.6/lib/puppet/provider/package/pkg.rb.orig 2016-04-19 15:09:14.789792650 -0700 |
9 +++ puppet-3.8.6/lib/puppet/provider/package/pkg.rb 2016-04-13 14:27:31.382336591 -0700 |
9 +++ puppet-3.8.6/lib/puppet/provider/package/pkg.rb 2016-04-19 15:09:44.646514474 -0700 |
10 @@ -1,7 +1,8 @@ |
10 @@ -5,7 +5,7 @@ |
11 +require 'json' |
|
12 require 'puppet/provider/package' |
11 require 'puppet/provider/package' |
13 |
12 |
14 Puppet::Type.type(:package).provide :pkg, :parent => Puppet::Provider::Package do |
13 Puppet::Type.type(:package).provide :pkg, :parent => Puppet::Provider::Package do |
15 - desc "OpenSolaris image packaging system. See pkg(5) for more information" |
14 - desc "OpenSolaris image packaging system. See pkg(5) for more information" |
16 + desc "Solaris image packaging system. See pkg(5) for more information" |
15 + desc "Solaris image packaging system. See pkg(5) for more information" |
17 # http://docs.oracle.com/cd/E19963-01/html/820-6572/managepkgs.html |
16 # http://docs.oracle.com/cd/E19963-01/html/820-6572/managepkgs.html |
18 # A few notes before we start : |
17 # A few notes before we start : |
19 # Opensolaris pkg has two slightly different formats (as of now.) |
18 # Opensolaris pkg has two slightly different formats (as of now.) |
20 @@ -14,10 +15,10 @@ |
19 @@ -18,10 +18,10 @@ |
21 # TODO: We still have to allow packages to specify a preferred publisher. |
20 # TODO: We still have to allow packages to specify a preferred publisher. |
22 |
21 |
23 has_feature :versionable |
22 has_feature :versionable |
24 - |
23 - |
25 has_feature :upgradable |
24 has_feature :upgradable |
28 + has_feature :install_options |
27 + has_feature :install_options |
29 + has_feature :uninstall_options |
28 + has_feature :uninstall_options |
30 |
29 |
31 commands :pkg => "/usr/bin/pkg" |
30 commands :pkg => "/usr/bin/pkg" |
32 |
31 |
33 @@ -26,7 +27,7 @@ |
32 @@ -30,7 +30,7 @@ |
34 defaultfor :osfamily => :solaris, :kernelrelease => ['5.11', '5.12'] |
33 defaultfor :osfamily => :solaris, :kernelrelease => ['5.11', '5.12'] |
35 |
34 |
36 def self.instances |
35 def self.instances |
37 - pkg(:list, '-H').split("\n").map{|l| new(parse_line(l))} |
36 - pkg(:list, '-H').split("\n").map{|l| new(parse_line(l))} |
38 + pkg(:list, '-Hv').split("\n").map{|l| new(parse_line(l))} |
37 + pkg(:list, '-Hv').split("\n").map{|l| new(parse_line(l))} |
39 end |
38 end |
40 |
39 |
41 # The IFO flag field is just what it names, the first field can have ether |
40 # The IFO flag field is just what it names, the first field can have ether |
42 @@ -69,6 +70,10 @@ |
41 @@ -73,6 +73,10 @@ |
43 {} |
42 {} |
44 end |
43 end |
45 |
44 |
46 + def self.ufxi_flag(flags) |
45 + def self.ufxi_flag(flags) |
47 + {} |
46 + {} |
48 + end |
47 + end |
49 + |
48 + |
50 # pkg state was present in the older version of pkg (with UFOXI) but is |
49 # pkg state was present in the older version of pkg (with UFOXI) but is |
51 # no longer available with the IFO field version. When it was present, |
50 # no longer available with the IFO field version. When it was present, |
52 # it was used to indicate that a particular version was present (installed) |
51 # it was used to indicate that a particular version was present (installed) |
53 @@ -90,29 +95,73 @@ |
52 @@ -94,29 +98,73 @@ |
54 # formats of output for different pkg versions. |
53 # formats of output for different pkg versions. |
55 def self.parse_line(line) |
54 def self.parse_line(line) |
56 (case line.chomp |
55 (case line.chomp |
57 - # NAME (PUBLISHER) VERSION IFO (new:630e1ffc7a19) |
56 - # NAME (PUBLISHER) VERSION IFO (new:630e1ffc7a19) |
58 - # system/core-os 0.5.11-0.169 i-- |
57 - # system/core-os 0.5.11-0.169 i-- |
140 + end |
139 + end |
141 + |
140 + |
142 def hold |
141 def hold |
143 pkg(:freeze, @resource[:name]) |
142 pkg(:freeze, @resource[:name]) |
144 end |
143 end |
145 @@ -122,31 +171,22 @@ |
144 @@ -126,31 +174,22 @@ |
146 raise Puppet::Error, "Unable to unfreeze #{r[:out]}" unless [0,4].include? r[:exit] |
145 raise Puppet::Error, "Unable to unfreeze #{r[:out]}" unless [0,4].include? r[:exit] |
147 end |
146 end |
148 |
147 |
149 - # Return the version of the package. Note that the bug |
148 - # Return the version of the package. Note that the bug |
150 - # http://defect.opensolaris.org/bz/show_bug.cgi?id=19159% |
149 - # http://defect.opensolaris.org/bz/show_bug.cgi?id=19159% |
187 + Puppet.debug "Desirable query status = #{lst}" |
186 + Puppet.debug "Desirable query status = #{lst}" |
188 + return lst[:ensure] |
187 + return lst[:ensure] |
189 end |
188 end |
190 |
189 |
191 # install the package and accept all licenses. |
190 # install the package and accept all licenses. |
192 @@ -162,19 +202,22 @@ |
191 @@ -166,19 +205,22 @@ |
193 self.uninstall if Puppet::Util::Package.versioncmp(should, is[:ensure]) < 0 |
192 self.uninstall if Puppet::Util::Package.versioncmp(should, is[:ensure]) < 0 |
194 end |
193 end |
195 end |
194 end |
196 - r = exec_cmd(command(:pkg), 'install', '--accept', name) |
195 - r = exec_cmd(command(:pkg), 'install', '--accept', name) |
197 + |
196 + |
213 end |
212 end |
214 + cmd << join_options(@resource[:uninstall_options]) if @resource[:uninstall_options] |
213 + cmd << join_options(@resource[:uninstall_options]) if @resource[:uninstall_options] |
215 cmd << @resource[:name] |
214 cmd << @resource[:name] |
216 pkg cmd |
215 pkg cmd |
217 end |
216 end |
218 @@ -187,10 +230,22 @@ |
217 @@ -191,10 +233,22 @@ |
219 raise Puppet::Error, "Unable to update #{r[:out]}" |
218 raise Puppet::Error, "Unable to update #{r[:out]}" |
220 end |
219 end |
221 |
220 |
222 + def wildcard? |
221 + def wildcard? |
223 + @resource[:name].include?("*") || @resource[:name].include?("?") |
222 + @resource[:name].include?("*") || @resource[:name].include?("?") |