44 lines
909 B
Crystal
44 lines
909 B
Crystal
require "specparser"
|
|
|
|
class Package::Configuration
|
|
PATH_FROM_ROOT = "/etc/package.cfg"
|
|
|
|
getter file_path : String?
|
|
|
|
getter repositories = Array(Repository).new
|
|
|
|
getter cache_directory = "/var/cache/package"
|
|
|
|
def initialize
|
|
end
|
|
|
|
def initialize(@file_path : String)
|
|
specs = SpecParser.parse File.read @file_path.not_nil!
|
|
|
|
specs.sections.each do |section|
|
|
case section.name
|
|
when "repository"
|
|
repository_url = section.options[0]
|
|
repository_uri = URI.parse repository_url
|
|
spec_url = "#{repository_url}/repository.spec"
|
|
spec_uri = URI.parse spec_url
|
|
|
|
if spec_uri.scheme == "" || spec_uri.scheme == "file"
|
|
@repositories << Repository.new(
|
|
File.read(spec_uri.path),
|
|
repository_uri
|
|
)
|
|
else
|
|
@repositories << Repository.new(repository_uri)
|
|
end
|
|
end
|
|
end
|
|
end
|
|
|
|
def download_index(context : Context)
|
|
cache = context.get_indices_cache
|
|
|
|
end
|
|
end
|
|
|