Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found

Target

Select target project
  • postmarketOS/pmbootstrap
  • fossdd/pmbootstrap
  • Adrian/pmbootstrap
  • JustSoup321/pmbootstrap
  • longnoserob/pmbootstrap
  • sixthkrum/pmbootstrap
  • ollieparanoid/pmbootstrap
  • magdesign/pmbootstrap
  • anjandev/pmbootstrap
  • HenriDellal/pmbootstrap
  • Minecrell/pmbootstrap
  • chipiguay/pmbootstrap
  • ijiki16/pmbootstrap
  • whynothugo/pmbootstrap
  • amessier/pmbootstrap
  • Eisenbahnfan/pmbootstrap
  • user0-07161/pmbootstrap
  • SzczurekYT/pmbootstrap
  • neuschaefer/pmbootstrap
  • knuxify/pmbootstrap
  • Frieder.Hannenheim/pmbootstrap
21 results
Show changes
Commits on Source (9)
Showing
with 250 additions and 133 deletions
......@@ -4,10 +4,11 @@
if [ "$(id -u)" = 0 ]; then
set -x
apk -q add py3-argcomplete py3-mypy
apk -q add py3-argcomplete py3-pip
exec su "${TESTUSER:-build}" -c "sh -e $0"
fi
set -x
mypy --color-output pmbootstrap.py
pip install --break-system-packages --no-warn-script-location mypy
python -m mypy --color-output --check-untyped-defs pmbootstrap.py
......@@ -18,7 +18,11 @@ def generate(pkgname: str) -> None:
# Parse version from APKINDEX
package_data = pmb.parse.apkindex.package("busybox")
version = package_data["version"]
if package_data is None:
raise RuntimeError("Couldn't find APKINDEX for busybox!")
version = package_data.version
pkgver = version.split("-r")[0]
pkgrel = version.split("-r")[1]
......
......@@ -210,14 +210,17 @@ def get_upstream_aport(pkgname: str, arch: Arch | None = None, retain_branch: bo
index_path = pmb.helpers.repo.alpine_apkindex_path(repo, arch)
package = pmb.parse.apkindex.package(pkgname, indexes=[index_path])
if package is None:
raise RuntimeError(f"Couldn't find {pkgname} in APKINDEX!")
# Compare version (return when equal)
compare = pmb.parse.version.compare(apkbuild_version, package["version"])
compare = pmb.parse.version.compare(apkbuild_version, package.version)
# APKBUILD > binary: this is fine
if compare == 1:
logging.info(
f"NOTE: {pkgname} {arch} binary package has a lower"
f" version {package['version']} than the APKBUILD"
f" version {package.version} than the APKBUILD"
f" {apkbuild_version}"
)
return aport_path
......@@ -229,7 +232,7 @@ def get_upstream_aport(pkgname: str, arch: Arch | None = None, retain_branch: bo
" local checkout of Alpine's aports ("
+ apkbuild_version
+ ") compared to Alpine's binary package ("
+ package["version"]
+ package.version
+ ")!"
)
logging.info("NOTE: You can update your local checkout with: 'pmbootstrap pull'")
......
......@@ -12,12 +12,14 @@ from pmb.core import Chroot
from pmb.core.context import get_context
def generate(pkgname):
def generate(pkgname: str) -> None:
arch = Arch.x86
if pkgname != "grub-efi-x86":
raise RuntimeError("only grub-efi-x86 is available")
package_data = pmb.parse.apkindex.package("grub")
version = package_data["version"]
if package_data is None:
raise RuntimeError("Couldn't find package grub!")
version = package_data.version
pkgver = version.split("-r")[0]
pkgrel = version.split("-r")[1]
......
......@@ -17,7 +17,9 @@ def generate(pkgname: str) -> None:
# Parse musl version from APKINDEX
package_data = pmb.parse.apkindex.package("musl")
version = package_data["version"]
if package_data is None:
raise RuntimeError("Couldn't find package musl!")
version = package_data.version
pkgver = version.split("-r")[0]
pkgrel = version.split("-r")[1]
......
......@@ -51,7 +51,7 @@ def check_build_for_arch(pkgname: str, arch: Arch):
pmaport_version = pmaport["pkgver"] + "-r" + pmaport["pkgrel"]
logging.debug(
pkgname + ": found pmaport (" + pmaport_version + ") and"
" binary package (" + binary["version"] + ", from"
" binary package (" + binary.version + ", from"
" postmarketOS or Alpine), but pmaport can't be built"
f" for {arch} -> using binary package"
)
......@@ -274,7 +274,7 @@ def prioritise_build_queue(disarray: list[BuildQueueItem]) -> list[BuildQueueIte
)
if not dep_data:
raise NonBugError(f"{item['name']}: dependency not found: {dep}")
dep = dep_data["pkgname"]
dep = dep_data.pkgname
if dep in all_pkgnames:
unmet_deps.setdefault(item["name"], []).append(dep)
......@@ -483,11 +483,11 @@ def packages(
# building with --src with an outdated pmaports checkout.
if (
index_data
and pmb.parse.version.compare(index_data["version"], f"{pkgver}-r{apkbuild['pkgrel']}")
and pmb.parse.version.compare(index_data.version, f"{pkgver}-r{apkbuild['pkgrel']}")
== 1
):
raise NonBugError(
f"A binary package for {name} has a newer version ({index_data['version']})"
f"A binary package for {name} has a newer version ({index_data.version})"
f" than the source ({pkgver}-{apkbuild['pkgrel']}). Please ensure your pmaports branch is up"
" to date and that you don't have a newer version of the package in your local"
f" binary repo ({context.config.work / 'packages' / channel / pkg_arch})."
......
......@@ -107,7 +107,7 @@ def get_status(arch, apkbuild) -> BuildStatus:
return BuildStatus.CANT_BUILD
# a) Binary repo has a newer version
version_binary = index_data["version"]
version_binary = index_data.version
if pmb.parse.version.compare(version_binary, version_pmaports) == 1:
logging.warning(
f"WARNING: about to install {package} {version_binary}"
......
# Copyright 2023 Oliver Smith
# SPDX-License-Identifier: GPL-3.0-or-later
from __future__ import annotations
import os
from pathlib import Path
import traceback
......@@ -98,7 +101,7 @@ def check_min_version(chroot: Chroot = Chroot.native()):
)
# Compare
version_installed = installed_pkgs["apk-tools"]["version"]
version_installed = installed_pkgs["apk-tools"].version
pmb.helpers.apk.check_outdated(
version_installed,
"Delete your http cache and zap all chroots, then try again:" " 'pmbootstrap zap -hc'",
......@@ -126,7 +129,7 @@ def packages_split_to_add_del(packages):
return (to_add, to_del)
def packages_get_locally_built_apks(packages, arch: Arch) -> list[Path]:
def packages_get_locally_built_apks(package_list: list[str], arch: Arch) -> list[Path]:
"""
Iterate over packages and if existing, get paths to locally built packages.
This is used to force apk to upgrade packages to newer local versions, even
......@@ -141,7 +144,7 @@ def packages_get_locally_built_apks(packages, arch: Arch) -> list[Path]:
channels: list[str] = pmb.config.pmaports.all_channels()
local: list[Path] = []
packages = set(packages)
packages = set(package_list)
walked: set[str] = set()
while len(packages):
......@@ -150,7 +153,7 @@ def packages_get_locally_built_apks(packages, arch: Arch) -> list[Path]:
if not data_repo:
continue
apk_file = f"{data_repo['pkgname']}-{data_repo['version']}.apk"
apk_file = f"{data_repo.pkgname}-{data_repo.version}.apk"
# FIXME: we should know what channel we expect this package to be in
# this will have weird behaviour if you build gnome-shell for edge and
# then checkout out the systemd branch... But there isn't
......@@ -163,12 +166,13 @@ def packages_get_locally_built_apks(packages, arch: Arch) -> list[Path]:
break
# Record all the packages we have visited so far
walked |= set([data_repo["pkgname"], package])
# Add all dependencies to the list of packages to check, excluding
# meta-deps like cmd:* and so:* as well as conflicts (!).
packages |= (
set(filter(lambda x: ":" not in x and "!" not in x, data_repo["depends"])) - walked
)
walked |= set([data_repo.pkgname, package])
if data_repo.depends:
# Add all dependencies to the list of packages to check, excluding
# meta-deps like cmd:* and so:* as well as conflicts (!).
packages |= (
set(filter(lambda x: ":" not in x and "!" not in x, data_repo.depends)) - walked
)
return local
......@@ -283,21 +287,13 @@ def install(packages, chroot: Chroot, build=True, quiet: bool = False):
install_run_apk(to_add, to_add_local, to_del, chroot)
def installed(suffix: Chroot = Chroot.native()):
def installed(suffix: Chroot = Chroot.native()) -> dict[str, pmb.parse.apkindex.ApkindexBlock]:
"""
Read the list of installed packages (which has almost the same format, as
an APKINDEX, but with more keys).
:returns: a dictionary with the following structure:
{ "postmarketos-mkinitfs":
{
"pkgname": "postmarketos-mkinitfs"
"version": "0.0.4-r10",
"depends": ["busybox-extras", "lddtree", ...],
"provides": ["mkinitfs=0.0.1"]
}, ...
}
{ "postmarketos-mkinitfs": ApkindexBlock }
"""
path = suffix / "lib/apk/db/installed"
......
......@@ -157,14 +157,18 @@ def download(file):
return pmb.helpers.http.download(f"{base_url}/{file}", file)
def init():
def init() -> None:
"""
Download, verify, extract $WORK/apk.static.
"""
# Get and parse the APKINDEX
apkindex = pmb.helpers.repo.alpine_apkindex_path("main")
index_data = pmb.parse.apkindex.package("apk-tools-static", indexes=[apkindex])
version = index_data["version"]
if index_data is None:
raise RuntimeError("Could not find apk-tools-static in APKINDEX!")
version = index_data.version
# Verify the apk-tools-static version
pmb.helpers.apk.check_outdated(version, "Run 'pmbootstrap update', then try again.")
......
from pathlib import Path
import pytest
from pmb.core.arch import Arch
from pmb.core.context import get_context
from pmb.parse.apkindex import ApkindexBlock
from .apk import packages_get_locally_built_apks
import pmb.config.pmaports
@pytest.fixture
def apk_mocks(monkeypatch):
def apk_mocks(monkeypatch) -> dict | None:
def _pmaports_config(_aports=None):
return {
"channel": "edge",
......@@ -16,48 +19,67 @@ def apk_mocks(monkeypatch):
monkeypatch.setattr(pmb.config.pmaports, "read_config", _pmaports_config)
def _apkindex_package(_package, _arch, _must_exist=False, indexes=None):
def _apkindex_package(
_package: str, _arch: Arch, _must_exist: bool = False, indexes=None
) -> ApkindexBlock:
if _package == "package1":
return {
"pkgname": _package,
"version": "5.5-r0",
"arch": str(_arch),
"depends": ["package2"],
}
return ApkindexBlock(
arch=_arch,
depends=["package2"],
origin=None,
pkgname=_package,
provides=[],
provider_priority=None,
timestamp=None,
version="5.5-r0",
)
if _package == "package2":
return {
"pkgname": _package,
"version": "5.5-r0",
"arch": str(_arch),
"depends": [],
}
return ApkindexBlock(
arch=_arch,
depends=[],
origin=None,
pkgname=_package,
provides=[],
provider_priority=None,
timestamp=None,
version="5.5-r0",
)
if _package == "package3":
return {
"pkgname": _package,
"version": "5.5-r0",
"arch": str(_arch),
"depends": ["package1", "package4"],
}
return ApkindexBlock(
arch=_arch,
depends=["package1", "package4"],
origin=None,
pkgname=_package,
provides=[],
provider_priority=None,
timestamp=None,
version="5.5-r0",
)
# Test recursive dependency
if _package == "package4":
return {
"pkgname": _package,
"version": "5.5-r0",
"arch": str(_arch),
"depends": ["package3"],
}
return ApkindexBlock(
arch=_arch,
depends=["package3"],
origin=None,
pkgname=_package,
provides=[],
provider_priority=None,
timestamp=None,
version="5.5-r0",
)
monkeypatch.setattr(pmb.parse.apkindex, "package", _apkindex_package)
return None
def create_apk(pkgname, arch):
def create_apk(pkgname: str, arch: Arch) -> Path:
apk_file = get_context().config.work / "packages" / "edge" / arch / f"{pkgname}-5.5-r0.apk"
apk_file.parent.mkdir(parents=True, exist_ok=True)
apk_file.touch()
return apk_file
def test_get_local_apks(pmb_args, apk_mocks):
def test_get_local_apks(pmb_args, apk_mocks) -> None:
"""Ensure packages_get_locally_built_apks() returns paths for local apks"""
pkgname = "package1"
......
......@@ -116,7 +116,7 @@ def zap(
logging.info("Dry run: nothing has been deleted")
def zap_pkgs_local_mismatch(confirm=True, dry=False):
def zap_pkgs_local_mismatch(confirm: bool = True, dry: bool = False) -> None:
channel = pmb.config.pmaports.read_config()["channel"]
if not os.path.exists(f"{get_context().config.work}/packages/{channel}"):
return
......@@ -135,10 +135,10 @@ def zap_pkgs_local_mismatch(confirm=True, dry=False):
# Delete packages without same version in aports
blocks = pmb.parse.apkindex.parse_blocks(apkindex_path)
for block in blocks:
pkgname = block["pkgname"]
origin = block["origin"]
version = block["version"]
arch = block["arch"]
pkgname = block.pkgname
origin = block.origin
version = block.version
arch = block.arch
# Apk path
apk_path_short = f"{arch}/{pkgname}-{version}.apk"
......@@ -147,6 +147,9 @@ def zap_pkgs_local_mismatch(confirm=True, dry=False):
logging.info("WARNING: Package mentioned in index not" f" found: {apk_path_short}")
continue
if origin is None:
raise RuntimeError("Can't handle virtual packages")
# Aport path
aport_path = pmb.helpers.pmaports.find_optional(origin)
if not aport_path:
......
# Copyright 2024 Stefan Hansson
# SPDX-License-Identifier: GPL-3.0-or-later
from dataclasses import dataclass
from pmb.core.arch import Arch
@dataclass
class ApkindexBlock:
"""
"depends" is not set for packages without any dependencies, e.g. ``musl``.
"timestamp" and "origin" are not set for virtual packages (#1273).
We use that information to skip these virtual packages in parse().
"""
arch: Arch
depends: list[str] | None
origin: str | None
pkgname: str
provides: list[str]
provider_priority: int | None
timestamp: str | None
version: str
# Copyright 2024 Stefan Hansson
# SPDX-License-Identifier: GPL-3.0-or-later
from dataclasses import dataclass
from typing import Any
import pmb.build._package
from pmb.core.apkindex_block import ApkindexBlock
from pmb.core.context import get_context
@dataclass
class PackageMetadata:
# This can't be list[Arch] because it can have values like "noarch" and "!armhf"
arch: list[str]
depends: list[str]
pkgname: str
provides: list[str]
version: str
@staticmethod
def from_apkindex_block(apkindex_block: ApkindexBlock) -> "PackageMetadata":
return PackageMetadata(
arch=[str(apkindex_block.arch)],
depends=apkindex_block.depends or [],
pkgname=apkindex_block.pkgname,
provides=apkindex_block.provides,
version=apkindex_block.version,
)
@staticmethod
def from_pmaport(pmaport: dict[str, Any]) -> "PackageMetadata":
pmaport_arches = pmaport["arch"]
pmaport_depends = pmb.build._package.get_depends(get_context(), pmaport)
pmaport_pkgname = pmaport["pkgname"]
pmaport_provides = pmaport["provides"]
pmaport_version = pmaport["pkgver"] + "-r" + pmaport["pkgrel"]
return PackageMetadata(
arch=pmaport_arches,
depends=pmaport_depends or [],
pkgname=pmaport_pkgname,
provides=pmaport_provides,
version=pmaport_version,
)
......@@ -36,6 +36,7 @@ import pmb.install
import pmb.install.blockdevice
import pmb.netboot
import pmb.parse
import pmb.parse.apkindex
import pmb.qemu
import pmb.sideload
from pmb.core import ChrootType, Chroot
......@@ -490,7 +491,12 @@ def apkindex_parse(args: PmbArgs) -> None:
if args.package:
if args.package not in result:
raise RuntimeError(f"Package not found in the APKINDEX: {args.package}")
result = result[args.package]
if isinstance(args.package, list):
raise AssertionError
result_temp = result[args.package]
if isinstance(result_temp, pmb.parse.apkindex.ApkindexBlock):
raise AssertionError
result = result_temp
print(json.dumps(result, indent=4))
......
......@@ -4,21 +4,21 @@ import logging
import os
from pathlib import Path
import sys
from typing import TextIO
from typing import Final, TextIO
import pmb.config
from pmb.meta import Cache
logfd: TextIO
CRITICAL = logging.CRITICAL
FATAL = logging.FATAL
ERROR = logging.ERROR
WARNING = logging.WARNING
WARN = logging.WARN
INFO = logging.INFO
DEBUG = logging.DEBUG
NOTSET = logging.NOTSET
VERBOSE = 5
CRITICAL: Final[int] = logging.CRITICAL
FATAL: Final[int] = logging.FATAL
ERROR: Final[int] = logging.ERROR
WARNING: Final[int] = logging.WARNING
WARN: Final[int] = logging.WARN
INFO: Final[int] = logging.INFO
DEBUG: Final[int] = logging.DEBUG
NOTSET: Final[int] = logging.NOTSET
VERBOSE: Final[int] = 5
class log_handler(logging.StreamHandler):
......
......@@ -9,10 +9,9 @@ See also:
- pmb/helpers/repo.py (work with binary package repos)
"""
import copy
from typing import Any, overload
from typing import overload
from pmb.core.arch import Arch
from pmb.core.context import get_context
from pmb.core.package_metadata import PackageMetadata
from pmb.helpers import logging
import pmb.build._package
......@@ -30,27 +29,33 @@ def remove_operators(package):
@overload
def get(pkgname: str, arch: Arch, replace_subpkgnames: bool = False) -> dict[str, Any]: ...
def get(pkgname: str, arch: Arch, replace_subpkgnames: bool = ...) -> PackageMetadata: ...
@overload
def get(
pkgname: str, arch: Arch, replace_subpkgnames: bool = False, must_exist: bool = True
) -> dict[str, Any] | None: ...
pkgname: str, arch: Arch, replace_subpkgnames: bool = ..., must_exist: bool = ...
) -> PackageMetadata | None: ...
@overload
def get(
pkgname: str,
arch: Arch,
replace_subpkgnames: bool = False,
must_exist: bool = True,
try_other_arches: bool = True,
) -> dict[str, Any] | None: ...
replace_subpkgnames: bool = ...,
must_exist: bool = ...,
try_other_arches: bool = ...,
) -> PackageMetadata | None: ...
@Cache("pkgname", "arch", "replace_subpkgnames", "try_other_arches")
def get(pkgname, arch, replace_subpkgnames=False, must_exist=True, try_other_arches=True):
def get(
pkgname: str,
arch: Arch,
replace_subpkgnames: bool = False,
must_exist: bool = True,
try_other_arches: bool = True,
) -> PackageMetadata | None:
"""Find a package in pmaports, and as fallback in the APKINDEXes of the binary packages.
:param pkgname: package name (e.g. "hello-world")
......@@ -71,50 +76,37 @@ def get(pkgname, arch, replace_subpkgnames=False, must_exist=True, try_other_arc
* None if the package was not found
"""
# Find in pmaports
ret: dict[str, Any] = {}
ret: PackageMetadata | None = None
pmaport = pmb.helpers.pmaports.get(pkgname, False)
if pmaport:
ret = {
"arch": pmaport["arch"],
"depends": pmb.build._package.get_depends(get_context(), pmaport),
"pkgname": pmaport["pkgname"],
"provides": pmaport["provides"],
"version": pmaport["pkgver"] + "-r" + pmaport["pkgrel"],
}
ret = PackageMetadata.from_pmaport(pmaport)
# Find in APKINDEX (given arch)
if not ret or not pmb.helpers.pmaports.check_arches(ret["arch"], arch):
if not ret or not pmb.helpers.pmaports.check_arches(ret.arch, arch):
pmb.helpers.repo.update(arch)
ret_repo = pmb.parse.apkindex.package(pkgname, arch, False)
# Save as result if there was no pmaport, or if the pmaport can not be
# built for the given arch, but there is a binary package for that arch
# (e.g. temp/mesa can't be built for x86_64, but Alpine has it)
if not ret or (ret_repo and ret_repo["arch"] == arch):
ret = ret_repo
if ret_repo and (not ret or ret_repo.arch == arch):
ret = PackageMetadata.from_apkindex_block(ret_repo)
# Find in APKINDEX (other arches)
if not ret and try_other_arches:
pmb.helpers.repo.update()
for arch_i in Arch.supported():
if arch_i != arch:
ret = pmb.parse.apkindex.package(pkgname, arch_i, False)
apkindex_block = pmb.parse.apkindex.package(pkgname, arch_i, False)
if apkindex_block is not None:
ret = PackageMetadata.from_apkindex_block(apkindex_block)
if ret:
break
# Copy ret (it might have references to caches of the APKINDEX or APKBUILDs
# and we don't want to modify those!)
if ret:
ret = copy.deepcopy(ret)
# Make sure ret["arch"] is a list (APKINDEX code puts a string there)
if ret and isinstance(ret["arch"], str):
ret["arch"] = [ret["arch"]]
# Replace subpkgnames if desired
if replace_subpkgnames:
if replace_subpkgnames and ret:
depends_new = []
for depend in ret["depends"]:
for depend in ret.depends:
depend_data = get(depend, arch, must_exist=False, try_other_arches=try_other_arches)
if not depend_data:
logging.warning(f"WARNING: {pkgname}: failed to resolve" f" dependency '{depend}'")
......@@ -122,10 +114,10 @@ def get(pkgname, arch, replace_subpkgnames=False, must_exist=True, try_other_arc
if depend not in depends_new:
depends_new += [depend]
continue
depend_pkgname = depend_data["pkgname"]
depend_pkgname = depend_data.pkgname
if depend_pkgname not in depends_new:
depends_new += [depend_pkgname]
ret["depends"] = depends_new
ret.depends = depends_new
# Save to cache and return
if ret:
......@@ -141,7 +133,7 @@ def get(pkgname, arch, replace_subpkgnames=False, must_exist=True, try_other_arc
@Cache("pkgname", "arch")
def depends_recurse(pkgname, arch):
def depends_recurse(pkgname: str, arch: Arch) -> list[str]:
"""Recursively resolve all of the package's dependencies.
:param pkgname: name of the package (e.g. "device-samsung-i9100")
......@@ -158,19 +150,19 @@ def depends_recurse(pkgname, arch):
package = get(pkgname_queue, arch)
# Add its depends to the queue
for depend in package["depends"]:
for depend in package.depends:
if depend not in ret:
queue += [depend]
# Add the pkgname (not possible subpkgname) to ret
if package["pkgname"] not in ret:
ret += [package["pkgname"]]
if package.pkgname not in ret:
ret += [package.pkgname]
ret.sort()
return ret
def check_arch(pkgname, arch, binary=True):
def check_arch(pkgname: str, arch: Arch, binary: bool = True) -> bool:
"""Check if a package be built for a certain architecture, or is there a binary package for it.
:param pkgname: name of the package
......@@ -181,7 +173,7 @@ def check_arch(pkgname, arch, binary=True):
:returns: True when the package can be built, or there is a binary package, False otherwise
"""
if binary:
arches = get(pkgname, arch)["arch"]
arches = get(pkgname, arch).arch
else:
arches = pmb.helpers.pmaports.get(pkgname, must_exist=True)["arch"]
return pmb.helpers.pmaports.check_arches(arches, arch)
......@@ -123,7 +123,7 @@ def auto_apkindex_package(arch, aport, apk, dry: bool = False) -> bool:
return False
def auto(dry=False) -> list[str]:
def auto(dry: bool = False) -> list[str]:
""":returns: list of aport names, where the pkgrel needed to be changed"""
ret = []
for arch in Arch.supported():
......@@ -132,11 +132,19 @@ def auto(dry=False) -> list[str]:
logging.info(f"scan {path}")
index = pmb.parse.apkindex.parse(path, False)
for pkgname, apk in index.items():
origin = apk["origin"]
if isinstance(apk, dict):
raise AssertionError("pmb.parse.apkindex.parse returned an illegal structure")
origin = apk.origin
# Only increase once!
if origin in ret:
logging.verbose(f"{pkgname}: origin '{origin}' found again")
continue
if origin is None:
logging.warning(f"{pkgname}: skipping, is a virtual package")
continue
aport_path = pmb.helpers.pmaports.find_optional(origin)
if not aport_path:
logging.warning(f"{pkgname}: origin '{origin}' aport not found")
......
......@@ -13,7 +13,6 @@ from pmb.core.pkgrepo import pkgrepo_iter_package_dirs
from pmb.helpers import logging
from pathlib import Path
from typing import Any
from collections.abc import Sequence
from pmb.meta import Cache
import pmb.parse
......@@ -46,7 +45,7 @@ def _find_apkbuilds(skip_extra_repos=False) -> dict[str, Path]:
return apkbuilds
def get_list() -> Sequence[str]:
def get_list() -> list[str]:
""":returns: list of all pmaport pkgnames (["hello-world", ...])"""
return list(_find_apkbuilds().keys())
......@@ -215,7 +214,7 @@ def find_optional(package: str) -> Path | None:
# The only caller with subpackages=False is ui.check_option()
@Cache("pkgname", subpackages=True)
def get_with_path(
pkgname, must_exist=True, subpackages=True, skip_extra_repos=False
pkgname: str, must_exist: bool = True, subpackages: bool = True, skip_extra_repos: bool = False
) -> tuple[Path | None, dict[str, Any] | None]:
"""Find and parse an APKBUILD file.
......
# Copyright 2023 Oliver Smith
# SPDX-License-Identifier: GPL-3.0-or-later
from typing import Any
from pmb.core.arch import Arch
from pmb.helpers import logging
import pmb.build
......@@ -90,7 +93,7 @@ def get_relevant_packages(arch, pkgname=None, built=False):
return ret
def generate_output_format(arch, pkgnames):
def generate_output_format(arch: Arch, pkgnames: list[str]) -> list[dict[str, Any]]:
"""Generate the detailed output format.
:param arch: architecture
......@@ -109,12 +112,16 @@ def generate_output_format(arch, pkgnames):
ret = []
for pkgname in pkgnames:
entry = pmb.helpers.package.get(pkgname, arch, True, try_other_arches=False)
if entry is None:
raise RuntimeError(f"Couldn't get package {pkgname} for arch {arch}")
ret += [
{
"pkgname": entry["pkgname"],
"pkgname": entry.pkgname,
"repo": pmb.helpers.pmaports.get_repo(pkgname),
"version": entry["version"],
"depends": entry["depends"],
"version": entry.version,
"depends": entry.depends,
}
]
return ret
......
......@@ -372,7 +372,7 @@ def setup_keymap(config: Config):
def setup_timezone(chroot: Chroot, timezone: str):
# We don't care about the arch since it's built for all!
alpine_conf = pmb.helpers.package.get("alpine-conf", Arch.native())
version = alpine_conf["version"].split("-r")[0]
version = alpine_conf.version.split("-r")[0]
setup_tz_cmd = ["setup-timezone"]
# setup-timezone will, by default, copy the timezone to /etc/zoneinfo
......@@ -700,7 +700,7 @@ def sanity_check_disk_size(args: PmbArgs):
def get_ondev_pkgver(args: PmbArgs):
arch = pmb.parse.deviceinfo().arch
package = pmb.helpers.package.get("postmarketos-ondev", arch)
return package["version"].split("-r")[0]
return package.version.split("-r")[0]
def sanity_check_ondev_version(args: PmbArgs):
......