forked from Mirror/pmbootstrap
pmb.config.init: fix perf regression when selecting "none" UI (MR 1913)
The ui-extras questions will attempt to find a postmarketos-ui-<ui> package in pmaports. If the package does not exist as "root" APKBUILD it currently attempts to parse all APKBUILDs in case it is somewhere defined as a subpackage. This is really slow (up to 2-3 seconds), which feels weird during "pmbootstrap init". For the UI packages we specifically look for the root UI package, not the subpackage, so let's skip searching for subpackages in this case. This makes selecting the "none" UI nice and fast again.
This commit is contained in:
parent
87f81de052
commit
add39d1a57
2 changed files with 16 additions and 5 deletions
|
@ -90,7 +90,8 @@ def ask_for_ui(args):
|
||||||
|
|
||||||
|
|
||||||
def ask_for_ui_extras(args, ui):
|
def ask_for_ui_extras(args, ui):
|
||||||
apkbuild = pmb.helpers.pmaports.get(args, "postmarketos-ui-" + ui, must_exist=False)
|
apkbuild = pmb.helpers.pmaports.get(args, "postmarketos-ui-" + ui,
|
||||||
|
subpackages=False, must_exist=False)
|
||||||
if not apkbuild:
|
if not apkbuild:
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
|
|
@ -163,13 +163,15 @@ def find(args, package, must_exist=True):
|
||||||
return ret
|
return ret
|
||||||
|
|
||||||
|
|
||||||
def get(args, pkgname, must_exist=True):
|
def get(args, pkgname, must_exist=True, subpackages=True):
|
||||||
""" Find and parse an APKBUILD file.
|
""" Find and parse an APKBUILD file.
|
||||||
Run 'pmbootstrap apkbuild_parse hello-world' for a full output example.
|
Run 'pmbootstrap apkbuild_parse hello-world' for a full output example.
|
||||||
Relevant variables are defined in pmb.config.apkbuild_attributes.
|
Relevant variables are defined in pmb.config.apkbuild_attributes.
|
||||||
|
|
||||||
:param pkgname: the package name to find
|
:param pkgname: the package name to find
|
||||||
:param must_exist: raise an exception when it can't be found
|
:param must_exist: raise an exception when it can't be found
|
||||||
|
:param subpackages: also search for subpackages with the specified names
|
||||||
|
(slow! might need to parse all APKBUILDs to find it)
|
||||||
:returns: relevant variables from the APKBUILD as dictionary, e.g.:
|
:returns: relevant variables from the APKBUILD as dictionary, e.g.:
|
||||||
{ "pkgname": "hello-world",
|
{ "pkgname": "hello-world",
|
||||||
"arch": ["all"],
|
"arch": ["all"],
|
||||||
|
@ -178,9 +180,17 @@ def get(args, pkgname, must_exist=True):
|
||||||
"options": [],
|
"options": [],
|
||||||
... }
|
... }
|
||||||
"""
|
"""
|
||||||
aport = find(args, pkgname, must_exist)
|
if subpackages:
|
||||||
if aport:
|
aport = find(args, pkgname, must_exist)
|
||||||
return pmb.parse.apkbuild(args, aport + "/APKBUILD")
|
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:
|
||||||
|
raise RuntimeError(f"Could not find APKBUILD for package: {pkgname}")
|
||||||
|
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue