fixups: properly propagate distro.scan and try_download

This commit is contained in:
InsanePrawn 2022-08-08 22:47:30 +02:00
parent 597390c1e6
commit 06b8536915
3 changed files with 10 additions and 6 deletions

View file

@ -53,6 +53,7 @@ def get_kupfer(arch: str, url_template: str, scan: bool = False) -> Distro:
return Distro( return Distro(
arch=arch, arch=arch,
repo_infos=repos, repo_infos=repos,
scan=scan,
) )

View file

@ -43,7 +43,7 @@ class Repo(RepoInfo):
uri = f'{self.resolved_url}/{self.name}.db' uri = f'{self.resolved_url}/{self.name}.db'
path = '' path = ''
if self.remote: if self.remote:
logging.debug(f'Downloading repo file from {uri}') logging.info(f'Downloading repo file from {uri}')
with urllib.request.urlopen(uri) as request: with urllib.request.urlopen(uri) as request:
fd, path = tempfile.mkstemp() fd, path = tempfile.mkstemp()
with open(fd, 'wb') as writable: with open(fd, 'wb') as writable:

View file

@ -356,16 +356,17 @@ def get_kupfer_https_distro(arch: Arch, scan: bool = True) -> Distro:
def try_download_package(dest_file_path: str, package: Pkgbuild, arch: Arch) -> bool: def try_download_package(dest_file_path: str, package: Pkgbuild, arch: Arch) -> bool:
logging.debug(f"checking if we can download {package.name}")
filename = os.path.basename(dest_file_path) filename = os.path.basename(dest_file_path)
pkgname = package.name pkgname = package.name
repo_name = package.repo repo_name = package.repo
repos = get_kupfer_https_distro(arch).repos repos = get_kupfer_https_distro(arch, scan=True).repos
if repo_name not in repos: if repo_name not in repos:
logging.warning(f"Repository {repo_name} is not a known HTTPS repo") logging.warning(f"Repository {repo_name} is not a known HTTPS repo")
return False return False
repo = repos[repo_name] repo = repos[repo_name]
if pkgname not in repo.packages: if pkgname not in repo.packages:
logging.debug(f"Package {pkgname} not found remote") logging.info(f"Package {pkgname} not found in remote repos: {list(repo.packages.keys())}")
return False return False
repo_pkg: PackageInfo = repo.packages[pkgname] repo_pkg: PackageInfo = repo.packages[pkgname]
if repo_pkg.version != package.version: if repo_pkg.version != package.version:
@ -374,13 +375,14 @@ def try_download_package(dest_file_path: str, package: Pkgbuild, arch: Arch) ->
if repo_pkg.filename != filename: if repo_pkg.filename != filename:
logging.debug(f"package filenames don't match: local: {filename}, remote: {repo_pkg.filename}") logging.debug(f"package filenames don't match: local: {filename}, remote: {repo_pkg.filename}")
return False return False
# url = f"{repo.resolve_url()}/{filename}" url = f"{repo.resolve_url()}/{filename}"
url = repo_pkg.resolved_url #url = repo_pkg.resolved_url
assert url assert url
try: try:
logging.debug(f"Trying to retrieve remote package {filename} from {url}") logging.debug(f"Trying to retrieve remote package {filename} from {url}")
with urlopen(url) as fsrc, open(dest_file_path, 'wb') as fdst: with urlopen(url) as fsrc, open(dest_file_path, 'wb') as fdst:
copyfileobj(fsrc, fdst) copyfileobj(fsrc, fdst)
logging.info(f"{filename} downloaded from repos")
return True return True
except HTTPError as e: except HTTPError as e:
if e.code == 404: if e.code == 404:
@ -429,7 +431,7 @@ def check_package_version_built(package: Pkgbuild, arch: Arch, try_download: boo
add_file_to_repo(file, repo_name=package.repo, arch=arch) add_file_to_repo(file, repo_name=package.repo, arch=arch)
# copy arch=(any) packages to all arches # copy arch=(any) packages to all arches
if filename_stripped.endswith('any.pkg.tar'): if filename_stripped.endswith('any.pkg.tar'):
logging.info("any-arch pkg detected") logging.debug("any-arch pkg detected")
target_repo_file = os.path.join(config.get_package_dir(arch), package.repo, basename) target_repo_file = os.path.join(config.get_package_dir(arch), package.repo, basename)
if os.path.exists(target_repo_file): if os.path.exists(target_repo_file):
missing = False missing = False
@ -705,6 +707,7 @@ def build_enable_qemu_binfmt(arch: Arch, repo: dict[str, Pkgbuild] = None):
['cross/' + pkg for pkg in CROSSDIRECT_PKGS], ['cross/' + pkg for pkg in CROSSDIRECT_PKGS],
native, native,
repo, repo,
try_download=True,
enable_crosscompile=False, enable_crosscompile=False,
enable_crossdirect=False, enable_crossdirect=False,
enable_ccache=False, enable_ccache=False,