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/opkg.rb
require 'puppet/provider/package'

Puppet::Type.type(:package).provide :opkg, :source => :opkg, :parent => Puppet::Provider::Package do
  desc "Opkg packaging support. Common on OpenWrt and OpenEmbedded platforms"

  commands :opkg => "opkg"

  confine     :operatingsystem => :openwrt
  defaultfor  :operatingsystem => :openwrt

  def self.instances
    packages = []
    execpipe("#{command(:opkg)} list-installed") do |process|
      regex = %r{^(\S+) - (\S+)}
      fields = [:name, :ensure]
      hash = {}

      process.each_line { |line|
        match = regex.match(line)
        if match
          fields.zip(match.captures) { |field,value| hash[field] = value }
          hash[:provider] = self.name
          packages << new(hash)
          hash = {}
        else
          warning(_("Failed to match line %{line}") % { line: line })
        end
      }
    end
    packages
  rescue Puppet::ExecutionFailure
    return nil
  end

  def latest
    output = opkg( "list", @resource[:name])
    matches = /^(\S+) - (\S+)/.match(output).captures
    matches[1]
  end

  def install
    # OpenWrt package lists are ephemeral, make sure we have at least
    # some entries in the list directory for opkg to use
    opkg('update') if package_lists.size <= 2

    if @resource[:source]
      opkg( '--force-overwrite', 'install', @resource[:source] )
    else
      opkg( '--force-overwrite', 'install', @resource[:name] )
    end
  end

  def uninstall
    opkg( 'remove', @resource[:name] )
  end

  def update
    self.install
  end

  def query
    # list out our specific package
    output = opkg( 'list-installed', @resource[:name] )
    if output =~ /^(\S+) - (\S+)/
      return { :ensure => $2 }
    end
    nil
  rescue Puppet::ExecutionFailure
    return {
      :ensure => :purged,
      :status => 'missing',
      :name => @resource[:name],
      :error => 'ok',
    }
  end

  private

  def package_lists
    Dir.entries('/var/opkg-lists/')
  end
end