[elbe-devel] [PATCH] efilesystem: Handle missing pkg-list node
Olivier Dion
dion at linutronix.de
Tue Jul 21 02:34:23 CEST 2020
Check if pkg-list node exists. If it doesn't the list of package is
empty and emit a warning.
Signed-off-by: Olivier Dion <dion at linutronix.de>
---
elbepack/efilesystem.py | 25 +++++++++++++++++++++----
1 file changed, 21 insertions(+), 4 deletions(-)
diff --git a/elbepack/efilesystem.py b/elbepack/efilesystem.py
index 40865c28..216f17f5 100644
--- a/elbepack/efilesystem.py
+++ b/elbepack/efilesystem.py
@@ -95,11 +95,20 @@ def extract_target(src, xml, dst, cache):
# pylint: disable=too-many-locals
# pylint: disable=too-many-branches
+ # pylint: disable=too-many-statements
# 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']
+
+ if xml.has("target/pkg-list"):
+ pkglist = [n.et.text
+ for n
+ in xml.node('target/pkg-list')
+ if n.tag == 'pkg']
+ else:
+ pkglist = []
+ logging.warning("No <pkg-list> for project with <tighten> or <diet>")
+
arch = xml.text("project/buildimage/arch", key="arch")
if xml.tgt.has("diet"):
@@ -145,8 +154,16 @@ 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']
+
+ if xml.has("target/pkg-list"):
+ pkglist = [n.et.text
+ for n
+ in xml.node('target/pkg-list')
+ if n.tag == 'pkg']
+ else:
+ pkglist = []
+ logging.warning("No <pkglist> for project with <setsel>")
+
psel = 'var/cache/elbe/pkg-selections'
with open(dst.fname(psel), 'w+') as f:
--
2.27.0
More information about the elbe-devel
mailing list