[elbe-devel] [PATCH v3] virtapt/lookup_uri: handle 'provides'

Volker Haspel volker.haspel at linutronix.de
Wed Aug 15 13:47:45 CEST 2018


On Wed, 15 Aug 2018 12:41:32 +0200
Manuel Traut <manut at linutronix.de> wrote:

> If going through the dependencies of a package 'provides' might
> be used instead of a real package name.  If get_uri is used with
> incl_deps=True lookup_uri can be called with a 'provides'
> instead of a package name.
> 
> Extend lookup_uri with a loop that iterates over all packages
> in the cache and check their 'provides'  if the package name
> can't be found in the cache. If a 'provides' matches use the
> according package to return its uri.
> 
> Signed-off-by: Manuel Traut <manut at linutronix.de>

Reviewed-by: Volker Haspel <volker.haspel at linutronix.de>

> ---
> 
> changes since v1:
>   * none
> 
> changes since v2:
>   * added comment about ignored package priorities
> 
>  elbepack/virtapt.py | 55 ++++++++++++++++++++++++++++++++++-----------
>  1 file changed, 42 insertions(+), 13 deletions(-)
> 
> diff --git a/elbepack/virtapt.py b/elbepack/virtapt.py
> index deac0e8a..59fb93ba 100644
> --- a/elbepack/virtapt.py
> +++ b/elbepack/virtapt.py
> @@ -29,11 +29,27 @@ def getdeps(pkg):
>              yield d.target_pkg.name
>  
>  
> +# target_pkg is either a 'package name' or a 'provides'
> +#
> +# ATTENTION: for provides pinning and priorities for package selection are
> +#            ignored. This should be safe for now, because the code is only
> +#            used for downloading 'elbe-bootstrap' and generating the SDKs
> +#            host-sysroot. For generating host-sysroots there is no posibility
> +#            to modify package priorities via elbe-xml.
>  def lookup_uri(v, d, target_pkg):
> -
> -    pkg = v.cache[target_pkg]
> -
> -    c = d.get_candidate_ver(pkg)
> +    try:
> +        pkg = v.cache[target_pkg]
> +        c = d.get_candidate_ver(pkg)
> +    except KeyError:
> +        pkg = None
> +        c = None
> +
> +    if not c:
> +        for pkg in v.cache.packages:
> +            for x in pkg.provides_list:
> +                if target_pkg == x[0]:
> +                    return lookup_uri(v, d, x[2].parent_pkg.name)
> +        return "", "", ""
>  
>      x = v.source.find_index(c.file_list[0][0])
>  
> @@ -226,15 +242,28 @@ class VirtApt:
>          togo = [target_pkg]
>          while len(togo):
>              pp = togo.pop()
> -            pkg= self.cache[pp]
> -            c = d.get_candidate_ver(pkg)
> -            for p in getdeps(c):
> -                if len([y for y in deps if y[0] == p]):
> -                    continue
> -                if p != target_pkg and p == pp:
> -                    continue
> -                deps.append(lookup_uri(self, d, p))
> -                togo.append(p)
> +            try:
> +                pkg= self.cache[pp]
> +                c = d.get_candidate_ver(pkg)
> +            except KeyError:
> +                pkg = None
> +                c = None
> +            if not c:
> +                for p in self.cache.packages:
> +                    for x in p.provides_list:
> +                        if pp == x[0]:
> +                            pkg = self.cache[x[2].parent_pkg.name]
> +                            c = d.get_candidate_ver(pkg)
> +            if not c:
> +                print("couldnt get candidate: %s" % pkg)
> +            else:
> +                for p in getdeps(c):
> +                    if len([y for y in deps if y[0] == p]):
> +                        continue
> +                    if p != target_pkg and p == pp:
> +                        continue
> +                    deps.append(lookup_uri(self, d, p))
> +                    togo.append(p)
>  
>          return deps
>  



More information about the elbe-devel mailing list