Module: Dgh
Defined Under Namespace
Modules: Version
Constant Summary collapse
Class Method Summary collapse
Instance Method Summary collapse
-
#find_downgradable(packages) ⇒ Object
Find downgradable packages.
-
#parse(input) ⇒ Object
Parse input with the policy grammar.
Class Method Details
.run ⇒ Object
31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 |
# File 'lib/dgh.rb', line 31 def run optspec = <<-SPEC Usage: dgh [options] inputfile(s) --- d,debug Output debug messages h,help Output help message SPEC opts = Slop.optspec(optspec) opts.parse! if opts.help? puts opts exit end log = Logger.new(STDOUT) log.level = Logger::DEBUG LogBuddy.init :default_loggger => log, :disabled => !opts.debug? if ARGV.empty? || ARGV.any? {|a| !File.exist? a} puts opts puts "You can generate a policy listing by running e.g." puts "`dpkg --get-selections|egrep '\\binstall'|awk '{print $1}'|\\" puts " xargs env LANG=C apt-cache policy`" else ARGV.each do |f| d "Parsing #{f}" find_downgradable(parse(File.open(f).read).content).each do |pkg| puts pkg[:name] end end end end |
Instance Method Details
#find_downgradable(packages) ⇒ Object
Find downgradable packages
22 23 24 25 26 27 28 |
# File 'lib/dgh.rb', line 22 def find_downgradable(packages) packages.select do |pkg| pkg[:versions].any? do |ver| ver[:current] && ver[:sources].length == 1 && ver[:sources][0][:source] == '/var/lib/dpkg/status' end end end |
#parse(input) ⇒ Object
Parse input with the policy grammar
14 15 16 17 |
# File 'lib/dgh.rb', line 14 def parse(input) @parser ||= PolicyParser.new @parser.parse input end |