[elbe-devel] [PATCH v2 2/3] pbuilder: create ccache dir in pbuilder environment

Torben Hohn torben.hohn at linutronix.de
Mon May 25 15:43:11 CEST 2020


On Tue, May 19, 2020 at 04:35:29PM +0200, Christian Teklenborg wrote:
> Make sure that the noccache and ccachesize parameters end up in the right
> place. Create a ccache dir in the elbe pbuilder environment and write the
> ccache.conf in there.
> 
> Signed-off-by: Christian Teklenborg <chris at linutronix.de>

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

> ---
>  elbepack/asyncworker.py        |  7 +++++--
>  elbepack/daemons/soap/esoap.py |  6 +++---
>  elbepack/elbeproject.py        | 14 +++++++++++---
>  elbepack/pbuilderaction.py     | 13 +++++++++----
>  elbepack/projectmanager.py     |  5 +++--
>  elbepack/soapclient.py         |  5 +++--
>  6 files changed, 34 insertions(+), 16 deletions(-)
> 
> diff --git a/elbepack/asyncworker.py b/elbepack/asyncworker.py
> index 451725d9..c2e76306 100644
> --- a/elbepack/asyncworker.py
> +++ b/elbepack/asyncworker.py
> @@ -240,9 +240,11 @@ class PdebuildJob(AsyncWorkerJob):
>              db.reset_busy(self.project.builddir, success)
>  
>  class CreatePbuilderJob(AsyncWorkerJob):
> -    def __init__(self, project, cross=False):
> +    def __init__(self, project, ccachesize, cross=False, noccache=False):
>          AsyncWorkerJob.__init__(self, project)
>          self.cross = cross
> +        self.noccache = noccache
> +        self.ccachesize = ccachesize
>  
>      def enqueue(self, queue, db):
>          db.set_busy(self.project.builddir,
> @@ -255,7 +257,8 @@ class CreatePbuilderJob(AsyncWorkerJob):
>          success = self.build_failed
>          try:
>              logging.info("Building pbuilder started")
> -            self.project.create_pbuilder(self.cross)
> +            self.project.create_pbuilder(self.cross, self.noccache,
> +                                         self.ccachesize)
>          except Exception:
>              logging.exception("Pbuilder failed")
>          else:
> diff --git a/elbepack/daemons/soap/esoap.py b/elbepack/daemons/soap/esoap.py
> index b29060b5..a620ea87 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, Boolean)
> +    @rpc(String, Boolean, Boolean, String)
>      @authenticated_uid
>      @soap_faults
> -    def build_pbuilder(self, uid, builddir, cross):
> +    def build_pbuilder(self, uid, builddir, cross, noccache, ccachesize):
>          self.app.pm.open_project(uid, builddir)
> -        self.app.pm.build_pbuilder(uid, cross)
> +        self.app.pm.build_pbuilder(uid, cross, noccache, ccachesize)
>  
>      @rpc(String)
>      @authenticated_uid
> diff --git a/elbepack/elbeproject.py b/elbepack/elbeproject.py
> index 49dbbeee..9033a406 100644
> --- a/elbepack/elbeproject.py
> +++ b/elbepack/elbeproject.py
> @@ -810,7 +810,7 @@ class ElbeProject (object):
>             (os.path.join(self.builddir, "pbuilderrc"),
>              os.path.join(self.builddir, "aptconfdir")))
>  
> -    def create_pbuilder(self, cross):
> +    def create_pbuilder(self, cross, noccache, ccachesize):
>          # Remove old pbuilder directory, if it exists
>          do('rm -rf "%s" "%s"' % (os.path.join(self.builddir, "pbuilder"),
>                                   os.path.join(self.builddir, "pbuilder_cross")))
> @@ -829,14 +829,22 @@ class ElbeProject (object):
>          do('mkdir -p "%s"' %
>             os.path.join(self.builddir, "aptconfdir", "apt.conf.d"))
>  
> +        if not noccache:
> +            ccache_path = os.path.join(self.builddir, "ccache")
> +            do('mkdir -p "%s"' % ccache_path)
> +            do('chmod a+w "%s"' % ccache_path)
> +            ccache_fp = open(os.path.join(ccache_path, "ccache.conf"), "w")
> +            ccache_fp.write("max_size = %s" % ccachesize)
> +            ccache_fp.close()
> +
>          # write config files
>          if cross:
> -            pbuilder_write_cross_config(self.builddir, self.xml)
> +            pbuilder_write_cross_config(self.builddir, self.xml, noccache)
>              pbuilder_write_repo_hook(self.builddir, self.xml, cross)
>              do('chmod -R 755 "%s"' %
>                 os.path.join(self.builddir, "pbuilder_cross", "hooks.d"))
>          else:
> -            pbuilder_write_config(self.builddir, self.xml)
> +            pbuilder_write_config(self.builddir, self.xml, noccache)
>              pbuilder_write_repo_hook(self.builddir, self.xml, cross)
>              do('chmod -R 755 "%s"' %
>                 os.path.join(self.builddir, "pbuilder", "hooks.d"))
> diff --git a/elbepack/pbuilderaction.py b/elbepack/pbuilderaction.py
> index ca7b9aa3..104cdea5 100644
> --- a/elbepack/pbuilderaction.py
> +++ b/elbepack/pbuilderaction.py
> @@ -70,6 +70,12 @@ class CreateAction(PBuilderAction):
>          crossopt = ""
>          if opt.cross:
>              crossopt = "--cross"
> +        if opt.noccache:
> +            ccacheopt = "--no-ccache"
> +            ccachesize = ""
> +        else:
> +            ccacheopt = "--ccache-size"
> +            ccachesize = opt.ccachesize
>  
>          if opt.xmlfile:
>              try:
> @@ -114,9 +120,8 @@ class CreateAction(PBuilderAction):
>          print("Creating pbuilder")
>  
>          try:
> -            system('%s control build_pbuilder "%s" "%s"' % (elbe_exe,
> -                                                            prjdir,
> -                                                            crossopt))
> +            system('%s control build_pbuilder "%s" %s %s %s' % (
> +                    elbe_exe, prjdir, crossopt, ccacheopt, ccachesize))
>          except CommandError:
>              print("elbe control build_pbuilder Failed", file=sys.stderr)
>              print("Giving up", file=sys.stderr)
> @@ -252,7 +257,7 @@ class BuildAction(PBuilderAction):
>          print("")
>  
>          try:
> -            system('%s control set_pdebuild --cpuset "%d" --profile "%s" "%s" '
> +            system('%s control set_pdebuild --cpuset "%d" --profile "%s" %s '
>                     '"%s" "%s"' %
>                     (elbe_exe, opt.cpuset, opt.profile, crossopt,
>                      prjdir, tmp.fname("pdebuild.tar.gz")))
> diff --git a/elbepack/projectmanager.py b/elbepack/projectmanager.py
> index 0aca90ff..0202d9fa 100644
> --- a/elbepack/projectmanager.py
> +++ b/elbepack/projectmanager.py
> @@ -308,10 +308,11 @@ class ProjectManager(object):
>              ep = self._get_current_project(userid, allow_busy=False)
>              self.worker.enqueue(UpdatePbuilderJob(ep))
>  
> -    def build_pbuilder(self, userid, cross):
> +    def build_pbuilder(self, userid, cross, noccache, ccachesize):
>          with self.lock:
>              ep = self._get_current_project(userid, allow_busy=False)
> -            self.worker.enqueue(CreatePbuilderJob(ep, cross))
> +            self.worker.enqueue(CreatePbuilderJob(ep, ccachesize, cross,
> +                                                  noccache))
>  
>      def build_current_pdebuild(self, userid, cpuset, profile, cross):
>          with self.lock:
> diff --git a/elbepack/soapclient.py b/elbepack/soapclient.py
> index de159451..71c6d815 100644
> --- a/elbepack/soapclient.py
> +++ b/elbepack/soapclient.py
> @@ -754,14 +754,15 @@ class BuildPbuilderAction(ClientAction):
>          ClientAction.__init__(self, node)
>  
>      def execute(self, client, opt, args):
> -        if len(args) != 1 and len(args) != 2:
> +        if len(args) != 1:
>              print(
>                  "usage: elbe control build_pbuilder <project_dir>",
>                  file=sys.stderr)
>              sys.exit(20)
>  
>          builddir = args[0]
> -        client.service.build_pbuilder(builddir, opt.cross)
> +        client.service.build_pbuilder(builddir, opt.cross, opt.noccache,
> +                                      opt.ccachesize)
>  
>  
>  ClientAction.register(BuildPbuilderAction)
> -- 
> 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