[elbe-devel] [PATCH v2 10/28] Add logging to stdout for command chroot

Torben Hohn torben.hohn at linutronix.de
Wed Jun 26 15:09:13 CEST 2019


On Fri, Jun 21, 2019 at 07:40:02PM +0200, dion at linutronix.de wrote:
> From: Olivier Dion <dion at linutronix.de>
> 
> Signed-off-by: Olivier Dion <dion at linutronix.de>

this will conflict with the system PQ,
gonna review after rebase

> ---
>  elbepack/commands/chroot.py | 56 +++++++++++++++++++++++----------------------
>  1 file changed, 29 insertions(+), 27 deletions(-)
> 
> diff --git a/elbepack/commands/chroot.py b/elbepack/commands/chroot.py
> index 7529fcf7..3fb7e812 100644
> --- a/elbepack/commands/chroot.py
> +++ b/elbepack/commands/chroot.py
> @@ -14,6 +14,7 @@ import os
>  
>  from elbepack.elbeproject import ElbeProject
>  from elbepack.elbexml import ValidationError, ValidationMode
> +from elbepack.log import elbe_logging
>  
>  
>  def run_command(argv):
> @@ -35,34 +36,35 @@ def run_command(argv):
>          oparser.print_help()
>          sys.exit(20)
>  
> -    try:
> -        project = ElbeProject(
> -            args[0],
> -            override_buildtype=opt.buildtype,
> -            skip_validate=opt.skip_validation,
> -            url_validation=ValidationMode.NO_CHECK)
> -    except ValidationError as e:
> -        print(str(e))
> -        print("xml validation failed. Bailing out")
> -        sys.exit(20)
> +    with elbe_logging(stdout=True):
> +        try:
> +            project = ElbeProject(
> +                args[0],
> +                override_buildtype=opt.buildtype,
> +                skip_validate=opt.skip_validation,
> +                url_validation=ValidationMode.NO_CHECK)
> +        except ValidationError as e:
> +            print(str(e))
> +            print("xml validation failed. Bailing out")
> +            sys.exit(20)
>  
> -    os.environ["LANG"] = "C"
> -    os.environ["LANGUAGE"] = "C"
> -    os.environ["LC_ALL"] = "C"
> -    # TODO: howto set env in chroot?
> -    os.environ["PS1"] = project.xml.text('project/name') + ': \w\$'
> +        os.environ["LANG"] = "C"
> +        os.environ["LANGUAGE"] = "C"
> +        os.environ["LC_ALL"] = "C"
> +        # TODO: howto set env in chroot?
> +        os.environ["PS1"] = project.xml.text('project/name') + ': \w\$'
>  
> -    cmd = "/bin/bash"
> +        cmd = "/bin/bash"
>  
> -    if len(args) > 1:
> -        cmd = ""
> -        cmd2 = args[1:]
> -        for c in cmd2:
> -            cmd += (c + " ")
> +        if len(args) > 1:
> +            cmd = ""
> +            cmd2 = args[1:]
> +            for c in cmd2:
> +                cmd += (c + " ")
>  
> -    if opt.target:
> -        with project.targetfs:
> -            os.system("/usr/sbin/chroot %s %s" % (project.targetpath, cmd))
> -    else:
> -        with project.buildenv:
> -            os.system("/usr/sbin/chroot %s %s" % (project.chrootpath, cmd))
> +        if opt.target:
> +            with project.targetfs:
> +                os.system("/usr/sbin/chroot %s %s" % (project.targetpath, cmd))
> +        else:
> +            with project.buildenv:
> +                os.system("/usr/sbin/chroot %s %s" % (project.chrootpath, cmd))
> -- 
> 2.11.0
> 
> 
> _______________________________________________
> 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



More information about the elbe-devel mailing list