Revert "pmb.helpers.repo: Always update APKINDEX if it doesn't exist"

This patch made the assumption that if the Alpine APKINDEX for the
"main" repository exist, all other Alpine indexes ("community",
"testing") as well as the postmarketOS indexes (normal one, systemd)
exist as well.

This is not always the case, e.g. when the internet connection dropped
while downloading indexes and so only "main" was downloaded. While this
is unlikely to happen, it is currently also breaking BPO where the
postmarketOS repository does not get set during "pmbootstrap init" on
purpose as it causes problems when bringing up new releases.

This reverts commit 752a3a98f5.

I'll make a different fix in the next patch for the problem that this
patch was made for, having a broken "pmbootstrap zap -a" with apkv3.

Related: BPO issue 160
Part-of: https://gitlab.postmarketos.org/postmarketOS/pmbootstrap/-/merge_requests/2636
This commit is contained in:
Oliver Smith 2025-07-03 20:55:13 +02:00
parent 8ae3050a0d
commit 3d764546c1
No known key found for this signature in database
GPG key ID: 5AE7F5513E0885CB

View file

@ -151,9 +151,8 @@ def apkindex_files(
@Cache("arch", force=False)
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.
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
@ -241,28 +240,7 @@ def _update(arch: Arch | None, force: bool, existing_only: bool) -> bool:
return True
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:
def alpine_apkindex_path(repo: str = "main", arch: Arch | None = None) -> 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")
@ -275,8 +253,7 @@ def alpine_apkindex_path(
# Download the file
arch = arch or Arch.native()
if with_update:
update(arch)
update(arch)
# Find it on disk
channel_cfg = pmb.config.pmaports.read_config_channel()