[elbe-devel] ELBE releases/v2.1: Issue with elbe show and elbe validate command

Manuel Traut manuel.traut at linutronix.de
Wed Aug 23 17:30:52 CEST 2017


Hi Rüdiger,

thanks for your feedback!

> I have detected, that the commands "elbe show" and "elbe validate" will fail if the Elbe XML file contains XInclude statements. I have verified this behavior also with the example xml -files x86_32-pc-hdimg-with-include-development.xml and x86_32-pc-hdimg-with-include-production.xml. I have found that, in contrast to the command initvm, no preprocess action for expanding the xinclude statements takes place with the commands "elbe show" and "elbe validate". After I have added the appropriate code, the commands work as expected. I have attached the patch below.

only the high-level command 'initvm' calls 'elbe preprocess' if needed. For
all other commands the user needs to give a 'valid' XML to elbe. This can be
done by calling 'elbe preprocess' and give the output XML to e.g. 'elbe show'.
We designed this in mind to extend the 'preprocess' command with additional
features, e.g. automatically exchanging the archive.

So the behaviour of 'elbe validate' is correct. However it doesn't give a hint
to the correct workflow. This should be improved!

Regards,

  Manuuel

> Best regards
> 
> Rüdiger Fichter
> 
> >From 65ceed005193dfc0d670908a63639b1b422c4ea4 Mon Sep 17 00:00:00 2001
> From: Ruediger Fichter <ruediger.fichter at emtrion.de>
> Date: Wed, 23 Aug 2017 12:53:10 +0200
> Subject: [PATCH] BugFix: elbe-show and elbe-validates failed if the elbe xml
>  contains xinclude nodes. This is fixed now.
> 
> ---
>  elbepack/commands/show.py | 12 +++++++++++-
>  elbepack/validate.py      | 12 ++++++++++++
>  2 files changed, 23 insertions(+), 1 deletion(-)
> 
> diff --git a/elbepack/commands/show.py b/elbepack/commands/show.py
> index 1a02155b..9d27419f 100644
> --- a/elbepack/commands/show.py
> +++ b/elbepack/commands/show.py
> @@ -25,6 +25,11 @@ from elbepack.validate import validate_xml
> 
>  from optparse import OptionParser
> 
> +from elbepack.directories import elbe_exe
> +from elbepack.shellhelper import CommandError, system, command_out_stderr
> +
> +from tempfile import NamedTemporaryFile
> +
>  def run_command( argv ):
>      oparser = OptionParser( usage="usage: %prog show [options] <filename>" )
> 
> @@ -57,7 +62,12 @@ def run_command( argv ):
>                      print i
>                  sys.exit(20)
> 
> -        xml = etree( args[0] )
> +        outxml = NamedTemporaryFile(prefix='elbe', suffix='xml')
> +        cmd = '%s preprocess -o %s %s' % (elbe_exe, outxml.name, args[0])
> +        ret, msg, err = command_out_stderr (cmd)
> +        if ret != 0:
> +            return ["elbe preprocess failed.\n" +str(sys.exc_info()[1])]
> +        xml = etree( outxml.name )
>      except:
>          print "Unable to open xml File. Bailing out"
>          sys.exit(20)
> diff --git a/elbepack/validate.py b/elbepack/validate.py
> index 7574cb91..277a04be 100644
> --- a/elbepack/validate.py
> +++ b/elbepack/validate.py
> @@ -20,6 +20,11 @@ import sys
>  from lxml import etree
>  from lxml.etree import XMLParser,parse
> 
> +from elbepack.directories import elbe_exe
> +from elbepack.shellhelper import CommandError, system, command_out_stderr
> +
> +from tempfile import NamedTemporaryFile
> +
>  def validate_xml(fname):
>      schema_file = "https://www.linutronix.de/projects/Elbe/dbsfed.xsd"
>      parser = XMLParser(huge_tree=True)
> @@ -27,6 +32,13 @@ def validate_xml(fname):
>      schema = etree.XMLSchema(schema_tree)
> 
>      try:
> +        outxml = NamedTemporaryFile(prefix='elbe', suffix='xml')
> +        cmd = '%s preprocess -o %s %s' % (elbe_exe, outxml.name, fname)
> +        ret, msg, err = command_out_stderr (cmd)
> +        if ret != 0:
> +            return ["elbe preprocess failed.\n" +str(sys.exc_info()[1])]
> +        fname = outxml.name
> +
>          xml = parse(fname,parser=parser)
> 
>          if schema.validate(xml):
> --
> 2.11.0
> 
> 
> emtrion GmbH
> Kreativpark - Alter Schlachthof 45
> 76131 Karlsruhe
> GERMANY
> http://www.emtrion.de
> _______________________________________
> 
> Amtsgericht Mannheim
> HRB 110 300
> Geschäftsführer: Dieter Baur, Ramona Maurer
> _______________________________________
> 
> _______________________________________________
> elbe-devel mailing list
> elbe-devel at linutronix.de
> https://lists.linutronix.de/mailman/listinfo/elbe-devel



More information about the elbe-devel mailing list