Some refactoring.

This commit is contained in:
Jelmer Vernooij 2021-03-16 20:02:52 +00:00
parent 09d74cf827
commit b6414238bf

View file

@ -42,17 +42,14 @@ def read_contents_file(f):
yield path, rest
def contents_urls_from_sourceslist(sl, arch):
# TODO(jelmer): Verify signatures, etc.
arches = [(arch, True), ("all", False)]
for source in sl.list:
def contents_urls_from_sources_entry(source, arches):
if source.invalid or source.disabled:
continue
return
if source.type == "deb-src":
continue
return
if source.type != "deb":
logging.warning("Invalid line in sources: %r", source)
continue
return
base_url = source.uri.rstrip("/")
name = source.dist.rstrip("/")
components = source.comps
@ -76,6 +73,13 @@ def contents_urls_from_sourceslist(sl, arch):
)
def contents_urls_from_sourceslist(sl, arch):
# TODO(jelmer): Verify signatures, etc.
arches = [(arch, True), ("all", False)]
for source in sl.list:
yield from contents_urls_from_sources_entry(source, arches)
def load_contents_url(url):
from urllib.error import HTTPError
from urllib.request import urlopen, Request
@ -158,10 +162,10 @@ class AptCachedContentsFileSearcher(FileSearcher):
urls = list(
contents_urls_from_sourceslist(sl, get_build_architecture()))
cache_dirs = [
cache_dirs = set([
os.path.join(session.location, "var/lib/apt/lists"),
"/var/lib/apt/lists",
]
])
self._load_urls(urls, cache_dirs)
def _load_urls(self, urls, cache_dirs):