Sha256: d955ffed34a5224c4c604000aa5314368b6da419156ef0cb32b5befd801565db

Contents?: true

Size: 943 Bytes

Versions: 12

Compression:

Stored size: 943 Bytes

Contents

# frozen_string_literal: true

Puppet::Type.type(:package).provide :aptitude, :parent => :apt, :source => :dpkg do
  desc "Package management via `aptitude`."

  has_feature :versionable

  commands :aptitude => "/usr/bin/aptitude"
  commands :aptcache => "/usr/bin/apt-cache"

  ENV['DEBIAN_FRONTEND'] = "noninteractive"

  def aptget(*args)
    args.flatten!
    # Apparently aptitude hasn't always supported a -q flag.
    args.delete("-q") if args.include?("-q")
    args.delete("--force-yes") if args.include?("--force-yes")
    output = aptitude(*args)

    # Yay, stupid aptitude doesn't throw an error when the package is missing.
    if args.include?(:install) and output.to_s =~ /Couldn't find any package/
      raise Puppet::Error.new(
        _("Could not find package %{name}") % { name: self.name }
      )
    end
  end

  def purge
    aptitude '-y', 'purge', @resource[:name]
  end

  private

  def source
    nil
  end
end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
puppet-8.5.1 lib/puppet/provider/package/aptitude.rb
puppet-8.5.1-x86-mingw32 lib/puppet/provider/package/aptitude.rb
puppet-8.5.1-x64-mingw32 lib/puppet/provider/package/aptitude.rb
puppet-8.5.1-universal-darwin lib/puppet/provider/package/aptitude.rb
puppet-8.5.0 lib/puppet/provider/package/aptitude.rb
puppet-8.5.0-x86-mingw32 lib/puppet/provider/package/aptitude.rb
puppet-8.5.0-x64-mingw32 lib/puppet/provider/package/aptitude.rb
puppet-8.5.0-universal-darwin lib/puppet/provider/package/aptitude.rb
puppet-8.4.0 lib/puppet/provider/package/aptitude.rb
puppet-8.4.0-x86-mingw32 lib/puppet/provider/package/aptitude.rb
puppet-8.4.0-x64-mingw32 lib/puppet/provider/package/aptitude.rb
puppet-8.4.0-universal-darwin lib/puppet/provider/package/aptitude.rb