Package: xen Version: 4.0.1-1 Tags: patch Attached is a patch which I already sent upstream that replaces the python-xml (pyxml/xmlproc) based validation code with validation code based on python-lxml. The obvious gain from this is that XenAPI works on Squeeze and Sid, where python-xml is not available anymore. Additionally this patch adds a dependency on python-lxml for the xen-utils-4.0 package.
Regards, Stephan
diff -Nru a/debian/changelog b/debian/changelog --- a/debian/changelog 2010-09-03 17:16:04.000000000 +0200 +++ b/debian/changelog 2010-10-08 12:56:41.165295001 +0200 @@ -1,3 +1,11 @@ +xen (4.0.1-2~sp0) unstable; urgency=low + + * Added patch that replaces code requiring python-xml with code + requiring python-lxml. + * Updated debian/control to reflect change of dependencies. + + -- Stephan Peijnik <s...@anexia.at> Fri, 08 Oct 2010 12:56:27 +0200 + xen (4.0.1-1) unstable; urgency=low * New upstream release. diff -Nru a/debian/control b/debian/control --- a/debian/control 2010-09-03 17:18:05.000000000 +0200 +++ b/debian/control 2010-10-08 12:55:19.577295002 +0200 @@ -43,7 +43,7 @@ Package: xen-utils-4.0 Architecture: amd64 i386 Provides: xen-utils -Depends: ${shlibs:Depends}, ${misc:Depends}, ${python:Depends}, xen-utils-common (>= 3.4.2-4), iproute, udev (>> 0.060) +Depends: ${shlibs:Depends}, ${misc:Depends}, ${python:Depends}, xen-utils-common (>= 3.4.2-4), iproute, udev (>> 0.060), python-lxml Recommends: bridge-utils, libc6-xen [i386], xen-hypervisor-4.0 Suggests: xen-docs-4.0 Description: XEN administrative tools diff -Nru a/debian/patches/series b/debian/patches/series --- a/debian/patches/series 2010-08-17 23:14:56.000000000 +0200 +++ b/debian/patches/series 2010-10-08 13:00:35.321295001 +0200 @@ -47,3 +47,4 @@ tools-xenmon-install.diff tools-python-shebang.diff +tools-python-replace-xmlproc-with-lxml.patch diff -Nru a/debian/patches/tools-python-replace-xmlproc-with-lxml.patch b/debian/patches/tools-python-replace-xmlproc-with-lxml.patch --- a/debian/patches/tools-python-replace-xmlproc-with-lxml.patch 1970-01-01 01:00:00.000000000 +0100 +++ b/debian/patches/tools-python-replace-xmlproc-with-lxml.patch 2010-10-08 13:04:39.057295002 +0200 @@ -0,0 +1,133 @@ +--- a/tools/python/xen/xm/xenapi_create.py 2010-10-08 13:01:09.265295002 +0200 ++++ b/tools/python/xen/xm/xenapi_create.py 2010-10-08 13:01:35.557295002 +0200 +@@ -13,13 +13,15 @@ + # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + #============================================================================ + # Copyright (C) 2007 Tom Wilkie <tom.wil...@gmail.com> ++# Copyright (C) 2010 ANEXIA Internetdienstleistungs GmbH ++# Author: Stephan Peijnik <s...@anexia.at> + #============================================================================ + """Domain creation using new XenAPI + """ + + from xen.xm.main import server, get_default_SR + from xml.dom.minidom import parse, getDOMImplementation +-from xml.parsers.xmlproc import xmlproc, xmlval, xmldtd ++from lxml import etree + from xen.xend import sxp + from xen.xend.XendAPIConstants import XEN_API_ON_NORMAL_EXIT, \ + XEN_API_ON_CRASH_BEHAVIOUR +@@ -34,6 +36,7 @@ + from os.path import join + import traceback + import re ++import warnings # Used by lxml-based validator + + def log(_, msg): + #print "> " + msg +@@ -117,62 +120,58 @@ + Use this if possible as it gives nice + error messages + """ +- dtd = xmldtd.load_dtd(self.dtd) +- parser = xmlproc.XMLProcessor() +- parser.set_application(xmlval.ValidatingApp(dtd, parser)) +- parser.dtd = dtd +- parser.ent = dtd +- parser.parse_resource(file) +- ++ try: ++ dtd = etree.DTD(open(self.dtd, 'r')) ++ except IOError: ++ # The old code did neither raise an exception here, nor ++ # did it report an error. For now we issue a warning. ++ # TODO: How to handle a missing dtd file? ++ # --sp ++ warnings.warn('DTD file %s not found.' % (self.dtd), ++ UserWarning) ++ return ++ ++ tree = etree.parse(file) ++ root = tree.getroot() ++ if not dtd.validate(root): ++ self.handle_dtd_errors(dtd) ++ + def check_dom_against_dtd(self, dom): + """ + Check DOM again DTD. + Doesn't give as nice error messages. + (no location info) + """ +- dtd = xmldtd.load_dtd(self.dtd) +- app = xmlval.ValidatingApp(dtd, self) +- app.set_locator(self) +- self.dom2sax(dom, app) +- +- # Get errors back from ValidatingApp +- def report_error(self, number, args=None): +- self.errors = xmlproc.errors.english + try: +- msg = self.errors[number] +- if args != None: +- msg = msg % args +- except KeyError: +- msg = self.errors[4002] % number # Unknown err msg :-) +- print msg ++ dtd = etree.DTD(open(self.dtd, 'r')) ++ except IOError: ++ # The old code did neither raise an exception here, nor ++ # did it report an error. For now we issue a warning. ++ # TODO: How to handle a missing dtd file? ++ # --sp ++ warnings.warn('DTD file %s not found.' % (self.dtd), ++ UserWarning) ++ return ++ ++ # XXX: This may be a bit slow. Maybe we should use another way ++ # of getting an etree root element from the minidom DOM tree... ++ # -- sp ++ root = etree.XML(dom.toxml()) ++ if not dtd.validate(root): ++ self.handle_dtd_errors(dtd) ++ ++ # Do the same that was done in report_error before. This is directly ++ # called by check_dtd and check_dom_against_dtd. ++ # We are using sys.stderr instead of print though (python3k clean). ++ def handle_dtd_errors(self, dtd): ++ # XXX: Do we really want to bail out here? ++ # -- sp ++ for err in dtd.error_log: ++ err_str = 'ERROR: %s\n' % (str(err),) ++ sys.stderr.write(err_str) ++ sys.stderr.flush() + sys.exit(-1) + +- # Here for compatibility with ValidatingApp +- def get_line(self): +- return -1 +- +- def get_column(self): +- return -1 +- +- def dom2sax(self, dom, app): +- """ +- Take a dom tree and tarverse it, +- issuing SAX calls to app. +- """ +- for child in dom.childNodes: +- if child.nodeType == child.TEXT_NODE: +- data = child.nodeValue +- app.handle_data(data, 0, len(data)) +- else: +- app.handle_start_tag( +- child.nodeName, +- self.attrs_to_dict(child.attributes)) +- self.dom2sax(child, app) +- app.handle_end_tag(child.nodeName) +- +- def attrs_to_dict(self, attrs): +- return dict(attrs.items()) +- + # + # Checks which cannot be done with dtd + #