[elbe-devel] [PATCH 2/2] elbepack: aptpkgutils: replace handle-rolled Built-Using parsing

Thomas Weißschuh thomas.weissschuh at linutronix.de
Wed Apr 24 10:29:50 CEST 2024


python-apt provides helpers to parse this syntax, use it.

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

diff --git a/elbepack/aptpkgutils.py b/elbepack/aptpkgutils.py
index 567e3f288364..fdfecec36958 100644
--- a/elbepack/aptpkgutils.py
+++ b/elbepack/aptpkgutils.py
@@ -163,11 +163,13 @@ def parse_built_using(value):
     if value is None:
         return
 
-    built_using_lst = value.split(', ')
-    for built_using in built_using_lst:
-        name, version = built_using.split(' ', 1)
-        version = version.strip('(= )')
-        yield name, version
+    for group in apt_pkg.parse_src_depends(value):
+        assert len(group) == 1
+
+        package, version, operation = group[0]
+        assert operation == '='
+
+        yield package, version
 
 
 def get_corresponding_source_packages(cache, pkg_lst=None):

-- 
2.44.0



More information about the elbe-devel mailing list