[elbe-devel] [PATCH 2/2] allow building cdroms via soap interface

Manuel Traut manut at linutronix.de
Fri Jun 8 11:29:44 CEST 2018


this exports the build_cdrom function via SOAP.

If it is called after build_sysroot, the sysroot packages should also be
part of the cdroms.

Signed-off-by: Manuel Traut <manut at linutronix.de>
---
 elbepack/asyncworker.py        | 26 ++++++++++++++++++++++++++
 elbepack/daemons/soap/esoap.py |  7 +++++++
 elbepack/projectmanager.py     |  7 ++++++-
 elbepack/soapclient.py         | 21 +++++++++++++++++++++
 4 files changed, 60 insertions(+), 1 deletion(-)

diff --git a/elbepack/asyncworker.py b/elbepack/asyncworker.py
index 75be989c..910c97ce 100644
--- a/elbepack/asyncworker.py
+++ b/elbepack/asyncworker.py
@@ -81,6 +81,32 @@ class BuildSDKJob(AsyncWorkerJob):
             db.reset_busy(self.project.builddir, "build_failed")
 
 
+class BuildCDROMsJob(AsyncWorkerJob):
+    def __init__(self, project, build_bin, build_src):
+        AsyncWorkerJob.__init__(self, project)
+        self.build_bin = build_bin
+        self.build_src = build_src
+
+    def enqueue(self, queue, db):
+        db.set_busy(self.project.builddir,
+                    ["empty_project", "needs_build", "has_changes",
+                     "build_done", "build_failed"])
+        self.project.log.printo("Enqueueing project for building CDROMs")
+        AsyncWorkerJob.enqueue(self, queue, db)
+
+    def execute(self, db):
+        try:
+            self.project.log.printo("Build CDROMs started")
+            self.project.build_cdroms(build_bin, build_src)
+            db.update_project_files(self.project)
+            self.project.log.printo("Build finished successfully")
+            db.reset_busy(self.project.builddir, "build_done")
+        except Exception as e:
+            db.update_project_files(self.project)
+            self.project.log.printo("Build CDROMs failed")
+            self.project.log.printo(traceback.format_exc())
+            db.reset_busy(self.project.builddir, "build_failed")
+
 class BuildChrootTarJob(AsyncWorkerJob):
     def __init__(self, project):
         AsyncWorkerJob.__init__(self, project)
diff --git a/elbepack/daemons/soap/esoap.py b/elbepack/daemons/soap/esoap.py
index a42cef7a..102faef2 100644
--- a/elbepack/daemons/soap/esoap.py
+++ b/elbepack/daemons/soap/esoap.py
@@ -152,6 +152,13 @@ class ESoap (ServiceBase):
         self.app.pm.open_project(uid, builddir)
         self.app.pm.build_sdk(uid)
 
+    @rpc(String, Boolean, Boolean)
+    @authenticated_uid
+    @soap_faults
+    def build_cdroms(self, uid, builddir, build_bin, build_src):
+        self.app.pm.open_project(uid, builddir)
+        self.app.pm.build_cdroms(uid, build_bin, build_src)
+
     @rpc(String, Boolean, Boolean, Boolean)
     @authenticated_uid
     @soap_faults
diff --git a/elbepack/projectmanager.py b/elbepack/projectmanager.py
index 60d76659..4ab310ca 100644
--- a/elbepack/projectmanager.py
+++ b/elbepack/projectmanager.py
@@ -22,7 +22,7 @@ from elbepack.asyncworker import (AsyncWorker, BuildJob, APTUpdateJob,
                                   APTUpdUpgrJob, BuildSysrootJob,
                                   PdebuildJob, CreatePbuilderJob,
                                   UpdatePbuilderJob, BuildChrootTarJob,
-                                  BuildSDKJob)
+                                  BuildSDKJob, BuildCDROMsJob)
 
 from elbepack.elbexml import ValidationMode
 
@@ -354,6 +354,11 @@ class ProjectManager(object):
             ep = self._get_current_project(userid, allow_busy=False)
             self.worker.enqueue(BuildSDKJob(ep))
 
+    def build_cdroms(self, userid, build_bin, build_src):
+        with self.lock:
+            ep = self._get_current_project(userid, allow_busy=False)
+            self.worker.enqueue(BuildCDROMsJob(ep, build_bin, build_src))
+
     def build_update_package(self, userid, base_version):
         with self.lock:
             c = self._get_current_project_apt_cache(userid)
diff --git a/elbepack/soapclient.py b/elbepack/soapclient.py
index f91081a9..2a66a559 100644
--- a/elbepack/soapclient.py
+++ b/elbepack/soapclient.py
@@ -390,6 +390,27 @@ class BuildSDKAction(ClientAction):
 ClientAction.register(BuildSDKAction)
 
 
+class BuildCDROMsAction(ClientAction):
+
+    tag = 'build_cdroms'
+
+    def __init__(self, node):
+        ClientAction.__init__(self, node)
+
+    def execute(self, client, opt, args):
+        if len(args) != 1:
+            print(
+                "usage: elbe control build-cdroms <project_dir>",
+                file=sys.stderr)
+            sys.exit(20)
+
+        builddir = args[0]
+        client.service.build_cdroms(builddir, opt.build_bin, opt.build_sources)
+
+
+ClientAction.register(BuildCDROMsAction)
+
+
 class GetFileAction(ClientAction):
 
     tag = 'get_file'
-- 
2.17.1




More information about the elbe-devel mailing list