forked from Mirror/pmbootstrap
WIP: start ripping out args (MR 2252)
Cease merging pmbootstrap.cfg into args, implement a Context type to let us pull globals out of thin air (as an intermediate workaround) and rip args out of a lot of the codebase. This is just a first pass, after this we can split all the state that leaked over into Context into types with narrower scopes (like a BuildContext(), etc). Signed-off-by: Caleb Connolly <caleb@postmarketos.org>
This commit is contained in:
parent
bfea00e03a
commit
34dd9d42ba
129 changed files with 1393 additions and 1300 deletions
|
@ -12,7 +12,7 @@ import copy
|
|||
from typing import Any, Dict
|
||||
from pmb.helpers import logging
|
||||
|
||||
from pmb.core.types import PmbArgs
|
||||
from pmb.types import PmbArgs
|
||||
import pmb.helpers.pmaports
|
||||
import pmb.helpers.repo
|
||||
|
||||
|
@ -25,7 +25,7 @@ def remove_operators(package):
|
|||
return package
|
||||
|
||||
|
||||
def get(args: PmbArgs, pkgname, arch, replace_subpkgnames=False, must_exist=True):
|
||||
def get(pkgname, arch, replace_subpkgnames=False, must_exist=True):
|
||||
"""Find a package in pmaports, and as fallback in the APKINDEXes of the binary packages.
|
||||
|
||||
:param pkgname: package name (e.g. "hello-world")
|
||||
|
@ -59,7 +59,7 @@ def get(args: PmbArgs, pkgname, arch, replace_subpkgnames=False, must_exist=True
|
|||
|
||||
# Find in pmaports
|
||||
ret: Dict[str, Any] = {}
|
||||
pmaport = pmb.helpers.pmaports.get(args, pkgname, False)
|
||||
pmaport = pmb.helpers.pmaports.get(pkgname, False)
|
||||
if pmaport:
|
||||
ret = {"arch": pmaport["arch"],
|
||||
"depends": pmb.build._package.get_depends(args, pmaport),
|
||||
|
@ -69,8 +69,8 @@ def get(args: PmbArgs, pkgname, arch, replace_subpkgnames=False, must_exist=True
|
|||
|
||||
# Find in APKINDEX (given arch)
|
||||
if not ret or not pmb.helpers.pmaports.check_arches(ret["arch"], arch):
|
||||
pmb.helpers.repo.update(args, arch)
|
||||
ret_repo = pmb.parse.apkindex.package(args, pkgname, arch, False)
|
||||
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
|
||||
|
@ -80,10 +80,10 @@ def get(args: PmbArgs, pkgname, arch, replace_subpkgnames=False, must_exist=True
|
|||
|
||||
# Find in APKINDEX (other arches)
|
||||
if not ret:
|
||||
pmb.helpers.repo.update(args)
|
||||
pmb.helpers.repo.update()
|
||||
for arch_i in pmb.config.build_device_architectures:
|
||||
if arch_i != arch:
|
||||
ret = pmb.parse.apkindex.package(args, pkgname, arch_i, False)
|
||||
ret = pmb.parse.apkindex.package(pkgname, arch_i, False)
|
||||
if ret:
|
||||
break
|
||||
|
||||
|
@ -100,7 +100,7 @@ def get(args: PmbArgs, pkgname, arch, replace_subpkgnames=False, must_exist=True
|
|||
if replace_subpkgnames:
|
||||
depends_new = []
|
||||
for depend in ret["depends"]:
|
||||
depend_data = get(args, depend, arch, must_exist=False)
|
||||
depend_data = get(depend, arch, must_exist=False)
|
||||
if not depend_data:
|
||||
logging.warning(f"WARNING: {pkgname}: failed to resolve"
|
||||
f" dependency '{depend}'")
|
||||
|
@ -131,7 +131,7 @@ def get(args: PmbArgs, pkgname, arch, replace_subpkgnames=False, must_exist=True
|
|||
" could not find this package in any APKINDEX!")
|
||||
|
||||
|
||||
def depends_recurse(args: PmbArgs, pkgname, arch):
|
||||
def depends_recurse(pkgname, arch):
|
||||
"""Recursively resolve all of the package's dependencies.
|
||||
|
||||
:param pkgname: name of the package (e.g. "device-samsung-i9100")
|
||||
|
@ -151,7 +151,7 @@ def depends_recurse(args: PmbArgs, pkgname, arch):
|
|||
ret = []
|
||||
while len(queue):
|
||||
pkgname_queue = queue.pop()
|
||||
package = get(args, pkgname_queue, arch)
|
||||
package = get(pkgname_queue, arch)
|
||||
|
||||
# Add its depends to the queue
|
||||
for depend in package["depends"]:
|
||||
|
@ -170,7 +170,7 @@ def depends_recurse(args: PmbArgs, pkgname, arch):
|
|||
return ret
|
||||
|
||||
|
||||
def check_arch(args: PmbArgs, pkgname, arch, binary=True):
|
||||
def check_arch(pkgname, arch, binary=True):
|
||||
"""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 +181,7 @@ def check_arch(args: PmbArgs, pkgname, arch, binary=True):
|
|||
:returns: True when the package can be built, or there is a binary package, False otherwise
|
||||
"""
|
||||
if binary:
|
||||
arches = get(args, pkgname, arch)["arch"]
|
||||
arches = get(pkgname, arch)["arch"]
|
||||
else:
|
||||
arches = pmb.helpers.pmaports.get(args, pkgname)["arch"]
|
||||
arches = pmb.helpers.pmaports.get(pkgname)["arch"]
|
||||
return pmb.helpers.pmaports.check_arches(arches, arch)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue