new action: 'pmbootstrap repo_missing'

Add a new action that lists all aports, for which no binary packages
exist. Only list packages that can be built for the relevant arch
(specified with --arch). This works recursively: when a package can be
built for a certain arch, but one of its dependencies
(or their depends) can not be built for that arch, then don't list it.

This action will be used for the new sr.ht based build infrastructure,
to figure out which packages need to be built ahead of time (so we can
trigger each of them as single build job). Determining the order of the
packages to be built is not determined with pmbootstrap, the serverside
code of build.postmarketos.org takes care of that.

For testing purposes, a single package can also be specified and the
action will list if it can be built for that arch with its
dependencies, and what needs to be built exactly.

Add pmb/helpers/package.py to hold functions that work on both pmaports
and (binary package) repos - in contrary to the existing
pmb/helpers/pmaports.py (see previous commit) and pmb/helpers/repo.py,
which only work with one of those.

Refactoring:
* pmb/helpers/pmaports.py: add a get_list() function, which lists all
  aports and use it instead of writing the same glob loop over and over
* add pmb.helpers.pmaports.get(), which finds an APKBUILD and parses it
  in one step.
* rename pmb.build._package.check_arch to ...check_arch_abort to
  distinguish it from the other check_arch function
This commit is contained in:
Oliver Smith 2018-11-15 08:36:39 +01:00 committed by Martijn Braam
parent a44b80b31d
commit 933c4d0f0d
13 changed files with 787 additions and 29 deletions

View file

@ -18,8 +18,6 @@ along with pmbootstrap. If not, see <http://www.gnu.org/licenses/>.
"""
import argparse
import copy
import glob
import os
try:
import argcomplete
@ -29,6 +27,7 @@ except ImportError:
import pmb.config
import pmb.parse.arch
import pmb.helpers.args
import pmb.helpers.pmaports
""" This file is about parsing command line arguments passed to pmbootstrap, as
well as generating the help pages (pmbootstrap -h). All this is done with
@ -235,12 +234,25 @@ def arguments_kconfig(subparser):
edit.add_argument("package")
def arguments_repo_missing(subparser):
ret = subparser.add_parser("repo_missing")
package = ret.add_argument("package", nargs="?", help="only look at a"
" specific package and its dependencies")
if argcomplete:
package.completer = packagecompleter
ret.add_argument("--arch", choices=pmb.config.build_device_architectures,
default=pmb.parse.arch.alpine_native())
ret.add_argument("--built", action="store_true",
help="include packages which exist in the binary repos")
ret.add_argument("--overview", action="store_true",
help="only print the pkgnames without any details")
return ret
def packagecompleter(prefix, action, parser, parsed_args):
args = parsed_args
pmb.config.merge_with_args(args)
packages = set()
for apkbuild in glob.glob(args.aports + "/*/" + prefix + "*/APKBUILD"):
packages.add(os.path.basename(os.path.dirname(apkbuild)))
packages = set(pmb.helpers.pmaports.get_list(args))
return packages
@ -315,6 +327,7 @@ def arguments():
sub.add_parser("work_migrate", help="run this before using pmbootstrap"
" non-interactively to migrate the"
" work folder version on demand")
arguments_repo_missing(sub)
arguments_kconfig(sub)
arguments_export(sub)
arguments_flasher(sub)