[elbe-devel] [PATCH v3 3/4] pbuilder: add cross option to pbuilder

Torben Hohn torben.hohn at linutronix.de
Wed Apr 29 16:08:58 CEST 2020


On Mon, Apr 27, 2020 at 04:35:43PM +0200, Christian Teklenborg wrote:
> Add a '--cross' option to pbuilder with the 'store_true' action. The option
> defaults to False. Make sure that the stored boolean ends up in the
> elbeproject.
> 
> Signed-off-by: Christian Teklenborg <chris at linutronix.de>

see below..

> ---
>  elbepack/asyncworker.py        | 10 ++++++----
>  elbepack/commands/control.py   |  6 ++++++
>  elbepack/commands/pbuilder.py  |  6 ++++++
>  elbepack/daemons/soap/esoap.py | 12 ++++++------
>  elbepack/elbeproject.py        |  8 +++++---
>  elbepack/pbuilderaction.py     | 14 +++++++++++---
>  elbepack/soapclient.py         |  4 ++--
>  7 files changed, 42 insertions(+), 18 deletions(-)
> 
> diff --git a/elbepack/asyncworker.py b/elbepack/asyncworker.py
> index 2d2deeff..451725d9 100644
> --- a/elbepack/asyncworker.py
> +++ b/elbepack/asyncworker.py
> @@ -209,10 +209,11 @@ class BuildJob(AsyncWorkerJob):
>              db.reset_busy(self.project.builddir, success)
>  
>  class PdebuildJob(AsyncWorkerJob):
> -    def __init__(self, project, cpuset=-1, profile=""):
> +    def __init__(self, project, cpuset=-1, profile="", cross=False):
>          AsyncWorkerJob.__init__(self, project)
>          self.cpuset=cpuset
>          self.profile=profile
> +        self.cross=cross
>  
>      def enqueue(self, queue, db):
>          db.set_busy(self.project.builddir,
> @@ -225,7 +226,7 @@ class PdebuildJob(AsyncWorkerJob):
>          success = self.build_failed
>          try:
>              logging.info("Pdebuild started")
> -            self.project.pdebuild(self.cpuset, self.profile)
> +            self.project.pdebuild(self.cpuset, self.profile, self.cross)
>          except Exception:
>              logging.exception("Pdebuild failed")
>          else:
> @@ -239,8 +240,9 @@ class PdebuildJob(AsyncWorkerJob):
>              db.reset_busy(self.project.builddir, success)
>  
>  class CreatePbuilderJob(AsyncWorkerJob):
> -    def __init__(self, project):
> +    def __init__(self, project, cross=False):
>          AsyncWorkerJob.__init__(self, project)
> +        self.cross = cross
>  
>      def enqueue(self, queue, db):
>          db.set_busy(self.project.builddir,
> @@ -253,7 +255,7 @@ class CreatePbuilderJob(AsyncWorkerJob):
>          success = self.build_failed
>          try:
>              logging.info("Building pbuilder started")
> -            self.project.create_pbuilder()
> +            self.project.create_pbuilder(self.cross)
>          except Exception:
>              logging.exception("Pbuilder failed")
>          else:
> diff --git a/elbepack/commands/control.py b/elbepack/commands/control.py
> index 442df289..24b39269 100644
> --- a/elbepack/commands/control.py
> +++ b/elbepack/commands/control.py
> @@ -86,6 +86,12 @@ def run_command(argv):
>      oparser.add_option("--profile", dest="profile", default="",
>                         help="Make pbuilder commands build the specified profile")
>  
> +    oparser.add_option("--cross", dest="cross", default=False,
> +                       action="store_true",
> +                       help="Creates an environment for crossbuilding if "
> +                            "combined with create. Combined with build it"
> +                            " will use this environment.")
> +
>      devel = OptionGroup(
>          oparser,
>          "options for elbe developers",
> diff --git a/elbepack/commands/pbuilder.py b/elbepack/commands/pbuilder.py
> index 2e5f55d9..91844e62 100644
> --- a/elbepack/commands/pbuilder.py
> +++ b/elbepack/commands/pbuilder.py
> @@ -46,6 +46,12 @@ def run_command(argv):
>      oparser.add_option("--profile", dest="profile", default="",
>                         help="profile that shall be built")
>  
> +    oparser.add_option("--cross", dest="cross", default=False,
> +                       action="store_true",
> +                       help="Creates an environment for crossbuilding if "
> +                            "combined with create. Combined with build it"
> +                            " will use this environment.")
> +
>      PreprocessWrapper.add_options(oparser)
>  
>      (opt, args) = oparser.parse_args(argv)
> diff --git a/elbepack/daemons/soap/esoap.py b/elbepack/daemons/soap/esoap.py
> index ddc09018..b29060b5 100644
> --- a/elbepack/daemons/soap/esoap.py
> +++ b/elbepack/daemons/soap/esoap.py
> @@ -227,12 +227,12 @@ class ESoap (ServiceBase):
>          self.app.pm.build_current_project(uid, build_bin, build_src,
>                                            skip_pbuilder)
>  
> -    @rpc(String)
> +    @rpc(String, Boolean)
>      @authenticated_uid
>      @soap_faults
> -    def build_pbuilder(self, uid, builddir):
> +    def build_pbuilder(self, uid, builddir, cross):
>          self.app.pm.open_project(uid, builddir)
> -        self.app.pm.build_pbuilder(uid)
> +        self.app.pm.build_pbuilder(uid, cross)
>  
>      @rpc(String)
>      @authenticated_uid
> @@ -301,12 +301,12 @@ class ESoap (ServiceBase):
>          fp.write(binascii.a2b_base64(data))
>          fp.close()
>  
> -    @rpc(String, Integer, String)
> +    @rpc(String, Integer, String, Boolean)
>      @authenticated_uid
>      @soap_faults
> -    def finish_pdebuild(self, uid, builddir, cpuset, profile):
> +    def finish_pdebuild(self, uid, builddir, cpuset, profile, cross):
>          self.app.pm.open_project(uid, builddir)
> -        self.app.pm.build_current_pdebuild(uid, cpuset, profile)
> +        self.app.pm.build_current_pdebuild(uid, cpuset, profile, cross)
>  
>      @rpc(String, String)
>      @authenticated_uid
> diff --git a/elbepack/elbeproject.py b/elbepack/elbeproject.py
> index 4f0dbb56..5bffa14b 100644
> --- a/elbepack/elbeproject.py
> +++ b/elbepack/elbeproject.py
> @@ -668,15 +668,17 @@ class ElbeProject (object):
>      def pdebuild(self, cpuset, profile, cross):
>          cross_pbuilderrc = os.path.join(self.builddir, "cross_pbuilderrc")
>          if cross and not os.path.exists(cross_pbuilderrc):
> -            logging.error("Please make sure that you create the pbuilder environment "
> -                          "with the --cross option if you want to use the build "
> -                          "command with --cross.")
> +            logging.error("Please make sure that you create the pbuilder "
> +                          "environment with the --cross option if you want to "
> +                          "use the build command with --cross.")
>              sys.exit(20)
> +
>          if os.path.exists(cross_pbuilderrc) and not cross:
>              logging.error("Please make sure that if you created the pbuilder "
>                            "environment without the --cross option, you use the "
>                            "build command without --cross too.")
>              sys.exit(20)
> +
>          self.pdebuild_init()
>  
>          pbdir = os.path.join(self.builddir, "pdebuilder", "current")
> diff --git a/elbepack/pbuilderaction.py b/elbepack/pbuilderaction.py
> index 1a567a33..ca7b9aa3 100644
> --- a/elbepack/pbuilderaction.py
> +++ b/elbepack/pbuilderaction.py
> @@ -67,6 +67,9 @@ class CreateAction(PBuilderAction):
>          PBuilderAction.__init__(self, node)
>  
>      def execute(self, opt, _args):
> +        crossopt = ""
> +        if opt.cross:
> +            crossopt = "--cross"
>  
>          if opt.xmlfile:
>              try:
> @@ -111,7 +114,9 @@ class CreateAction(PBuilderAction):
>          print("Creating pbuilder")
>  
>          try:
> -            system('%s control build_pbuilder "%s"' % (elbe_exe, prjdir))
> +            system('%s control build_pbuilder "%s" "%s"' % (elbe_exe,
> +                                                            prjdir,
> +                                                            crossopt))
>          except CommandError:
>              print("elbe control build_pbuilder Failed", file=sys.stderr)
>              print("Giving up", file=sys.stderr)
> @@ -176,6 +181,9 @@ class BuildAction(PBuilderAction):
>          # pylint: disable=too-many-statements
>          # pylint: disable=too-many-branches
>  
> +        crossopt = ""
> +        if opt.cross:
> +            crossopt = "--cross"
>          tmp = TmpdirFilesystem()
>  
>          if opt.xmlfile:
> @@ -244,9 +252,9 @@ class BuildAction(PBuilderAction):
>          print("")
>  
>          try:
> -            system('%s control set_pdebuild --cpuset "%d" --profile "%s" '
> +            system('%s control set_pdebuild --cpuset "%d" --profile "%s" "%s" '
>                     '"%s" "%s"' %
> -                   (elbe_exe, opt.cpuset, opt.profile,
> +                   (elbe_exe, opt.cpuset, opt.profile, crossopt,
>                      prjdir, tmp.fname("pdebuild.tar.gz")))
>          except CommandError:
>              print("elbe control set_pdebuild Failed", file=sys.stderr)
> diff --git a/elbepack/soapclient.py b/elbepack/soapclient.py
> index de159451..e19487a2 100644
> --- a/elbepack/soapclient.py
> +++ b/elbepack/soapclient.py
> @@ -727,8 +727,8 @@ class SetPdebuilderAction(ClientAction):
>                    "<project_dir> <pdebuild file>", file=sys.stderr)
>              sys.exit(20)
>  
> -        builddir = args[0]
> -        filename = args[1]
> +        builddir = args[-2]
> +        filename = args[-1]

dont use negative indices.
I dont see a reason, why this is changed.

Remove this hunk and add:

Reviewed-by: Torben Hohn <torben.hohn at linutronix.de>

>  
>          fp = open(filename, "r")
>          client.service.start_pdebuild(builddir)
> -- 
> 2.20.1
> 
> 
> _______________________________________________
> 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