forked from Mirror/pmbootstrap
pmb.{config, helpers, install}: add _pmb_default support (MR 2301)
This commit is contained in:
parent
7a299b3fc4
commit
56a4329f4f
4 changed files with 12 additions and 2 deletions
|
@ -238,6 +238,9 @@ apkbuild_package_attributes = {
|
|||
# additional configuration options in "pmbootstrap init" that allow
|
||||
# selecting alternative providers for a virtual APK package.
|
||||
"_pmb_select": {"array": True},
|
||||
# postmarketos-base and UI meta-packages can define the default package
|
||||
# to select during "_pmb_select".
|
||||
"_pmb_default": {"array": True},
|
||||
}
|
||||
|
||||
# Variables in APKBUILD files that get parsed
|
||||
|
|
|
@ -281,7 +281,7 @@ def ask_for_provider_select(apkbuild, providers_cfg) -> None:
|
|||
providers. Updated with new providers after selection
|
||||
"""
|
||||
for select in apkbuild["_pmb_select"]:
|
||||
providers = pmb.helpers.pmaports.find_providers(select)
|
||||
providers = pmb.helpers.pmaports.find_providers(select, apkbuild["_pmb_default"])
|
||||
logging.info(f"Available providers for {select} ({len(providers)}):")
|
||||
|
||||
has_default = False
|
||||
|
|
|
@ -248,12 +248,13 @@ def get(pkgname, must_exist=True, subpackages=True, skip_extra_repos=False) -> d
|
|||
return get_with_path(pkgname, must_exist, subpackages, skip_extra_repos)[1]
|
||||
|
||||
|
||||
def find_providers(provide):
|
||||
def find_providers(provide, default):
|
||||
"""Search for providers of the specified (virtual) package in pmaports.
|
||||
|
||||
Note: Currently only providers from a single APKBUILD are returned.
|
||||
|
||||
:param provide: the (virtual) package to search providers for
|
||||
:param default: the _pmb_default to look through for defaults
|
||||
:returns: tuple list (pkgname, apkbuild_pkg) with providers, sorted by
|
||||
provider_priority. The provider with the highest priority
|
||||
(which would be selected by default) comes first.
|
||||
|
@ -266,6 +267,8 @@ def find_providers(provide):
|
|||
for provides in subpkg["provides"]:
|
||||
# Strip provides version (=$pkgver-r$pkgrel)
|
||||
if provides.split("=", 1)[0] == provide:
|
||||
if subpkgname in default:
|
||||
subpkg["provider_priority"] = 999
|
||||
providers[subpkgname] = subpkg
|
||||
|
||||
return sorted(providers.items(), reverse=True, key=lambda p: p[1].get("provider_priority", 0))
|
||||
|
|
|
@ -1168,6 +1168,10 @@ def get_selected_providers(args: PmbArgs, packages):
|
|||
if select in get_context().config.providers:
|
||||
ret += [get_context().config.providers[select]]
|
||||
logging.verbose(f"{package}: install selected_providers:" f" {', '.join(ret)}")
|
||||
else:
|
||||
for default in apkbuild["_pmb_default"]:
|
||||
if select == default[: default.rfind("-")]:
|
||||
ret += [default]
|
||||
# Also iterate through dependencies to collect any providers they have
|
||||
depends = apkbuild["depends"]
|
||||
if depends:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue