Sha256: 1232baeb2734de406ae9833846a1aa8587cf377c0fb3efde7149c035ebbafb30

Contents?: true

Size: 1.62 KB

Versions: 4

Compression:

Stored size: 1.62 KB

Contents

# Copyright (c) 2013-2014 SUSE LLC
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of version 3 of the GNU General Public License as
# published by the Free Software Foundation.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.   See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, contact SUSE LLC.
#
# To contact SUSE about this file by physical or electronic mail,
# you may find current contact information at www.suse.com

class PackagesInspector < Inspector
  def inspect(system, description, options = {})
    system.check_requirement("rpm", "--version")

    packages = Array.new
    rpm_data = system.run_command(
      "rpm","-qa","--qf",
      "%{NAME}|%{VERSION}|%{RELEASE}|%{ARCH}|%{VENDOR}|%{SIGMD5}$",
      :stdout=>:capture
    )
    # gpg-pubkeys are no real packages but listed by rpm in the regular
    # package list
    rpm_data.scan(/(.*?)\|(.*?)\|(.*?)\|(.*?)\|(.*?)\|(.*?)\$/).reject do |name, *attrs|
      name =~ /^gpg-pubkey$/
    end.each do |name, version, release, arch, vendor, checksum|
      packages << Package.new(
        :name     => name,
        :version  => version,
        :release  => release,
        :arch     => arch,
        :vendor   => vendor,
        :checksum => checksum
      )
    end

    description.packages = PackagesScope.new(packages.sort_by(&:name))
    "Found #{packages.count} packages."
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
machinery-tool-1.2.0 plugins/inspect/packages_inspector.rb
machinery-tool-1.1.1 plugins/inspect/packages_inspector.rb
machinery-tool-1.1.0 plugins/inspect/packages_inspector.rb
machinery-tool-1.0.2 plugins/inspect/packages_inspector.rb