1
0
Fork 1
mirror of https://gitlab.postmarketos.org/postmarketOS/pmbootstrap.git synced 2025-07-12 19:09:56 +03:00

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:
Newbyte 2025-07-02 17:05:27 +02:00
parent f9add1b6d2
commit 752a3a98f5
No known key found for this signature in database
GPG key ID: ACD854892B38D898

View file

@ -151,8 +151,9 @@ def apkindex_files(
@Cache("arch", force=False)
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.
def _update(arch: Arch | None, force: bool, existing_only: bool) -> bool:
"""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", ...)
* None for all architectures
@ -240,7 +241,28 @@ def update(arch: Arch | None = None, force: bool = False, existing_only: bool =
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.
: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
arch = arch or Arch.native()
update(arch)
if with_update:
update(arch)
# Find it on disk
channel_cfg = pmb.config.pmaports.read_config_channel()