[elbe-devel] [PATCH 01/13] build sdk: create infrastructure

Manuel Traut manut at linutronix.de
Mon Jan 29 14:02:31 CET 2018


add build_sdk as a subcommand and as a SOAP function.

The implementation of the build_sdk function in elbeproject.py will be
done within the following changes.

Signed-off-by: Manuel Traut <manut at linutronix.de>
---
 elbepack/asyncworker.py        | 25 +++++++++++++++++++++++++
 elbepack/commands/buildsdk.py  | 39 +++++++++++++++++++++++++++++++++++++++
 elbepack/daemons/soap/esoap.py |  7 +++++++
 elbepack/elbeproject.py        |  6 +++++-
 elbepack/projectmanager.py     | 21 ++++++++++++++-------
 elbepack/soapclient.py         | 21 +++++++++++++++++++++
 6 files changed, 111 insertions(+), 8 deletions(-)
 create mode 100644 elbepack/commands/buildsdk.py

diff --git a/elbepack/asyncworker.py b/elbepack/asyncworker.py
index e1f23076..d7dfc725 100644
--- a/elbepack/asyncworker.py
+++ b/elbepack/asyncworker.py
@@ -67,6 +67,31 @@ class BuildSysrootJob(AsyncWorkerJob):
             db.reset_busy(self.project.builddir, "build_failed")
 
 
+class BuildSDKJob(AsyncWorkerJob):
+    def __init__(self, project):
+        AsyncWorkerJob.__init__(self, project)
+
+    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 SDK")
+        AsyncWorkerJob.enqueue(self, queue, db)
+
+    def execute(self, db):
+        try:
+            self.project.log.printo("Build SDK started")
+            self.project.build_sdk()
+            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 SDK 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/commands/buildsdk.py b/elbepack/commands/buildsdk.py
new file mode 100644
index 00000000..4092edb6
--- /dev/null
+++ b/elbepack/commands/buildsdk.py
@@ -0,0 +1,39 @@
+# ELBE - Debian Based Embedded Rootfilesystem Builder
+# Copyright (C) 2015  Linutronix GmbH
+#
+# SPDX-License-Identifier: GPL-3.0
+
+from __future__ import print_function
+
+from optparse import OptionParser
+import sys
+
+from elbepack.elbeproject import ElbeProject
+from elbepack.elbexml import ValidationError
+
+
+def run_command(argv):
+    oparser = OptionParser(
+        usage="usage: %prog buildsdk [options] <builddir>")
+    oparser.add_option("--skip-validation", action="store_true",
+                       dest="skip_validation", default=False,
+                       help="Skip xml schema validation")
+    oparser.add_option("--buildtype", dest="buildtype",
+                       help="Override the buildtype")
+
+    (opt, args) = oparser.parse_args(argv)
+
+    if len(args) != 1:
+        print("wrong number of arguments")
+        oparser.print_help()
+        sys.exit(20)
+
+    try:
+        project = ElbeProject(args[0], override_buildtype=opt.buildtype,
+                              skip_validate=opt.skip_validation)
+    except ValidationError as e:
+        print(str(e))
+        print("xml validation failed. Bailing out")
+        sys.exit(20)
+
+    project.build_sdk()
diff --git a/elbepack/daemons/soap/esoap.py b/elbepack/daemons/soap/esoap.py
index 6da2792b..03fcffc4 100644
--- a/elbepack/daemons/soap/esoap.py
+++ b/elbepack/daemons/soap/esoap.py
@@ -149,6 +149,13 @@ class ESoap (ServiceBase):
         self.app.pm.open_project(uid, builddir)
         self.app.pm.build_sysroot(uid)
 
+    @rpc(String)
+    @authenticated_uid
+    @soap_faults
+    def build_sdk(self, uid, builddir):
+        self.app.pm.open_project(uid, builddir)
+        self.app.pm.build_sdk(uid)
+
     @rpc(String, Boolean, Boolean, Boolean)
     @authenticated_uid
     @soap_faults
diff --git a/elbepack/elbeproject.py b/elbepack/elbeproject.py
index 3bb4547f..ba0cb40a 100644
--- a/elbepack/elbeproject.py
+++ b/elbepack/elbeproject.py
@@ -42,7 +42,7 @@ from elbepack.pbuilder import (pbuilder_write_config, pbuilder_write_repo_hook,
 
 from elbepack.repomanager import ProjectRepo
 from elbepack.config import cfg
-
+from elbepack.pkgutils import get_uri
 
 class IncompatibleArchitectureException(Exception):
     def __init__(self, oldarch, newarch):
@@ -227,6 +227,10 @@ class ElbeProject (object):
         # So we can still elbe chroot into the fs
         self.buildenv.rfs.remove("/etc/elbe_version", noerr=True)
 
+    def build_sdk(self):
+        toolchain = "gcc-%s" % self.xml.defs["triplet"]
+        print(get_uri(self.xml.prj, self.xml.defs, 'amd64', toolchain))
+
     def pbuild(self, p):
         self.pdebuild_init()
         src_path = os.path.join(self.builddir, "pdebuilder", "current")
diff --git a/elbepack/projectmanager.py b/elbepack/projectmanager.py
index 1f87d452..14da0c1b 100644
--- a/elbepack/projectmanager.py
+++ b/elbepack/projectmanager.py
@@ -26,13 +26,15 @@ from uuid import uuid4
 from shutil import rmtree
 
 from elbepack.db import ElbeDB, get_versioned_filename
-from elbepack.asyncworker import AsyncWorker, BuildJob, APTUpdateJob
-from elbepack.asyncworker import APTCommitJob, GenUpdateJob
-from elbepack.asyncworker import SaveVersionJob, CheckoutVersionJob
-from elbepack.asyncworker import APTUpdUpgrJob, BuildSysrootJob
-from elbepack.asyncworker import (PdebuildJob, CreatePbuilderJob,
-                                  UpdatePbuilderJob)
-from elbepack.asyncworker import BuildChrootTarJob
+
+from elbepack.asyncworker import (AsyncWorker, BuildJob, APTUpdateJob,
+                                  APTCommitJob, GenUpdateJob,
+                                  SaveVersionJob, CheckoutVersionJob,
+                                  APTUpdUpgrJob, BuildSysrootJob,
+                                  PdebuildJob, CreatePbuilderJob,
+                                  UpdatePbuilderJob, BuildChrootTarJob,
+                                  BuildSDKJob)
+
 from elbepack.elbexml import ValidationMode
 
 
@@ -358,6 +360,11 @@ class ProjectManager(object):
             ep = self._get_current_project(userid, allow_busy=False)
             self.worker.enqueue(BuildSysrootJob(ep))
 
+    def build_sdk(self, userid):
+        with self.lock:
+            ep = self._get_current_project(userid, allow_busy=False)
+            self.worker.enqueue(BuildSDKJob(ep))
+
     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 3877cb0f..f1fcf28f 100644
--- a/elbepack/soapclient.py
+++ b/elbepack/soapclient.py
@@ -347,6 +347,27 @@ class BuildSysrootAction(ClientAction):
 ClientAction.register(BuildSysrootAction)
 
 
+class BuildSDKAction(ClientAction):
+
+    tag = 'build_sdk'
+
+    def __init__(self, node):
+        ClientAction.__init__(self, node)
+
+    def execute(self, client, opt, args):
+        if len(args) != 1:
+            print(
+                "usage: elbe control build-sdk <project_dir>",
+                file=sys.stderr)
+            sys.exit(20)
+
+        builddir = args[0]
+        client.service.build_sdk(builddir)
+
+
+ClientAction.register(BuildSDKAction)
+
+
 class GetFileAction(ClientAction):
 
     tag = 'get_file'
-- 
2.15.1




More information about the elbe-devel mailing list