forked from Mirror/pmbootstrap
pmb.helpers.repo: Always update APKINDEX if it doesn't exist
When using `pmb zap --pkgs-online-mismatch`, the local index is downloaded if missing and `update()` is cached, however pmb zap removes the index and subsequent calls to `update()` don't actually do anything (i.e. redownload the index) so later things that expect the indext to exist (like finding providers) blow up. Wrap update() with a new update() method that checks if the APKINDEX exists, and always do a "real" update if it doesn't. Also rename update() to _update(). Co-Developed-by: Clayton Craft <clayton@craftyguy.net> Part-of: https://gitlab.postmarketos.org/postmarketOS/pmbootstrap/-/merge_requests/2635
This commit is contained in:
parent
f9add1b6d2
commit
752a3a98f5
1 changed files with 27 additions and 4 deletions
|
@ -151,8 +151,9 @@ def apkindex_files(
|
||||||
|
|
||||||
|
|
||||||
@Cache("arch", force=False)
|
@Cache("arch", force=False)
|
||||||
def update(arch: Arch | None = None, force: bool = False, existing_only: bool = False) -> bool:
|
def _update(arch: Arch | None, force: bool, existing_only: bool) -> bool:
|
||||||
"""Download the APKINDEX files for all URLs depending on the architectures.
|
"""Internal method for downloading the APKINDEX files. This should not be called directly, use
|
||||||
|
update() instead.
|
||||||
|
|
||||||
:param arch: * one Alpine architecture name ("x86_64", "armhf", ...)
|
:param arch: * one Alpine architecture name ("x86_64", "armhf", ...)
|
||||||
* None for all architectures
|
* None for all architectures
|
||||||
|
@ -240,7 +241,28 @@ def update(arch: Arch | None = None, force: bool = False, existing_only: bool =
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
|
||||||
def alpine_apkindex_path(repo: str = "main", arch: Arch | None = None) -> Path:
|
def update(arch: Arch | None = None, force: bool = False, existing_only: bool = False) -> bool:
|
||||||
|
"""Download the APKINDEX files for all URLs depending on the architectures.
|
||||||
|
|
||||||
|
:param arch: * one Alpine architecture name ("x86_64", "armhf", ...)
|
||||||
|
* None for all architectures
|
||||||
|
:param force: even update when the APKINDEX file is fairly recent
|
||||||
|
:param existing_only: only update the APKINDEX files that already exist,
|
||||||
|
this is used by "pmbootstrap update"
|
||||||
|
|
||||||
|
:returns: True when files have been downloaded, False otherwise
|
||||||
|
"""
|
||||||
|
apkindex_path = alpine_apkindex_path(arch=arch, with_update=False)
|
||||||
|
|
||||||
|
if not apkindex_path.exists() or force:
|
||||||
|
return _update(arch, force, existing_only)
|
||||||
|
|
||||||
|
return True
|
||||||
|
|
||||||
|
|
||||||
|
def alpine_apkindex_path(
|
||||||
|
repo: str = "main", arch: Arch | None = None, with_update: bool = True
|
||||||
|
) -> Path:
|
||||||
"""Get the path to a specific Alpine APKINDEX file on disk and download it if necessary.
|
"""Get the path to a specific Alpine APKINDEX file on disk and download it if necessary.
|
||||||
|
|
||||||
:param repo: Alpine repository name (e.g. "main")
|
:param repo: Alpine repository name (e.g. "main")
|
||||||
|
@ -253,7 +275,8 @@ def alpine_apkindex_path(repo: str = "main", arch: Arch | None = None) -> Path:
|
||||||
|
|
||||||
# Download the file
|
# Download the file
|
||||||
arch = arch or Arch.native()
|
arch = arch or Arch.native()
|
||||||
update(arch)
|
if with_update:
|
||||||
|
update(arch)
|
||||||
|
|
||||||
# Find it on disk
|
# Find it on disk
|
||||||
channel_cfg = pmb.config.pmaports.read_config_channel()
|
channel_cfg = pmb.config.pmaports.read_config_channel()
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue