Class: Dobby::PackageSource::DpkgStatusFile
- Inherits:
-
AbstractPackageSource
- Object
- AbstractPackageSource
- Dobby::PackageSource::DpkgStatusFile
- Defined in:
- lib/dobby/package_source/dpkg_status_file.rb
Overview
Defines a strategy for creating a Dobby::Package array from /var/lib/dpkg/status or a similarly formatted file.
Defined Under Namespace
Classes: DpkgFormatError
Instance Attribute Summary
Attributes included from Strategy
Class Method Summary collapse
-
.cli_options ⇒ Object
rubocop:disable Layout/AlignArray.
Instance Method Summary collapse
Methods included from Strategy
included, #initialize, #inspect, #log, #setup
Class Method Details
.cli_options ⇒ Object
rubocop:disable Layout/AlignArray
18 19 20 21 22 23 24 25 |
# File 'lib/dobby/package_source/dpkg_status_file.rb', line 18 def self. [ ['--release NAME', 'Release code name for package definitions.', 'Defaults to the code name of the current system.'], ['--dist DIST', 'The full name of the distribution for package definitions.', 'Defaults to "Debian".'] ] end |
Instance Method Details
#parse ⇒ Array<Package>
29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/dobby/package_source/dpkg_status_file.rb', line 29 def parse packages = [] File.read(.file_path).split("\n\n").each do |section| begin packages << package_from_section(section) rescue Package::FieldRequiredError => e # If the Version field is missing, this is probably a virtual # or meta-package (e.g. little-table-dev) - Skip it. Name and # release should never be missing, so reraise the error in those # cases. next if e.field == 'version' raise end end packages end |