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
|
@ -3,12 +3,12 @@
|
|||
from pmb.helpers import logging
|
||||
|
||||
import pmb.build
|
||||
from pmb.core.types import PmbArgs
|
||||
from pmb.types import PmbArgs
|
||||
import pmb.helpers.package
|
||||
import pmb.helpers.pmaports
|
||||
|
||||
|
||||
def filter_missing_packages(args: PmbArgs, arch, pkgnames):
|
||||
def filter_missing_packages(arch, pkgnames):
|
||||
"""Create a subset of pkgnames with missing or outdated binary packages.
|
||||
|
||||
:param arch: architecture (e.g. "armhf")
|
||||
|
@ -17,15 +17,15 @@ def filter_missing_packages(args: PmbArgs, arch, pkgnames):
|
|||
"""
|
||||
ret = []
|
||||
for pkgname in pkgnames:
|
||||
binary = pmb.parse.apkindex.package(args, pkgname, arch, False)
|
||||
binary = pmb.parse.apkindex.package(pkgname, arch, False)
|
||||
must_exist = False if binary else True
|
||||
pmaport = pmb.helpers.pmaports.get(args, pkgname, must_exist)
|
||||
if pmaport and pmb.build.is_necessary(args, arch, pmaport):
|
||||
pmaport = pmb.helpers.pmaports.get(pkgname, must_exist)
|
||||
if pmaport and pmb.build.is_necessary(arch, pmaport):
|
||||
ret.append(pkgname)
|
||||
return ret
|
||||
|
||||
|
||||
def filter_aport_packages(args: PmbArgs, arch, pkgnames):
|
||||
def filter_aport_packages(pkgnames):
|
||||
"""Create a subset of pkgnames where each one has an aport.
|
||||
|
||||
:param arch: architecture (e.g. "armhf")
|
||||
|
@ -34,12 +34,12 @@ def filter_aport_packages(args: PmbArgs, arch, pkgnames):
|
|||
"""
|
||||
ret = []
|
||||
for pkgname in pkgnames:
|
||||
if pmb.helpers.pmaports.find_optional(args, pkgname):
|
||||
if pmb.helpers.pmaports.find_optional(pkgname):
|
||||
ret += [pkgname]
|
||||
return ret
|
||||
|
||||
|
||||
def filter_arch_packages(args: PmbArgs, arch, pkgnames):
|
||||
def filter_arch_packages(arch, pkgnames):
|
||||
"""Create a subset of pkgnames with packages removed that can not be built for a certain arch.
|
||||
|
||||
:param arch: architecture (e.g. "armhf")
|
||||
|
@ -48,12 +48,12 @@ def filter_arch_packages(args: PmbArgs, arch, pkgnames):
|
|||
"""
|
||||
ret = []
|
||||
for pkgname in pkgnames:
|
||||
if pmb.helpers.package.check_arch(args, pkgname, arch, False):
|
||||
if pmb.helpers.package.check_arch(pkgname, arch, False):
|
||||
ret += [pkgname]
|
||||
return ret
|
||||
|
||||
|
||||
def get_relevant_packages(args: PmbArgs, arch, pkgname=None, built=False):
|
||||
def get_relevant_packages(arch, pkgname=None, built=False):
|
||||
"""Get all packages that can be built for the architecture in question.
|
||||
|
||||
:param arch: architecture (e.g. "armhf")
|
||||
|
@ -63,20 +63,20 @@ def get_relevant_packages(args: PmbArgs, arch, pkgname=None, built=False):
|
|||
["devicepkg-dev", "hello-world", "osk-sdl"]
|
||||
"""
|
||||
if pkgname:
|
||||
if not pmb.helpers.package.check_arch(args, pkgname, arch, False):
|
||||
if not pmb.helpers.package.check_arch(pkgname, arch, False):
|
||||
raise RuntimeError(pkgname + " can't be built for " + arch + ".")
|
||||
ret = pmb.helpers.package.depends_recurse(args, pkgname, arch)
|
||||
ret = pmb.helpers.package.depends_recurse(pkgname, arch)
|
||||
else:
|
||||
ret = pmb.helpers.pmaports.get_list(args)
|
||||
ret = filter_arch_packages(args, arch, ret)
|
||||
ret = pmb.helpers.pmaports.get_list()
|
||||
ret = filter_arch_packages(arch, ret)
|
||||
if built:
|
||||
ret = filter_aport_packages(args, arch, ret)
|
||||
ret = filter_aport_packages(ret)
|
||||
if not len(ret):
|
||||
logging.info("NOTE: no aport found for any package in the"
|
||||
" dependency tree, it seems they are all provided by"
|
||||
" upstream (Alpine).")
|
||||
else:
|
||||
ret = filter_missing_packages(args, arch, ret)
|
||||
ret = filter_missing_packages(arch, ret)
|
||||
if not len(ret):
|
||||
logging.info("NOTE: all relevant packages are up to date, use"
|
||||
" --built to include the ones that have already been"
|
||||
|
@ -87,7 +87,7 @@ def get_relevant_packages(args: PmbArgs, arch, pkgname=None, built=False):
|
|||
return ret
|
||||
|
||||
|
||||
def generate_output_format(args: PmbArgs, arch, pkgnames):
|
||||
def generate_output_format(arch, pkgnames):
|
||||
"""Generate the detailed output format.
|
||||
|
||||
:param arch: architecture
|
||||
|
@ -105,15 +105,15 @@ def generate_output_format(args: PmbArgs, arch, pkgnames):
|
|||
"""
|
||||
ret = []
|
||||
for pkgname in pkgnames:
|
||||
entry = pmb.helpers.package.get(args, pkgname, arch, True)
|
||||
entry = pmb.helpers.package.get(pkgname, arch, True)
|
||||
ret += [{"pkgname": entry["pkgname"],
|
||||
"repo": pmb.helpers.pmaports.get_repo(args, pkgname),
|
||||
"repo": pmb.helpers.pmaports.get_repo(pkgname),
|
||||
"version": entry["version"],
|
||||
"depends": entry["depends"]}]
|
||||
return ret
|
||||
|
||||
|
||||
def generate(args: PmbArgs, arch, overview, pkgname=None, built=False):
|
||||
def generate(arch, overview, pkgname=None, built=False):
|
||||
"""Get packages that need to be built, with all their dependencies.
|
||||
|
||||
:param arch: architecture (e.g. "armhf")
|
||||
|
@ -129,9 +129,9 @@ def generate(args: PmbArgs, arch, overview, pkgname=None, built=False):
|
|||
"".format(packages_str, arch))
|
||||
|
||||
# Order relevant packages
|
||||
ret = get_relevant_packages(args, arch, pkgname, built)
|
||||
ret = get_relevant_packages(arch, pkgname, built)
|
||||
|
||||
# Output format
|
||||
if overview:
|
||||
return ret
|
||||
return generate_output_format(args, arch, ret)
|
||||
return generate_output_format(arch, ret)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue