Sha256: 8901e31d512ad44b095e3877732b2ad5c483854116067f7894ac071deb4f64e5

Contents?: true

Size: 1.39 KB

Versions: 20

Compression:

Stored size: 1.39 KB

Contents

# frozen_string_literal: true
Puppet::Type.type(:package).provide :freebsd, :parent => :openbsd do
  desc "The specific form of package management on FreeBSD.  This is an
    extremely quirky packaging system, in that it freely mixes between
    ports and packages.  Apparently all of the tools are written in Ruby,
    so there are plans to rewrite this support to directly use those
    libraries."

  commands :pkginfo => "/usr/sbin/pkg_info",
    :pkgadd => "/usr/sbin/pkg_add",
    :pkgdelete => "/usr/sbin/pkg_delete"

  confine 'os.name' => :freebsd

  def self.listcmd
    command(:pkginfo)
  end

  def install
    if @resource[:source] =~ /\/$/
      if @resource[:source] =~ /^(ftp|https?):/
        Puppet::Util.withenv :PACKAGESITE => @resource[:source] do
          pkgadd "-r", @resource[:name]
        end
      else
        Puppet::Util.withenv :PKG_PATH => @resource[:source] do
          pkgadd @resource[:name]
        end
      end
    else
      Puppet.warning _("source is defined but does not have trailing slash, ignoring %{source}") % { source: @resource[:source] } if @resource[:source]
      pkgadd "-r", @resource[:name]
    end
  end

  def query
    self.class.instances.each do |provider|
      if provider.name == @resource.name
        return provider.properties
      end
    end
    nil
  end

  def uninstall
    pkgdelete "#{@resource[:name]}-#{@resource.should(:ensure)}"
  end
end

Version data entries

20 entries across 20 versions & 1 rubygems

Version Path
puppet-8.3.0 lib/puppet/provider/package/freebsd.rb
puppet-8.3.0-x86-mingw32 lib/puppet/provider/package/freebsd.rb
puppet-8.3.0-x64-mingw32 lib/puppet/provider/package/freebsd.rb
puppet-8.3.0-universal-darwin lib/puppet/provider/package/freebsd.rb
puppet-8.3.1 lib/puppet/provider/package/freebsd.rb
puppet-8.3.1-x86-mingw32 lib/puppet/provider/package/freebsd.rb
puppet-8.3.1-x64-mingw32 lib/puppet/provider/package/freebsd.rb
puppet-8.3.1-universal-darwin lib/puppet/provider/package/freebsd.rb
puppet-8.2.0 lib/puppet/provider/package/freebsd.rb
puppet-8.2.0-x86-mingw32 lib/puppet/provider/package/freebsd.rb
puppet-8.2.0-x64-mingw32 lib/puppet/provider/package/freebsd.rb
puppet-8.2.0-universal-darwin lib/puppet/provider/package/freebsd.rb
puppet-8.1.0 lib/puppet/provider/package/freebsd.rb
puppet-8.1.0-x86-mingw32 lib/puppet/provider/package/freebsd.rb
puppet-8.1.0-x64-mingw32 lib/puppet/provider/package/freebsd.rb
puppet-8.1.0-universal-darwin lib/puppet/provider/package/freebsd.rb
puppet-8.0.1 lib/puppet/provider/package/freebsd.rb
puppet-8.0.1-x86-mingw32 lib/puppet/provider/package/freebsd.rb
puppet-8.0.1-x64-mingw32 lib/puppet/provider/package/freebsd.rb
puppet-8.0.1-universal-darwin lib/puppet/provider/package/freebsd.rb