[elbe-devel] [PATCH 2/5] virtapt: add get_source_pkg() method

Torben Hohn torben.hohn at linutronix.de
Mon Jul 8 16:38:13 CEST 2019


retrieve the source package name. When the binary package and source
package name are identical, the source_pkg record is None.

thats why "r.source_pkg or pkg.name" is returned.

Signed-off-by: Torben Hohn <torben.hohn at linutronix.de>
---
 elbepack/virtapt.py | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/elbepack/virtapt.py b/elbepack/virtapt.py
index 58f1efbbe..e4600c84f 100644
--- a/elbepack/virtapt.py
+++ b/elbepack/virtapt.py
@@ -243,6 +243,15 @@ class VirtApt(object):
                                   destdir=self.basefs.fname('/cache/archives'))
         self.downloads[pkgname] = acq
 
+    def get_source_pkg(self, pkgname):
+        pkg = self.cache[pkgname]
+        c = self.depcache.get_candidate_ver(pkg)
+
+        r = apt_pkg.PackageRecords(self.cache)
+        r.lookup(c.file_list[0])
+
+        return r.source_pkg or pkg.name
+
     def do_downloads(self):
         res = self.acquire.run()
         if res != 0:
-- 
2.11.0




More information about the elbe-devel mailing list