~postmarketos/pmbootstrap-devel

This thread contains a patchset. You're looking at the original emails, but you may wish to use the patch review UI. Review patch
1

[PATCH pmbootstrap] pkg resolver: don't guess if pmaport was found

Details
Message ID
<20231121222457.2871-1-ollieparanoid@postmarketos.org>
DKIM signature
missing
Download raw message
Patch: +23 -19
If we found an APKBUILD already, with the exact name of the package we
are looking for, then don't also guess what other package could contain
the package as subpackage.

The guess was thrown away with the previous logic, but it caused
misleading verbose logs like:

  lomiri-history-service: guessed to be a subpackage of lomiri

Also this is slightly faster. While at it, tweak the related comments
to make this easier to understand.
---
 pmb/helpers/pmaports.py | 42 ++++++++++++++++++++++-------------------
 1 file changed, 23 insertions(+), 19 deletions(-)

diff --git a/pmb/helpers/pmaports.py b/pmb/helpers/pmaports.py
index 510ec4d0..24bb60f4 100644
--- a/pmb/helpers/pmaports.py
+++ b/pmb/helpers/pmaports.py
@@ -153,28 +153,32 @@ def find(args, package, must_exist=True):
        if "*" in package:
            raise RuntimeError("Invalid pkgname: " + package)

        # Search in packages
        # Try to find an APKBUILD with the exact pkgname we are looking for
        path = _find_apkbuilds(args).get(package)
        if path:
            ret = os.path.dirname(path)

        # Try to guess based on the subpackage name
        guess = guess_main(args, package)
        if guess:
            # ... but see if we were right
            if _find_package_in_apkbuild(package, f'{guess}/APKBUILD'):
                ret = guess

        # Search in subpackages and provides
        if not ret:
            for path_current in _find_apkbuilds(args).values():
                if _find_package_in_apkbuild(package, path_current):
                    ret = os.path.dirname(path_current)
                    break

        # Use the guess otherwise
        if not ret:
            ret = guess
        else:
            # No luck, take a guess what APKBUILD could have the package we are
            # looking for as subpackage
            guess = guess_main(args, package)
            if guess:
                # Parse the APKBUILD and verify if the guess was right
                if _find_package_in_apkbuild(package, f'{guess}/APKBUILD'):
                    ret = guess
                else:
                    # Otherwise parse all APKBUILDs (takes time!), is the
                    # package we are looking for a subpackage of any of those?
                    for path_current in _find_apkbuilds(args).values():
                        if _find_package_in_apkbuild(package, path_current):
                            ret = os.path.dirname(path_current)
                            break

                # If we still didn't find anything, as last resort: assume our
                # initial guess was right and the APKBUILD parser just didn't
                # find the subpackage in there because it is behind shell logic
                # that we don't parse.
                if not ret:
                    ret = guess

    # Crash when necessary
    if ret is None and must_exist:
-- 
2.41.0

[pmbootstrap/patches/.build.yml] build success

builds.sr.ht <builds@sr.ht>
Details
Message ID
<CX4ULPHF35WU.1F95HDKNRV2OB@cirno2>
In-Reply-To
<20231121222457.2871-1-ollieparanoid@postmarketos.org> (view parent)
DKIM signature
missing
Download raw message
pmbootstrap/patches/.build.yml: SUCCESS in 12m17s

[pkg resolver: don't guess if pmaport was found][0] from [Oliver Smith][1]

[0]: https://lists.sr.ht/~postmarketos/pmbootstrap-devel/patches/46885
[1]: ollieparanoid@postmarketos.org

✓ #1098367 SUCCESS pmbootstrap/patches/.build.yml https://builds.sr.ht/~postmarketos/job/1098367
Reply to thread Export thread (mbox)