2021-01-07 22:30:30 +00:00
|
|
|
# Copyright 2021 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
|
|
|
"""
|
2020-04-10 10:33:50 +00:00
|
|
|
Functions that work with pmaports. See also:
|
|
|
|
- pmb/helpers/repo.py (work with binary package repos)
|
|
|
|
- pmb/helpers/package.py (work with both)
|
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
|
|
|
"""
|
2018-11-15 07:30:49 +00:00
|
|
|
import glob
|
|
|
|
import logging
|
|
|
|
import os
|
|
|
|
|
|
|
|
import pmb.parse
|
|
|
|
|
|
|
|
|
2020-03-30 07:52:47 +00:00
|
|
|
def _find_apkbuilds(args):
|
2021-09-26 15:50:11 +00:00
|
|
|
# Try to get a cached result first (we assume that the aports don't change
|
2020-03-25 21:31:40 +00:00
|
|
|
# in one pmbootstrap call)
|
2020-03-30 07:52:47 +00:00
|
|
|
apkbuilds = args.cache.get("pmb.helpers.pmaports.apkbuilds")
|
|
|
|
if apkbuilds is not None:
|
|
|
|
return apkbuilds
|
2020-03-25 21:31:40 +00:00
|
|
|
|
2020-03-30 07:52:47 +00:00
|
|
|
apkbuilds = {}
|
|
|
|
for apkbuild in glob.iglob(f"{args.aports}/**/*/APKBUILD", recursive=True):
|
|
|
|
package = os.path.basename(os.path.dirname(apkbuild))
|
|
|
|
if package in apkbuilds:
|
|
|
|
raise RuntimeError(f"Package {package} found in multiple aports "
|
|
|
|
"subfolders. Please put it only in one folder.")
|
|
|
|
apkbuilds[package] = apkbuild
|
|
|
|
|
2021-05-19 18:36:24 +00:00
|
|
|
# Sort dictionary so we don't need to do it over and over again in
|
|
|
|
# get_list()
|
2020-03-30 07:52:47 +00:00
|
|
|
apkbuilds = dict(sorted(apkbuilds.items()))
|
2020-03-25 21:31:40 +00:00
|
|
|
|
|
|
|
# Save result in cache
|
2020-03-30 07:52:47 +00:00
|
|
|
args.cache["pmb.helpers.pmaports.apkbuilds"] = apkbuilds
|
|
|
|
return apkbuilds
|
2020-02-26 11:13:26 +00:00
|
|
|
|
|
|
|
|
2020-03-30 07:52:47 +00:00
|
|
|
def get_list(args):
|
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
|
|
|
""" :returns: list of all pmaport pkgnames (["hello-world", ...]) """
|
2020-03-30 07:52:47 +00:00
|
|
|
return list(_find_apkbuilds(args).keys())
|
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
|
|
|
|
|
|
|
|
2019-10-20 17:53:54 +00:00
|
|
|
def guess_main_dev(args, subpkgname):
|
|
|
|
"""
|
|
|
|
Check if a package without "-dev" at the end exists in pmaports or not, and
|
|
|
|
log the appropriate message. Don't call this function directly, use
|
|
|
|
guess_main() instead.
|
|
|
|
|
|
|
|
:param subpkgname: subpackage name, must end in "-dev"
|
|
|
|
:returns: full path to the pmaport or None
|
|
|
|
"""
|
|
|
|
pkgname = subpkgname[:-4]
|
2020-03-30 07:52:47 +00:00
|
|
|
path = _find_apkbuilds(args).get(pkgname)
|
|
|
|
if path:
|
2020-03-30 13:47:46 +00:00
|
|
|
logging.verbose(subpkgname + ": guessed to be a subpackage of " +
|
|
|
|
pkgname + " (just removed '-dev')")
|
2020-03-30 07:52:47 +00:00
|
|
|
return os.path.dirname(path)
|
2019-10-20 17:53:54 +00:00
|
|
|
|
2020-03-30 13:47:46 +00:00
|
|
|
logging.verbose(subpkgname + ": guessed to be a subpackage of " + pkgname +
|
|
|
|
", which we can't find in pmaports, so it's probably in"
|
|
|
|
" Alpine")
|
2019-10-20 17:53:54 +00:00
|
|
|
return None
|
|
|
|
|
|
|
|
|
2018-11-15 07:30:49 +00:00
|
|
|
def guess_main(args, subpkgname):
|
|
|
|
"""
|
|
|
|
Find the main package by assuming it is a prefix of the subpkgname.
|
|
|
|
We do that, because in some APKBUILDs the subpkgname="" variable gets
|
|
|
|
filled with a shell loop and the APKBUILD parser in pmbootstrap can't
|
|
|
|
parse this right. (Intentionally, we don't want to implement a full shell
|
|
|
|
parser.)
|
|
|
|
|
|
|
|
:param subpkgname: subpackage name (e.g. "u-boot-some-device")
|
|
|
|
:returns: * full path to the aport, e.g.:
|
|
|
|
"/home/user/code/pmbootstrap/aports/main/u-boot"
|
|
|
|
* None when we couldn't find a main package
|
|
|
|
"""
|
2019-10-20 17:53:54 +00:00
|
|
|
# Packages ending in -dev: just assume that the originating aport has the
|
|
|
|
# same pkgname, except for the -dev at the end. If we use the other method
|
|
|
|
# below on subpackages, we may end up with the wrong package. For example,
|
|
|
|
# if something depends on plasma-framework-dev, and plasma-framework is in
|
|
|
|
# Alpine, but plasma is in pmaports, then the cutting algorithm below would
|
|
|
|
# pick plasma instead of plasma-framework.
|
|
|
|
if subpkgname.endswith("-dev"):
|
|
|
|
return guess_main_dev(args, subpkgname)
|
|
|
|
|
2018-11-15 07:30:49 +00:00
|
|
|
# Iterate until the cut up subpkgname is gone
|
|
|
|
words = subpkgname.split("-")
|
|
|
|
while len(words) > 1:
|
|
|
|
# Remove one dash-separated word at a time ("a-b-c" -> "a-b")
|
|
|
|
words.pop()
|
|
|
|
pkgname = "-".join(words)
|
|
|
|
|
|
|
|
# Look in pmaports
|
2020-03-30 07:52:47 +00:00
|
|
|
path = _find_apkbuilds(args).get(pkgname)
|
|
|
|
if path:
|
2020-03-30 13:47:46 +00:00
|
|
|
logging.verbose(subpkgname + ": guessed to be a subpackage of " +
|
|
|
|
pkgname)
|
2020-03-30 07:52:47 +00:00
|
|
|
return os.path.dirname(path)
|
2018-11-15 07:30:49 +00:00
|
|
|
|
|
|
|
|
|
|
|
def find(args, package, must_exist=True):
|
|
|
|
"""
|
2021-09-26 15:50:11 +00:00
|
|
|
Find the aport path that provides a certain subpackage.
|
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
|
|
|
If you want the parsed APKBUILD instead, use pmb.helpers.pmaports.get().
|
2018-11-15 07:30:49 +00:00
|
|
|
|
|
|
|
:param must_exist: Raise an exception, when not found
|
|
|
|
:returns: the full path to the aport folder
|
|
|
|
"""
|
2021-09-26 15:50:11 +00:00
|
|
|
# Try to get a cached result first (we assume that the aports don't change
|
2018-11-15 07:30:49 +00:00
|
|
|
# in one pmbootstrap call)
|
|
|
|
ret = None
|
|
|
|
if package in args.cache["find_aport"]:
|
|
|
|
ret = args.cache["find_aport"][package]
|
|
|
|
else:
|
|
|
|
# Sanity check
|
|
|
|
if "*" in package:
|
|
|
|
raise RuntimeError("Invalid pkgname: " + package)
|
|
|
|
|
|
|
|
# Search in packages
|
2020-03-30 07:52:47 +00:00
|
|
|
path = _find_apkbuilds(args).get(package)
|
|
|
|
if path:
|
|
|
|
ret = os.path.dirname(path)
|
2018-11-15 07:30:49 +00:00
|
|
|
|
2018-12-10 19:48:57 +00:00
|
|
|
# Search in subpackages and provides
|
2018-11-15 07:30:49 +00:00
|
|
|
if not ret:
|
2020-03-30 07:52:47 +00:00
|
|
|
for path_current in _find_apkbuilds(args).values():
|
2018-11-15 07:30:49 +00:00
|
|
|
apkbuild = pmb.parse.apkbuild(args, path_current)
|
2018-12-10 19:48:57 +00:00
|
|
|
found = False
|
|
|
|
|
|
|
|
# Subpackages
|
2020-01-27 23:23:09 +00:00
|
|
|
if package in apkbuild["subpackages"]:
|
|
|
|
found = True
|
2018-12-10 19:48:57 +00:00
|
|
|
|
|
|
|
# Provides (cut off before equals sign for entries like
|
|
|
|
# "mkbootimg=0.0.1")
|
|
|
|
if not found:
|
|
|
|
for provides_i in apkbuild["provides"]:
|
pmb/helpers/pmaports: ignore provides without ver (!1851)
The APKBUILD reference for "provides" [1] is not worded clearly; but
after reading it over and over again, my understanding is:
* package with provides='foo=1.2' will be automatically installed if
user requests installing "foo"
* package with provides='foo' (without version) will NOT get
automatically installed if user requests installing "foo"
For pmbootstrap, this means, that we must not attempt to build a package
where the pkgname mentioned in provides matches what we are currently
resolving, unless there is an equals sign in the provides entry.
Fixes: #1862, pmaports#404
[1] https://wiki.alpinelinux.org/wiki/APKBUILD_Reference#provides says:
"List of package names (and optionally version info) this package
provides.
If package with a version is provided (provides='foo=1.2') apk will
consider it as an alternate name and it will automatically consider the
package for installation by the alternate name, and conflict with other
packages having the same name, or provides.
If version is not provided (provides='foo'), apk will consider it as
virtual package name. Several package with same non-versioned provides
can be installed simultaneously. However, none of them will be installed
by default when requested by the virtual name - instead, error message
is given and user is asked to choose which package providing the virtual
name should be installed."
2020-01-02 15:55:33 +00:00
|
|
|
# Ignore provides without version, they shall never be
|
|
|
|
# automatically selected
|
|
|
|
if "=" not in provides_i:
|
|
|
|
continue
|
|
|
|
|
2018-12-10 19:48:57 +00:00
|
|
|
if package == provides_i.split("=", 1)[0]:
|
|
|
|
found = True
|
|
|
|
break
|
|
|
|
|
|
|
|
if found:
|
2018-11-15 07:30:49 +00:00
|
|
|
ret = os.path.dirname(path_current)
|
|
|
|
break
|
|
|
|
|
|
|
|
# Guess a main package
|
|
|
|
if not ret:
|
|
|
|
ret = guess_main(args, package)
|
|
|
|
|
|
|
|
# Crash when necessary
|
|
|
|
if ret is None and must_exist:
|
|
|
|
raise RuntimeError("Could not find aport for package: " +
|
|
|
|
package)
|
|
|
|
|
|
|
|
# Save result in cache
|
|
|
|
args.cache["find_aport"][package] = ret
|
|
|
|
return ret
|
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
|
|
|
|
|
|
|
|
2020-04-12 15:15:19 +00:00
|
|
|
def get(args, pkgname, must_exist=True, subpackages=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
|
|
|
""" Find and parse an APKBUILD file.
|
|
|
|
Run 'pmbootstrap apkbuild_parse hello-world' for a full output example.
|
|
|
|
Relevant variables are defined in pmb.config.apkbuild_attributes.
|
|
|
|
|
|
|
|
:param pkgname: the package name to find
|
|
|
|
:param must_exist: raise an exception when it can't be found
|
2021-05-19 18:36:24 +00:00
|
|
|
:param subpackages: also search for subpackages with the specified
|
|
|
|
names (slow! might need to parse all APKBUILDs to
|
|
|
|
find it)
|
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
|
|
|
:returns: relevant variables from the APKBUILD as dictionary, e.g.:
|
|
|
|
{ "pkgname": "hello-world",
|
|
|
|
"arch": ["all"],
|
|
|
|
"pkgrel": "4",
|
|
|
|
"pkgrel": "1",
|
|
|
|
"options": [],
|
|
|
|
... }
|
|
|
|
"""
|
2020-04-12 15:15:19 +00:00
|
|
|
if subpackages:
|
|
|
|
aport = find(args, pkgname, must_exist)
|
|
|
|
if aport:
|
|
|
|
return pmb.parse.apkbuild(args, aport + "/APKBUILD")
|
|
|
|
else:
|
|
|
|
path = _find_apkbuilds(args).get(pkgname)
|
|
|
|
if path:
|
|
|
|
return pmb.parse.apkbuild(args, path)
|
|
|
|
if must_exist:
|
2021-05-19 18:36:24 +00:00
|
|
|
raise RuntimeError("Could not find APKBUILD for package:"
|
|
|
|
f" {pkgname}")
|
2020-04-12 15:15:19 +00:00
|
|
|
|
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
|
|
|
return None
|
|
|
|
|
|
|
|
|
|
|
|
def get_repo(args, pkgname, must_exist=True):
|
|
|
|
""" Get the repository folder of an aport.
|
|
|
|
|
|
|
|
:pkgname: package name
|
|
|
|
:must_exist: raise an exception when it can't be found
|
|
|
|
:returns: a string like "main", "device", "cross", ...
|
|
|
|
or None when the aport could not be found """
|
|
|
|
aport = find(args, pkgname, must_exist)
|
|
|
|
if not aport:
|
|
|
|
return None
|
|
|
|
return os.path.basename(os.path.dirname(aport))
|
2019-04-19 23:20:16 +00:00
|
|
|
|
|
|
|
|
|
|
|
def check_arches(arches, arch):
|
|
|
|
""" Check if building for a certain arch is allowed.
|
|
|
|
|
|
|
|
:param arches: list of all supported arches, as it can be found in the
|
|
|
|
arch="" line of APKBUILDS (including all, noarch,
|
|
|
|
!arch, ...). For example: ["x86_64", "x86", "!armhf"]
|
|
|
|
:param arch: the architecture to check for
|
|
|
|
:returns: True when building is allowed, False otherwise
|
|
|
|
"""
|
|
|
|
if "!" + arch in arches:
|
|
|
|
return False
|
|
|
|
for value in [arch, "all", "noarch"]:
|
|
|
|
if value in arches:
|
|
|
|
return True
|
|
|
|
return False
|
2021-03-02 18:47:58 +00:00
|
|
|
|
|
|
|
|
|
|
|
def get_channel_new(channel):
|
|
|
|
""" Translate legacy channel names to the new ones. Legacy names are still
|
|
|
|
supported for compatibility with old branches (pmb#2015).
|
|
|
|
:param channel: name as read from pmaports.cfg or channels.cfg, like
|
|
|
|
"edge", "v21.03" etc., or potentially a legacy name
|
|
|
|
like "stable".
|
|
|
|
:returns: name in the new format, e.g. "edge" or "v21.03"
|
|
|
|
"""
|
|
|
|
legacy_cfg = pmb.config.pmaports_channels_legacy
|
|
|
|
if channel in legacy_cfg:
|
|
|
|
ret = legacy_cfg[channel]
|
|
|
|
logging.verbose(f"Legacy channel '{channel}' translated to '{ret}'")
|
|
|
|
return ret
|
|
|
|
return channel
|