[elbe-devel] [PATCH 1/5] rpcaptcache: Add get_corresponding_source_packages

Torben Hohn torben.hohn at linutronix.de
Mon May 25 14:43:55 CEST 2020


On Tue, May 19, 2020 at 10:26:59PM -0400, Olivier Dion wrote:
> The method constructs a set of source packages from a list of binary
> packages.  This former includes the sources of the binaries, but also
> the built-using sources.
> 
> A list of unique tuples of the form (src_name, src_version) is
> returned.
> 
> Signed-off-by: Olivier Dion <dion at linutronix.de>
> ---
>  elbepack/rpcaptcache.py | 32 +++++++++++++++++++++++++++++++-
>  1 file changed, 31 insertions(+), 1 deletion(-)
> 
> diff --git a/elbepack/rpcaptcache.py b/elbepack/rpcaptcache.py
> index 5a1bb01a..14c3f654 100644
> --- a/elbepack/rpcaptcache.py
> +++ b/elbepack/rpcaptcache.py
> @@ -16,7 +16,7 @@ import time
>  from multiprocessing.util import Finalize
>  from multiprocessing.managers import BaseManager
>  
> -from apt_pkg import config, version_compare
> +from apt_pkg import config, version_compare, TagFile
>  from apt import Cache
>  
>  from elbepack.aptprogress import (ElbeAcquireProgress, ElbeInstallProgress,
> @@ -289,6 +289,36 @@ class RPCAPTCache(InChRootObject):
>                  self.cache[p]) for p in sorted(
>                  self.cache.keys()) if pkgname in p.lower()]
>  
> +    def get_corresponding_source_packages(self, pkg_lst=None):
> +
> +        if pkg_lst is None:
> +            pkg_lst = {p.name for p in self.cache if p.is_installed}

why {} ? this does not seem to be a dict.

rest looks good... use [] and:

Reviewed-by: Torben Hohn <torben.hohn at linutronix.de>

> +
> +        src_set = set()
> +
> +        with TagFile('/var/lib/dpkg/status') as tagfile:
> +            for section in tagfile:
> +
> +                pkg = section['Package']
> +
> +                if pkg not in pkg_lst:
> +                    continue
> +
> +                tmp = self.cache[pkg].installed or self.cache[pkg].candidate
> +
> +                src_set.add((tmp.source_name, tmp.source_version))
> +
> +                if "Built-Using" not in section:
> +                    continue
> +
> +                built_using_lst = section["Built-Using"].split(', ')
> +                for built_using in built_using_lst:
> +                    name, version = built_using.split(' ', 1)
> +                    version = version.strip('(= )')
> +                    src_set.add((name, version))
> +
> +        return list(src_set)
> +
>      def compare_versions(self, ver1, ver2):
>          return version_compare(ver1, ver2)
>  
> -- 
> 2.26.2
> 
> 
> _______________________________________________
> elbe-devel mailing list
> elbe-devel at linutronix.de
> https://lists.linutronix.de/mailman/listinfo/elbe-devel

-- 
Torben Hohn
Linutronix GmbH | Bahnhofstrasse 3 | D-88690 Uhldingen-Mühlhofen
Phone: +49 7556 25 999 18; Fax.: +49 7556 25 999 99

Hinweise zum Datenschutz finden Sie hier (Informations on data privacy 
can be found here): https://linutronix.de/kontakt/Datenschutz.php

Linutronix GmbH | Firmensitz (Registered Office): Uhldingen-Mühlhofen | 
Registergericht (Registration Court): Amtsgericht Freiburg i.Br., HRB700 
806 | Geschäftsführer (Managing Directors): Heinz Egger, Thomas Gleixner



More information about the elbe-devel mailing list