summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorluke <luke@980ebf18-57e1-0310-9a29-db15c13687c0>2006-03-13 17:04:35 +0000
committerluke <luke@980ebf18-57e1-0310-9a29-db15c13687c0>2006-03-13 17:04:35 +0000
commitf851be7c9d966d18e793b66a28d35a8e62dd04a0 (patch)
tree6e9310d190032bf428e2a2e5c7a017a1cb178146 /lib
parent4d1c221d063af33f1cb1745a43036c8a2a20e904 (diff)
downloadpuppet-f851be7c9d966d18e793b66a28d35a8e62dd04a0.tar.gz
puppet-f851be7c9d966d18e793b66a28d35a8e62dd04a0.tar.xz
puppet-f851be7c9d966d18e793b66a28d35a8e62dd04a0.zip
Adding upgrade ability to sun packages. Currently it removes the old package and installs the new one.
git-svn-id: https://reductivelabs.com/svn/puppet/trunk@1019 980ebf18-57e1-0310-9a29-db15c13687c0
Diffstat (limited to 'lib')
-rwxr-xr-xlib/puppet/type/package/sun.rb87
1 files changed, 52 insertions, 35 deletions
diff --git a/lib/puppet/type/package/sun.rb b/lib/puppet/type/package/sun.rb
index e8e17bdf4..e58980228 100755
--- a/lib/puppet/type/package/sun.rb
+++ b/lib/puppet/type/package/sun.rb
@@ -1,34 +1,7 @@
module Puppet
Puppet.type(:package).newpkgtype(:sunpkg) do
- def install
- unless self[:source]
- raise Puppet::Error, "Sun packages must specify a package source"
- end
- #cmd = "pkgadd -d %s -n %s 2>&1" % [self[:source], self[:name]]
- cmd = ["pkgadd"]
-
- if self[:adminfile]
- cmd += ["-a", self[:adminfile]]
- end
-
- if self[:responsefile]
- cmd += ["-r", self[:responsefile]]
- end
-
- cmd += ["-d", self[:source]]
- cmd += ["-n", self[:name]]
- cmd << "2>&1"
- cmd = cmd.join(" ")
-
- self.info "Executing %s" % cmd.inspect
- output = %x{#{cmd} 2>&1}
-
- unless $? == 0
- raise Puppet::PackageError.new(output)
- end
- end
-
- def query
+ # Get info on a package, optionally specifying a device.
+ def info2hash(device = nil)
names = {
"PKGINST" => :name,
"NAME" => nil,
@@ -48,9 +21,14 @@ module Puppet
}
hash = {}
+ cmd = "pkginfo -l"
+ if device
+ cmd += " -d #{device}"
+ end
+ cmd += " #{self[:name]} 2>/dev/null"
# list out all of the packages
- open("| pkginfo -l %s 2>/dev/null" % self[:name]) { |process|
+ open("| #{cmd}") { |process|
# we're using the long listing, so each line is a separate
# piece of information
process.each { |line|
@@ -79,6 +57,39 @@ module Puppet
end
end
+ def install
+ unless self[:source]
+ raise Puppet::Error, "Sun packages must specify a package source"
+ end
+ cmd = ["pkgadd"]
+
+ if self[:adminfile]
+ cmd += ["-a", self[:adminfile]]
+ end
+
+ if self[:responsefile]
+ cmd += ["-r", self[:responsefile]]
+ end
+
+ cmd += ["-d", self[:source]]
+ cmd += ["-n", self[:name]]
+ cmd << "2>&1"
+ cmd = cmd.join(" ")
+
+ self.info "Executing %s" % cmd.inspect
+ output = %x{#{cmd} 2>&1}
+
+ unless $? == 0
+ raise Puppet::PackageError.new(output)
+ end
+ end
+
+ # Retrieve the version from the current package file.
+ def latest
+ hash = info2hash(self[:source])
+ hash[:ensure]
+ end
+
def list
packages = []
hash = {}
@@ -126,11 +137,9 @@ module Puppet
return packages
end
- # we need package retrieval mechanisms before we can have package
- # installation mechanisms...
- #type.install = proc { |pkg|
- # raise "installation not implemented yet"
- #}
+ def query
+ info2hash()
+ end
def uninstall
cmd = "pkgrm -n %s 2>&1" % self[:name]
@@ -139,5 +148,13 @@ module Puppet
raise Puppet::Error, "Removal of %s failed: %s" % [self.name, output]
end
end
+
+ # Remove the old package, and install the new one
+ def update
+ if @states[:ensure].is != :absent
+ self.uninstall
+ end
+ self.install
+ end
end
end