[elbe-devel] [PATCH v2 14/22] virtapt: add apt_pkg.DepCache member and mathods using it

Bastian Germann bage at linutronix.de
Tue Jul 2 17:08:27 CEST 2019


Typo in the title (mathods -> methods)

> make virtapt more similar to how RPCAptCache works.
> 
> the only user "elbe check_updates" has the DepCache as private variable
> currently. But, for downloading of packages, the DepCache is also needed.
> 
> Create self.depcache and read the pinning file, which is already generated
> by the VirtApt constructor.
> Then add methods, taking pkgnames as parameters.
> 
> Signed-off-by: Torben Hohn <torben.hohn at linutronix.de>

With this applied
Reviewed-by: Bastian Germann <bage at linutronix.de>

> ---
>  elbepack/virtapt.py | 18 ++++++++++++++++++
>  1 file changed, 18 insertions(+)
> 
> diff --git a/elbepack/virtapt.py b/elbepack/virtapt.py
> index ae7fe94fc..71d7d54c0 100644
> --- a/elbepack/virtapt.py
> +++ b/elbepack/virtapt.py
> @@ -140,6 +140,13 @@ class VirtApt(object):
>          except BaseException as e:
>              print(e)
>  
> +        try:
> +            self.depcache = apt_pkg.DepCache(self.cache)
> +            prefs_name = self.basefs.fname("/etc/apt/preferences")
> +            self.depcache.read_pinfile(prefs_name)
> +        except BaseException as e:
> +            print(e)
> +
>      def add_key(self, key):
>          cmd = 'echo "%s" > %s' % (key, self.basefs.fname("tmp/key.pub"))
>          clean = 'rm -f %s' % self.basefs.fname("tmp/key.pub")
> @@ -198,6 +205,17 @@ class VirtApt(object):
>                     key,
>                     ring_path + '.d'))
>  
> +    def mark_install(self, pkgname):
> +        self.depcache.mark_install(self.cache[pkgname])
> +
> +    def marked_install(self, pkgname):
> +        return self.depcache.marked_install(self.cache[pkgname])
> +
> +    def get_candidate_ver(self, pkgname):
> +        return self.depcache.get_candidate_ver(self.cache[pkgname]).ver_str
> +
> +    def has_pkg(self, pkgname):
> +        return pkgname in self.cache
>  
>      def get_uri(self, target_pkg, incl_deps=False):
>  
> 



More information about the elbe-devel mailing list