[elbe-devel] [PATCH 1/2] elbepack: efilesystem: handle empty package list

Thomas Weißschuh thomas.weissschuh at linutronix.de
Tue Aug 20 08:36:39 CEST 2024


If target/pkg-list is not specified then xml.node() will return None
which is not iterable and lead to an error.
Use the helper xml.get_target_packages() which handles this gracefully.

Signed-off-by: Thomas Weißschuh <thomas.weissschuh at linutronix.de>
---
 elbepack/efilesystem.py | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/elbepack/efilesystem.py b/elbepack/efilesystem.py
index 3319ff2f8732..4ae1bbaca3f4 100644
--- a/elbepack/efilesystem.py
+++ b/elbepack/efilesystem.py
@@ -107,8 +107,7 @@ def extract_target(src, xml, dst, cache):
 
     # create filelists describing the content of the target rfs
     if xml.tgt.has('tighten') or xml.tgt.has('diet'):
-        pkglist = [n.et.text for n in xml.node(
-            'target/pkg-list') if n.tag == 'pkg']
+        pkglist = xml.get_target_packages()
         arch = xml.text('project/buildimage/arch', key='arch')
 
         if xml.tgt.has('diet'):
@@ -150,8 +149,7 @@ def extract_target(src, xml, dst, cache):
         pass
 
     if xml.tgt.has('setsel'):
-        pkglist = [n.et.text for n in xml.node(
-            'target/pkg-list') if n.tag == 'pkg']
+        pkglist = xml.get_target_packages()
         psel = 'var/cache/elbe/pkg-selections'
 
         with open(dst.fname(psel), 'w+') as f:

-- 
2.46.0



More information about the elbe-devel mailing list