Module: Dpkg::Deb
- Defined in:
- lib/dpkg/deb.rb,
lib/dpkg/deb/version.rb
Constant Summary collapse
- VERSION =
"0.1.0"
Class Method Summary collapse
Class Method Details
.fields(package_path, fieldnames = []) ⇒ Object
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/dpkg/deb.rb', line 8 def fields(package_path, fieldnames = []) out = `dpkg-deb -f #{package_path} #{fieldnames.join(" ")}` # rules are: # fields are usually line-based and follow the general format of # <field name><colon><space><field value>, for example # Maintainer: Felix Gilcher <[email protected]> # The exception to the rule is the decription field that has the format # <field name><colon><space><short description><newline> # <description> # The description needs to be indented by a single space and empty lines # are replaced by a dot. fields = {} description = [] out.each_line do |line| if match = /^(?<fieldname>[^:]+): (?<fieldvalue>.+)$/.match(line) fields[match['fieldname']] = match['fieldvalue'] elsif match = /^ .+$/.match(line) description.push line else raise "unparseable line '#{line}' found" end end fields['Description'] << description.join("") unless fields['Description'].nil? fields end |