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

Christian Teklenborg chris at linutronix.de
Tue Mar 10 17:49:42 CET 2020


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>
---
 elbepack/asyncworker.py        | 5 +++--
 elbepack/commands/pbuilder.py  | 4 ++++
 elbepack/daemons/soap/esoap.py | 6 +++---
 elbepack/pbuilderaction.py     | 5 ++++-
 elbepack/projectmanager.py     | 4 ++--
 elbepack/soapclient.py         | 5 +++--
 6 files changed, 19 insertions(+), 10 deletions(-)

diff --git a/elbepack/asyncworker.py b/elbepack/asyncworker.py
index 2d2deeff..a988f38f 100644
--- a/elbepack/asyncworker.py
+++ b/elbepack/asyncworker.py
@@ -239,8 +239,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 +254,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/pbuilder.py b/elbepack/commands/pbuilder.py
index 2e5f55d9..728201b7 100644
--- a/elbepack/commands/pbuilder.py
+++ b/elbepack/commands/pbuilder.py
@@ -46,6 +46,10 @@ 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="Crossbuilding packages using multiarch.")
+
     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 7d76d6a3..27025365 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, Integer)
     @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
diff --git a/elbepack/pbuilderaction.py b/elbepack/pbuilderaction.py
index 1a567a33..eb2afa1d 100644
--- a/elbepack/pbuilderaction.py
+++ b/elbepack/pbuilderaction.py
@@ -67,6 +67,7 @@ class CreateAction(PBuilderAction):
         PBuilderAction.__init__(self, node)
 
     def execute(self, opt, _args):
+        cross = opt.cross
 
         if opt.xmlfile:
             try:
@@ -111,7 +112,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,
+                                                            int(cross)))
         except CommandError:
             print("elbe control build_pbuilder Failed", file=sys.stderr)
             print("Giving up", file=sys.stderr)
diff --git a/elbepack/projectmanager.py b/elbepack/projectmanager.py
index f8ed894f..19cbe09e 100644
--- a/elbepack/projectmanager.py
+++ b/elbepack/projectmanager.py
@@ -308,10 +308,10 @@ class ProjectManager(object):
             ep = self._get_current_project(userid, allow_busy=False)
             self.worker.enqueue(UpdatePbuilderJob(ep))
 
-    def build_pbuilder(self, userid):
+    def build_pbuilder(self, userid, cross):
         with self.lock:
             ep = self._get_current_project(userid, allow_busy=False)
-            self.worker.enqueue(CreatePbuilderJob(ep))
+            self.worker.enqueue(CreatePbuilderJob(ep, cross))
 
     def build_current_pdebuild(self, userid, cpuset, profile):
         with self.lock:
diff --git a/elbepack/soapclient.py b/elbepack/soapclient.py
index 589bdefd..2fad71c9 100644
--- a/elbepack/soapclient.py
+++ b/elbepack/soapclient.py
@@ -753,14 +753,15 @@ class BuildPbuilderAction(ClientAction):
         ClientAction.__init__(self, node)
 
     def execute(self, client, _opt, args):
-        if len(args) != 1:
+        if len(args) != 2:
             print(
                 "usage: elbe control build_pbuilder <project_dir>",
                 file=sys.stderr)
             sys.exit(20)
 
         builddir = args[0]
-        client.service.build_pbuilder(builddir)
+        cross = args[1]
+        client.service.build_pbuilder(builddir, cross)
 
 
 ClientAction.register(BuildPbuilderAction)
-- 
2.20.1




More information about the elbe-devel mailing list