summaryrefslogtreecommitdiffstats
path: root/lib/puppet/provider/package/up2date.rb
blob: 42234e8aba0165a99de7e5bb77845fa8c1198bbe (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
Puppet.type(:package).provide :up2date, :parent => :rpm do
    desc "Support for Red Hat's proprietary ``up2date`` package update
        mechanism."

    commands :up2date => "/usr/sbin/up2date-nox"
    defaultfor :operatingsystem => :redhat, 
               :lsbdistrelease => ["2.1", "3", "4"]
    confine    :operatingsystem => :redhat

    # Install a package using 'up2date'.
    def install
        up2date "-u", @resource[:name]

        unless self.query
            raise Puppet::ExecutionFailure.new(
                "Could not find package %s" % self.name
            )
        end
    end

    # What's the latest package version available?
    def latest
        #up2date can only get a list of *all* available packages?
        output = up2date "--show-available"

        if output =~ /#{@resource[:name]}-(\d+.*)\.\w+/
            return $1
        else
            # up2date didn't find updates, pretend the current
            # version is the latest
            return @resource.is(:ensure)
        end
    end

    def update
        # Install in up2date can be used for update, too
        self.install
    end

    def versionable?
        false
    end
end

# $Id$