[elbe-devel] [PATCH] pbuilderaction: call elbe preprocess before submitting xmlfile in create

Manuel Traut manut at linutronix.de
Fri Oct 12 16:41:20 CEST 2018


Hi Torben,

On Fri, Sep 07, 2018 at 09:17:38AM +0200, Torben Hohn wrote:
> archivedir feature is handled in elbe preprocess. When an xml
> with archivedir is submitted via "elbe pbuilder create --xmlfile=a.xml"
> preprocess is not called, and validation inside the initvm fails.
> 
> call "elbe preprocess" and submit the tmpfile, that is produced.

To be really useful, the --variant argument needs to be supported by pbuilder
(and also from the initvm subcommand, that is not the case atm).

This is code-duplication from elbepack/initvmaction.py.

Please don't introduce new duplicated code and support the --variant parameter
for both commands.

Thanks,

  Manu

> Fixes: #177
> 
> Signed-off-by: Torben Hohn <torben.hohn at linutronix.de>
> ---
>  elbepack/pbuilderaction.py | 14 +++++++++++++-
>  1 file changed, 13 insertions(+), 1 deletion(-)
> 
> diff --git a/elbepack/pbuilderaction.py b/elbepack/pbuilderaction.py
> index a161a7bf..2f9948fd 100644
> --- a/elbepack/pbuilderaction.py
> +++ b/elbepack/pbuilderaction.py
> @@ -9,6 +9,8 @@ from __future__ import print_function
>  import sys
>  import os
>  
> +from tempfile import NamedTemporaryFile
> +
>  from elbepack.directories import elbe_exe
>  from elbepack.shellhelper import CommandError, system, command_out_stderr
>  from elbepack.filesystem import TmpdirFilesystem
> @@ -68,6 +70,16 @@ class CreateAction(PBuilderAction):
>      def execute(self, opt, _args):
>  
>          if opt.xmlfile:
> +            outxml = NamedTemporaryFile(prefix='elbe', suffix='xml')
> +            cmd = '%s preprocess -o %s %s' % (elbe_exe, outxml.name, opt.xmlfile)
> +            ret, _, err = command_out_stderr(cmd)
> +            if ret != 0:
> +                print("elbe preprocess failed.", file=sys.stderr)
> +                print(err, file=sys.stderr)
> +                print("Giving up", file=sys.stderr)
> +                sys.exit(20)
> +            xmlfile = outxml.name
> +
>              ret, prjdir, err = command_out_stderr(
>                  '%s control create_project' % (elbe_exe))
>              if ret != 0:
> @@ -79,7 +91,7 @@ class CreateAction(PBuilderAction):
>              prjdir = prjdir.strip()
>              ret, _, err = command_out_stderr(
>                  '%s control set_xml "%s" "%s"' %
> -                (elbe_exe, prjdir, opt.xmlfile))
> +                (elbe_exe, prjdir, xmlfile))
>  
>              if ret != 0:
>                  print("elbe control set_xml failed.", file=sys.stderr)
> -- 
> 2.11.0
> 
> 
> _______________________________________________
> 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