parse: apkindex: handle empty APKINDEX (MR 2252)

Sometimes the local binary repo will have no packages but still an
APKINDEX. It will be empty in this case. Handle this gracefully.

Signed-off-by: Caleb Connolly <caleb@postmarketos.org>
This commit is contained in:
Caleb Connolly 2024-06-15 18:47:57 +02:00 committed by Oliver Smith
parent 4a52f46bf0
commit 5c652e0602
No known key found for this signature in database
GPG key ID: 5AE7F5513E0885CB

View file

@ -197,6 +197,11 @@ def parse(path: Path, multiple_providers=True):
with path.open("r", encoding="utf-8") as handle:
lines = handle.read().splitlines()
# The APKINDEX might be empty, for example if you run "pmbootstrap index" and have no local
# packages
if not lines:
return {}
# Parse the whole APKINDEX file
ret: Dict[str, Any] = collections.OrderedDict()
if lines[-1] == "\n":