pkgdownload: fixups and typechecks

This commit is contained in:
InsanePrawn 2022-08-08 16:56:46 +02:00
parent 657ada4c73
commit ea7df92b7f
2 changed files with 7 additions and 6 deletions

View file

@ -47,7 +47,7 @@ def get_base_distro(arch: str) -> Distro:
return Distro(arch=arch, repo_infos=repos, scan=False)
def get_kupfer(arch: str, url_template: str) -> Distro:
def get_kupfer(arch: str, url_template: str, scan: bool = False) -> Distro:
repos = {name: RepoInfo(url_template=url_template, options={'SigLevel': 'Never'}) for name in REPOSITORIES}
return Distro(
arch=arch,
@ -55,8 +55,8 @@ def get_kupfer(arch: str, url_template: str) -> Distro:
)
def get_kupfer_https(arch: str) -> Distro:
return get_kupfer(arch, KUPFER_HTTPS.replace('%branch%', config.file['pacman']['repo_branch']))
def get_kupfer_https(arch: str, scan: bool = False) -> Distro:
return get_kupfer(arch, KUPFER_HTTPS.replace('%branch%', config.file['pacman']['repo_branch']), scan)
def get_kupfer_local(arch: Optional[str] = None, in_chroot: bool = True) -> Distro:

View file

@ -7,7 +7,7 @@ import subprocess
from copy import deepcopy
from joblib import Parallel, delayed
from glob import glob
from urllib import HTTPError
from urllib.error import HTTPError
from urllib.request import urlopen
from shutil import rmtree, copyfileobj
from typing import Iterable, Iterator, Any, Optional
@ -375,7 +375,8 @@ def try_download_package(dest_file_path: str, package: Pkgbuild, arch: Arch) ->
logging.debug(f"package filenames don't match: local: {filename}, remote: {repo_pkg.filename}")
return False
# url = f"{repo.resolve_url()}/{filename}"
url = repo_pkg.resolved_url()
url = repo_pkg.resolved_url
assert url
try:
logging.debug(f"Trying to retrieve remote package {filename} from {url}")
with urlopen(url) as fsrc, open(dest_file_path, 'wb') as fdst:
@ -423,7 +424,7 @@ def check_package_version_built(package: Pkgbuild, arch: Arch, try_download: boo
if not filename_stripped.endswith('.pkg.tar'):
logging.debug(f'skipping unknown file extension {basename}')
continue
if os.path.exists(file) or (try_download and try_download_package(file, package.repo, arch)):
if os.path.exists(file) or (try_download and try_download_package(file, package, arch)):
missing = False
add_file_to_repo(file, repo_name=package.repo, arch=arch)
# copy arch=(any) packages to all arches