DEB importer can now handle bzip2 files
This commit is contained in:
parent
beeb4cd37a
commit
a15b2b6674
3 changed files with 23 additions and 2 deletions
|
|
@ -1,5 +1,7 @@
|
|||
# Various helper methods to update the database of packages
|
||||
|
||||
require 'bzip2'
|
||||
|
||||
module DebImporter
|
||||
|
||||
# This module imports information about packages of a Linux distribution
|
||||
|
|
@ -45,15 +47,24 @@ module DebImporter
|
|||
packages_path = "/#{component}/binary-#{architecture}/Packages"
|
||||
# Check if gzip or uncompressed files exist
|
||||
# (there is no working bzip2 library for Ruby 2.x at the time - 11/2014)
|
||||
for suffix in ['.gz', '']
|
||||
for suffix in ['.bz2', '.gz', '']
|
||||
packages_path_with_suffix = packages_path+suffix
|
||||
Rails.logger.debug "Looking for Packages file: #{packages_path_with_suffix}"
|
||||
url = @dist_url + packages_path_with_suffix
|
||||
begin
|
||||
Rails.logger.debug "Try opening URL: #{url}"
|
||||
file = open(url)
|
||||
begin
|
||||
file = open(url)
|
||||
puts "URL: #{url}"
|
||||
puts "File: #{file}"
|
||||
rescue OpenURI::HTTPError => e
|
||||
Rails.logger.info "URL #{url} lead to #{e}. skipping."
|
||||
next
|
||||
end
|
||||
if suffix == '.gz'
|
||||
file = Zlib::GzipReader.new(file)
|
||||
elsif suffix == '.bz2'
|
||||
file = Bzip2::Reader.new(file)
|
||||
end
|
||||
Rails.logger.debug "File containing packages is: #{file}"
|
||||
#paragraphs = get_paragraphs(file)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue