[elbe-devel] [PATCH 1/3] elbepack: determine source packages without dpkg status file

Thomas Weißschuh thomas.weissschuh at linutronix.de
Tue Apr 16 15:19:05 CEST 2024


The apt cache is sufficient and additionally provides access to versions
not currently installed.
It also makes the logic easier.

Signed-off-by: Thomas Weißschuh <thomas.weissschuh at linutronix.de>
---
 elbepack/aptpkgutils.py | 33 +++++++++++++--------------------
 1 file changed, 13 insertions(+), 20 deletions(-)

diff --git a/elbepack/aptpkgutils.py b/elbepack/aptpkgutils.py
index 817fae4c4629..f403096cdc8e 100644
--- a/elbepack/aptpkgutils.py
+++ b/elbepack/aptpkgutils.py
@@ -158,26 +158,19 @@ def get_corresponding_source_packages(cache, pkg_lst=None):
 
     src_set = set()
 
-    with apt_pkg.TagFile('/var/lib/dpkg/status') as tagfile:
-        for section in tagfile:
-
-            pkg = section['Package']
-
-            if pkg not in pkg_lst:
-                continue
-
-            tmp = cache[pkg].installed or 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))
+    for pkg in pkg_lst:
+        version = cache[pkg].installed or cache[pkg.candidate]
+        src_set.add((version.source_name, version.source_version))
+
+        built_using = version.record.get('Built-Using')
+        if built_using is None:
+            continue
+
+        built_using_lst = 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)
 

-- 
2.44.0



More information about the elbe-devel mailing list