Rewrote apt.rb's read_debs' main loop.

Signed-off-by: Ryan Davis <zenspider@chef.io>
This commit is contained in:
Ryan Davis 2019-08-29 16:27:08 -07:00
parent 1aebd53314
commit 5a26b3c538

View file

@ -81,12 +81,10 @@ module Inspec::Resources
cmd = inspec.command("find /etc/apt/ -name \*.list -exec sh -c 'cat {} || echo -n' \\;")
# @see https://help.ubuntu.com/community/Repositories/CommandLine#Explanation_of_the_Repository_Format
@repo_cache = cmd.stdout.chomp.split("\n").each_with_object([]) do |raw_line, lines|
active = true
@repo_cache = cmd.stdout.lines.map do |raw_line|
# detect if the repo is commented out
line = raw_line.gsub(/^(#\s*)*/, "")
active = false if raw_line != line
active = raw_line == line
# formats:
# deb http://archive.ubuntu.com/ubuntu/ wily main restricted ...
@ -101,16 +99,14 @@ module Inspec::Resources
next unless %w{deb deb-src}.include? type
# map data
repo = {
type: type,
url: url,
distro: distro,
{
type: type,
url: url,
distro: distro,
components: components,
active: active,
}
lines.push(repo)
end
end.compact
end
# resolves ppa urls