Sha256: 87c072e6e73ec6f445813dfb74e1f449b3be3eaaa7495b96bf4a06b23814e823

Contents?: true

Size: 1.46 KB

Versions: 5

Compression:

Stored size: 1.46 KB

Contents

Puppet::Type.type(:package).provide :urpmi, :parent => :rpm, :source => :rpm do
    desc "Support via ``urpmi``."
    commands :urpmi => "urpmi", :rpm => "rpm"

    if command('rpm')
        confine :true => begin
                rpm('-ql', 'rpm')
           rescue Puppet::ExecutionFailure
               false
           else
               true
           end
    end

    defaultfor :operatingsystem => [:mandriva, :mandrake]

    has_feature :versionable

    def install
        should = @resource.should(:ensure)
        self.debug "Ensuring => #{should}"
        wanted = @resource[:name]

        # XXX: We don't actually deal with epochs here.
        case should
        when true, false, Symbol
            # pass
        else
            # Add the package version
            wanted += "-%s" % should
        end

        output = urpmi "--auto", wanted

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

    # What's the latest package version available?
    def latest
        output = urpmi "-S",  :available, @resource[:name]

        if output =~ /^#{@resource[:name]}\S+\s+(\S+)\s/
            return $1
        else
            # urpmi didn't find updates, pretend the current
            # version is the latest
            return @resource[:ensure]
        end
    end

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

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
puppet-0.24.0 lib/puppet/provider/package/urpmi.rb
puppet-0.24.2 lib/puppet/provider/package/urpmi.rb
puppet-0.24.3 lib/puppet/provider/package/urpmi.rb
puppet-0.24.4 lib/puppet/provider/package/urpmi.rb
puppet-0.24.1 lib/puppet/provider/package/urpmi.rb