[elbe-devel] [PATCH v2 11/24] build sdk: create infrastructure

Torben Hohn torben.hohn at linutronix.de
Thu Feb 8 15:31:19 CET 2018


On Thu, Feb 08, 2018 at 02:16:57PM +0100, Manuel Traut wrote:
> 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>

Reviewed-by: Torben Hohn <torben.hohn 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 c7b7b2df..3d0596c9 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):
> @@ -228,6 +228,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
> 

-- 
Mit freundlichen Grüßen
Torben Hohn

Linutronix GmbH

Standort: Bremen

Phone: +49 7556 25 999 18; Fax.: +49 7556 25 999 99

Firmensitz / Registered Office: D-88690 Uhldingen, Bahnhofstr. 3
Registergericht / Local District Court: Amtsgericht Freiburg i. Br.; HRB
Nr. / Trade register no.: 700 806

Geschäftsführer / Managing Directors: Heinz Egger, Thomas Gleixner

Eine Bitte von uns: Sollten Sie diese E-Mail irrtümlich erhalten haben,
benachrichtigen Sie uns in diesem Falle bitte sobald wie es Ihnen
möglich ist, durch Antwort-Mail. Vielen Dank!
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 488 bytes
Desc: not available
URL: <http://lists.linutronix.de/pipermail/elbe-devel/attachments/20180208/9965f885/attachment.sig>


More information about the elbe-devel mailing list