Merge branch 'prod'

This commit is contained in:
Christoph Haas 2023-12-26 01:21:15 +01:00
parent 0ba2ded4a2
commit 5b624e6c30
19 changed files with 724 additions and 310 deletions

View file

@ -1,7 +1,5 @@
# Various helper methods to update the database of packages
require 'bzip2'
module DebImporter
# This module imports information about packages of a Linux distribution
@ -89,7 +87,6 @@ module DebImporter
file = find_and_open_compressed_url(packages_path)
return get_paragraphs(file)
end # def packages
end # class Release
private
@ -98,28 +95,28 @@ module DebImporter
def get_fields(data)
fields = {}
name=value=''
name = value = ""
data.each_line do |line|
case line
when /^(\S+?): (.+)/ # "Key: Value"
fields[name.to_sym]=value unless value.empty?
name,value=$1,$2
when /^(\S+?):$/ # "Key:" (start of multi-line entry without value in line)
fields[name.to_sym]=value unless value.empty?
name=$1
value=''
when /^\s(.+)/ # " Indented multi-line value"
fields[name.to_sym] = value unless value.empty?
name, value = $1, $2
when /^(\S+?):$/ # "Key:" (start of multi-line entry without value in line)
fields[name.to_sym] = value unless value.empty?
name = $1
value = ""
when /^\s(.+)/ # " Indented multi-line value"
# Add a newline for multi-line entries ("Key: Value\n Foo\n Bar")
unless value.empty?
value << "\n"
end
value << $1
when /^\s+$/ # Empty line
when /^\s+$/ # Empty line
break
end
end
# Any lines left at the end of the input?
fields[name.to_sym]=value unless value.empty?
fields[name.to_sym] = value unless value.empty?
return fields
end
@ -132,8 +129,8 @@ module DebImporter
gathered_lines = '' # collects all lines belonging to a field
data.each_line do |line|
if line.chomp.empty? # empty line found that seperates paragraphs
unless gathered_lines.empty? # any lines gathered so far?
if line.chomp.empty? # empty line found that seperates paragraphs
unless gathered_lines.empty? # any lines gathered so far?
enum.yield get_fields(gathered_lines)
gathered_lines = ''
end
@ -148,7 +145,7 @@ module DebImporter
end
end # Enumerator
end # def
class Version
attr_reader :epoch, :upstream, :revision, :version_string