2023-01-22 18:11:10 +00:00
|
|
|
# Copyright 2023 Oliver Smith
|
2020-02-20 20:07:28 +00:00
|
|
|
# SPDX-License-Identifier: GPL-3.0-or-later
|
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
2018-11-15 07:36:39 +00:00
|
|
|
import logging
|
|
|
|
|
|
|
|
import pmb.build
|
|
|
|
import pmb.helpers.package
|
|
|
|
import pmb.helpers.pmaports
|
|
|
|
|
|
|
|
|
|
|
|
def filter_missing_packages(args, arch, pkgnames):
|
|
|
|
""" Create a subset of pkgnames with missing or outdated binary packages.
|
|
|
|
|
|
|
|
:param arch: architecture (e.g. "armhf")
|
|
|
|
:param pkgnames: list of package names (e.g. ["hello-world", "test12"])
|
|
|
|
:returns: subset of pkgnames (e.g. ["hello-world"]) """
|
|
|
|
ret = []
|
|
|
|
for pkgname in pkgnames:
|
|
|
|
binary = pmb.parse.apkindex.package(args, 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):
|
|
|
|
ret.append(pkgname)
|
|
|
|
return ret
|
|
|
|
|
|
|
|
|
|
|
|
def filter_aport_packages(args, arch, pkgnames):
|
|
|
|
""" Create a subset of pkgnames where each one has an aport.
|
|
|
|
|
|
|
|
:param arch: architecture (e.g. "armhf")
|
|
|
|
:param pkgnames: list of package names (e.g. ["hello-world", "test12"])
|
|
|
|
:returns: subset of pkgnames (e.g. ["hello-world"]) """
|
|
|
|
ret = []
|
|
|
|
for pkgname in pkgnames:
|
|
|
|
if pmb.helpers.pmaports.find(args, pkgname, False):
|
|
|
|
ret += [pkgname]
|
|
|
|
return ret
|
|
|
|
|
|
|
|
|
|
|
|
def filter_arch_packages(args, arch, pkgnames):
|
|
|
|
""" Create a subset of pkgnames with packages removed that can not be
|
2019-10-01 08:42:31 +00:00
|
|
|
built for a certain arch.
|
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
2018-11-15 07:36:39 +00:00
|
|
|
|
|
|
|
:param arch: architecture (e.g. "armhf")
|
|
|
|
:param pkgnames: list of package names (e.g. ["hello-world", "test12"])
|
|
|
|
:returns: subset of pkgnames (e.g. ["hello-world"]) """
|
|
|
|
ret = []
|
|
|
|
for pkgname in pkgnames:
|
2019-10-01 08:42:31 +00:00
|
|
|
if pmb.helpers.package.check_arch(args, pkgname, arch, False):
|
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
2018-11-15 07:36:39 +00:00
|
|
|
ret += [pkgname]
|
|
|
|
return ret
|
|
|
|
|
|
|
|
|
|
|
|
def get_relevant_packages(args, arch, pkgname=None, built=False):
|
|
|
|
""" Get all packages that can be built for the architecture in question.
|
|
|
|
|
|
|
|
:param arch: architecture (e.g. "armhf")
|
|
|
|
:param pkgname: only look at a specific package (and its dependencies)
|
|
|
|
:param built: include packages that have already been built
|
|
|
|
:returns: an alphabetically sorted list of pkgnames, e.g.:
|
|
|
|
["devicepkg-dev", "hello-world", "osk-sdl"] """
|
|
|
|
if pkgname:
|
2019-10-01 08:42:31 +00:00
|
|
|
if not pmb.helpers.package.check_arch(args, pkgname, arch, False):
|
|
|
|
raise RuntimeError(pkgname + " can't be built for " + arch + ".")
|
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
2018-11-15 07:36:39 +00:00
|
|
|
ret = pmb.helpers.package.depends_recurse(args, pkgname, arch)
|
|
|
|
else:
|
|
|
|
ret = pmb.helpers.pmaports.get_list(args)
|
|
|
|
ret = filter_arch_packages(args, arch, ret)
|
|
|
|
if built:
|
|
|
|
ret = filter_aport_packages(args, arch, 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)
|
|
|
|
if not len(ret):
|
|
|
|
logging.info("NOTE: all relevant packages are up to date, use"
|
|
|
|
" --built to include the ones that have already been"
|
|
|
|
" built.")
|
|
|
|
|
|
|
|
# Sort alphabetically (to get a deterministic build order)
|
|
|
|
ret.sort()
|
|
|
|
return ret
|
|
|
|
|
|
|
|
|
|
|
|
def generate_output_format(args, arch, pkgnames):
|
|
|
|
""" Generate the detailed output format.
|
|
|
|
:param arch: architecture
|
|
|
|
:param pkgnames: list of package names that should be in the output,
|
|
|
|
e.g.: ["hello-world", "pkg-depending-on-hello-world"]
|
|
|
|
:returns: a list like the following:
|
|
|
|
[{"pkgname": "hello-world",
|
|
|
|
"repo": "main",
|
|
|
|
"version": "1-r4",
|
|
|
|
"depends": []},
|
|
|
|
{"pkgname": "pkg-depending-on-hello-world",
|
|
|
|
"version": "0.5-r0",
|
|
|
|
"repo": "main",
|
|
|
|
"depends": ["hello-world"]}] """
|
|
|
|
ret = []
|
|
|
|
for pkgname in pkgnames:
|
2019-02-15 14:32:39 +00:00
|
|
|
entry = pmb.helpers.package.get(args, pkgname, arch, True)
|
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
2018-11-15 07:36:39 +00:00
|
|
|
ret += [{"pkgname": entry["pkgname"],
|
|
|
|
"repo": pmb.helpers.pmaports.get_repo(args, pkgname),
|
|
|
|
"version": entry["version"],
|
|
|
|
"depends": entry["depends"]}]
|
|
|
|
return ret
|
|
|
|
|
|
|
|
|
|
|
|
def generate(args, arch, overview, pkgname=None, built=False):
|
|
|
|
""" Get packages that need to be built, with all their dependencies.
|
|
|
|
|
|
|
|
:param arch: architecture (e.g. "armhf")
|
|
|
|
:param pkgname: only look at a specific package
|
|
|
|
:param built: include packages that have already been built
|
|
|
|
:returns: a list like the following:
|
|
|
|
[{"pkgname": "hello-world",
|
|
|
|
"repo": "main",
|
|
|
|
"version": "1-r4"},
|
|
|
|
{"pkgname": "package-depending-on-hello-world",
|
|
|
|
"version": "0.5-r0",
|
|
|
|
"repo": "main"}]
|
|
|
|
"""
|
|
|
|
# Log message
|
|
|
|
packages_str = pkgname if pkgname else "all packages"
|
2019-10-01 08:42:31 +00:00
|
|
|
logging.info("Calculate packages that need to be built ({}, {})"
|
|
|
|
"".format(packages_str, arch))
|
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
2018-11-15 07:36:39 +00:00
|
|
|
|
|
|
|
# Order relevant packages
|
|
|
|
ret = get_relevant_packages(args, arch, pkgname, built)
|
|
|
|
|
|
|
|
# Output format
|
|
|
|
if overview:
|
|
|
|
return ret
|
|
|
|
return generate_output_format(args, arch, ret)
|