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

Torben Hohn torben.hohn at linutronix.de
Mon Oct 15 09:05:32 CEST 2018


On Fri, Oct 12, 2018 at 04:41:20PM +0200, Manuel Traut wrote:
> 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).

ACK

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

i dont how to deduplicate this.
the outxml is a NamedTemporaryFile -> has to reside in this block.
the error case calls sys.exit(20)  -> should not sit in a separate
                                      module.

this leaves me with 2 lines, that could be deduplicated.
does not make much sense.

mmm... ok. got it... it can be done with __enter__ and __exit__


> > +            cmd = '%s preprocess -o %s %s' % (elbe_exe, outxml.name, opt.xmlfile)
> > +            ret, _, err = command_out_stderr(cmd)
                                     

> 
> 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
> 
> _______________________________________________
> elbe-devel mailing list
> elbe-devel at linutronix.de
> https://lists.linutronix.de/mailman/listinfo/elbe-devel

-- 
Torben Hohn
Linutronix GmbH | Bahnhofstrasse 3 | D-88690 Uhldingen-Mühlhofen
Phone: +49 7556 25 999 18; Fax.: +49 7556 25 999 99

Hinweise zum Datenschutz finden Sie hier (Informations on data privacy 
can be found here): https://linutronix.de/kontakt/Datenschutz.php

Linutronix GmbH | Firmensitz (Registered Office): Uhldingen-Mühlhofen | 
Registergericht (Registration Court): Amtsgericht Freiburg i.Br., HRB700 
806 | Geschäftsführer (Managing Directors): Heinz Egger, Thomas Gleixner
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 488 bytes
Desc: not available
URL: <http://lists.linutronix.de/pipermail/elbe-devel/attachments/20181015/6c72e099/attachment.sig>


More information about the elbe-devel mailing list