[elbe-devel] [PATCH v3 3/6] schema: Allow xml files without a pkg-list
Benedikt Spranger
b.spranger at linutronix.de
Fri Nov 9 12:18:51 CET 2018
From: Manuel Traut <manut at linutronix.de>
E.g. for a container base image, i just want to have
an image with the contents of debootstrap. Therefore
no 'pkg-list' element is needed in XML.
However this is currently not allowed in the schema.
Also the code needs some fixups to support 'None'
pkg-list.
Signed-off-by: Manuel Traut <manut at linutronix.de>
Signed-off-by: Benedikt Spranger <b.spranger at linutronix.de>
---
elbepack/dump.py | 39 +++++++++++++++--------------
elbepack/elbexml.py | 2 ++
elbepack/makofiles/preferences.mako | 14 ++++++-----
schema/dbsfed.xsd | 2 +-
4 files changed, 31 insertions(+), 26 deletions(-)
diff --git a/elbepack/dump.py b/elbepack/dump.py
index 377a18e9..3464fdaa 100644
--- a/elbepack/dump.py
+++ b/elbepack/dump.py
@@ -85,27 +85,28 @@ def check_full_pkgs(pkgs, fullpkgs, errorname, cache):
errors = 0
- for p in pkgs:
- name = p.et.text
- nomulti_name = name.split(":")[0]
- if not cache.has_pkg(nomulti_name):
- elog.printo("- package %s does not exist" % nomulti_name)
- errors += 1
- continue
+ if pkgs:
+ for p in pkgs:
+ name = p.et.text
+ nomulti_name = name.split(":")[0]
+ if not cache.has_pkg(nomulti_name):
+ elog.printo("- package %s does not exist" % nomulti_name)
+ errors += 1
+ continue
- if not cache.is_installed(nomulti_name):
- elog.printo("- package %s is not installed" % nomulti_name)
- errors += 1
- continue
+ if not cache.is_installed(nomulti_name):
+ elog.printo("- package %s is not installed" % nomulti_name)
+ errors += 1
+ continue
- ver = p.et.get('version')
- pkg = cache.get_pkg(nomulti_name)
- if ver and (pkg.installed_version != ver):
- elog.printo(
- "- package %s version %s does not match installed version %s" %
- (name, ver, pkg.installed_version))
- errors += 1
- continue
+ ver = p.et.get('version')
+ pkg = cache.get_pkg(nomulti_name)
+ if ver and (pkg.installed_version != ver):
+ elog.printo(
+ "- package %s version %s does not match installed version %s" %
+ (name, ver, pkg.installed_version))
+ errors += 1
+ continue
if errors == 0:
elog.printo("No Errors found")
diff --git a/elbepack/elbexml.py b/elbepack/elbexml.py
index 4eb26b9f..ad78a925 100644
--- a/elbepack/elbexml.py
+++ b/elbepack/elbexml.py
@@ -257,6 +257,8 @@ class ElbeXML(object):
["Repository %s can not be validated" % r["url"]])
def get_target_packages(self):
+ if not self.xml.has("/target/pkg-list"):
+ return []
return [p.et.text for p in self.xml.node("/target/pkg-list")]
def add_target_package(self, pkg):
diff --git a/elbepack/makofiles/preferences.mako b/elbepack/makofiles/preferences.mako
index 2d85585a..565ca49e 100644
--- a/elbepack/makofiles/preferences.mako
+++ b/elbepack/makofiles/preferences.mako
@@ -25,17 +25,19 @@ Pin: origin ${porg['origin']}
Pin-Priority: ${porg['pin']}
% endfor
-% for n in pkgs:
-% if "pin" in n.et.attrib.keys():
+% if pkgs:
+% for n in pkgs:
+% if "pin" in n.et.attrib.keys():
Package: ${n.et.text}
Pin: release n=${n.et.attrib["pin"]}
Pin-Priority: 991
-% endif
-% if "version" in n.et.attrib.keys():
+% endif
+% if "version" in n.et.attrib.keys():
Package: ${n.et.text}
Pin: version ${n.et.attrib["version"]}
Pin-Priority: 1001
-% endif
-% endfor
+% endif
+% endfor
+% endif
diff --git a/schema/dbsfed.xsd b/schema/dbsfed.xsd
index 66a989b8..17aa6283 100644
--- a/schema/dbsfed.xsd
+++ b/schema/dbsfed.xsd
@@ -837,7 +837,7 @@
</documentation>
</annotation>
</element>
- <element name="pkg-list" type="rfs:pkg-list">
+ <element name="pkg-list" type="rfs:pkg-list" minOccurs="0" maxOccurs="1">
<annotation>
<documentation>
install the given packages into the rootfilesystem
--
2.19.1
More information about the elbe-devel
mailing list