HEX
Server: Apache
System: Linux dinesh8189 5.15.98-grsec-sharedvalley-2.lc.el8.x86_64 #1 SMP Thu Mar 9 09:07:30 -03 2023 x86_64
User: cgmgerenciamento1 (814285)
PHP: 8.1.26
Disabled: apache_child_terminate,dl,escapeshellarg,escapeshellcmd,exec,link,mail,openlog,passthru,pcntl_alarm,pcntl_exec,pcntl_fork,pcntl_get_last_error,pcntl_getpriority,pcntl_setpriority,pcntl_signal,pcntl_signal_dispatch,pcntl_sigprocmask,pcntl_sigtimedwait,pcntl_sigwaitinfo,pcntl_strerror,pcntl_wait,pcntl_waitpid,pcntl_wexitstatus,pcntl_wifexited,pcntl_wifsignaled,pcntl_wifstopped,pcntl_wstopsig,pcntl_wtermsig,php_check_syntax,php_strip_whitespace,popen,proc_close,proc_open,shell_exec,symlink,system
Upload Files
File: //opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/provider/package/ports.rb
Puppet::Type.type(:package).provide :ports, :parent => :freebsd, :source => :freebsd do
  desc "Support for FreeBSD's ports.  Note that this, too, mixes packages and ports."

  commands :portupgrade => "/usr/local/sbin/portupgrade",
    :portversion => "/usr/local/sbin/portversion",
    :portuninstall => "/usr/local/sbin/pkg_deinstall",
    :portinfo => "/usr/sbin/pkg_info"

  %w{INTERACTIVE UNAME}.each do |var|
    ENV.delete(var) if ENV.include?(var)
  end

  def install
    # -N: install if the package is missing, otherwise upgrade
    # -M: yes, we're a batch, so don't ask any questions
    cmd = %w{-N -M BATCH=yes} << @resource[:name]

    output = portupgrade(*cmd)
    if output =~ /\*\* No such /
      raise Puppet::ExecutionFailure, _("Could not find package %{name}") % { name: @resource[:name] }
    end
  end

  # If there are multiple packages, we only use the last one
  def latest
    cmd = ["-v", @resource[:name]]

    begin
      output = portversion(*cmd)
    rescue Puppet::ExecutionFailure
      raise Puppet::Error.new(output, $!)
    end
    line = output.split("\n").pop

    unless line =~ /^(\S+)\s+(\S)\s+(.+)$/
      # There's no "latest" version, so just return a placeholder
      return :latest
    end

    pkgstuff = $1
    match = $2
    info = $3

    unless pkgstuff =~ /^\S+-([^-\s]+)$/
      raise Puppet::Error,
        _("Could not match package info '%{pkgstuff}'") % { pkgstuff: pkgstuff }
    end

    version = $1

    if match == "=" or match == ">"
      # we're up to date or more recent
      return version
    end

    # Else, we need to be updated; we need to pull out the new version

    unless info =~ /\((\w+) has (.+)\)/
      raise Puppet::Error,
        _("Could not match version info '%{info}'") % { info: info }
    end

    source, newversion = $1, $2

    debug "Newer version in #{source}"
    newversion
  end

  def query
    # support portorigin_glob such as "mail/postfix"
    name = self.name
    if name =~ /\//
      name = self.name.split(/\//).slice(1)
    end
    self.class.instances.each do |instance|
      if instance.name == name
        return instance.properties
      end
    end

    nil
  end

  def uninstall
    portuninstall @resource[:name]
  end

  def update
    install
  end
end