[elbe-devel] [PATCH v2 1/3] pbuilder: add ccache option to pbuilder

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


On Tue, May 19, 2020 at 04:35:28PM +0200, Christian Teklenborg wrote:
> By creating a pbuilder environment ccache gets installed by default. Therefore
> change the pbuilder config file to implement ccache. It can be
> deactivated by calling '--no-ccache' when the pbuilder environemt is created.
> Also add an option '--ccache-size "size"' where size takes a number followed by
> an optional suffix (k, M, G, T) and sets the maximum size of the compiler cache.
> Use 0 for no limit.
> 
> Signed-off-by: Christian Teklenborg <chris at linutronix.de>


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

> ---
>  elbepack/commands/control.py  | 10 ++++++++++
>  elbepack/commands/pbuilder.py | 10 ++++++++++
>  elbepack/elbeproject.py       |  3 ++-
>  elbepack/pbuilder.py          | 18 ++++++++++++++++--
>  4 files changed, 38 insertions(+), 3 deletions(-)
> 
> diff --git a/elbepack/commands/control.py b/elbepack/commands/control.py
> index 24b39269..a1c17365 100644
> --- a/elbepack/commands/control.py
> +++ b/elbepack/commands/control.py
> @@ -92,6 +92,16 @@ def run_command(argv):
>                              "combined with create. Combined with build it"
>                              " will use this environment.")
>  
> +    oparser.add_option("--no-ccache", dest="noccache", default=False,
> +                       action="store_true",
> +                       help="Deactivates the compiler cache 'ccache'")
> +
> +    oparser.add_option("--ccache-size", dest="ccachesize", default="10G",
> +                       action="store", type="string",
> +                       help="set a limit for the compiler cache size "
> +                            "(should be a number followed by an optional "
> +                            "suffix: k, M, G, T. Use 0 for no limit.)")
> +
>      devel = OptionGroup(
>          oparser,
>          "options for elbe developers",
> diff --git a/elbepack/commands/pbuilder.py b/elbepack/commands/pbuilder.py
> index 91844e62..3e7dc578 100644
> --- a/elbepack/commands/pbuilder.py
> +++ b/elbepack/commands/pbuilder.py
> @@ -52,6 +52,16 @@ def run_command(argv):
>                              "combined with create. Combined with build it"
>                              " will use this environment.")
>  
> +    oparser.add_option("--no-ccache", dest="noccache", default=False,
> +                       action="store_true",
> +                       help="Deactivates the compiler cache 'ccache'")
> +
> +    oparser.add_option("--ccache-size", dest="ccachesize", default="10G",
> +                       action="store", type="string",
> +                       help="set a limit for the compiler cache size "
> +                            "(should be a number followed by an optional "
> +                            "suffix: k, M, G, T. Use 0 for no limit.)")
> +
>      PreprocessWrapper.add_options(oparser)
>  
>      (opt, args) = oparser.parse_args(argv)
> diff --git a/elbepack/elbeproject.py b/elbepack/elbeproject.py
> index 8d45469d..49dbbeee 100644
> --- a/elbepack/elbeproject.py
> +++ b/elbepack/elbeproject.py
> @@ -565,7 +565,8 @@ class ElbeProject (object):
>  
>          if self.xml.has('target/pbuilder') and not skip_pbuild:
>              if not os.path.exists(os.path.join(self.builddir, "pbuilder")):
> -                self.create_pbuilder(cross=False)
> +                self.create_pbuilder(cross=False, noccache=False,
> +                                     ccachesize="10G")
>              for p in self.xml.node('target/pbuilder'):
>                  self.pbuild(p)
>                  # the package might be needed by a following pbuild, so update
> diff --git a/elbepack/pbuilder.py b/elbepack/pbuilder.py
> index e6f0b3cf..41697790 100644
> --- a/elbepack/pbuilder.py
> +++ b/elbepack/pbuilder.py
> @@ -12,7 +12,7 @@ try:
>  except ImportError:
>      from urllib2 import urlopen
>  
> -def pbuilder_write_config(builddir, xml):
> +def pbuilder_write_config(builddir, xml, noccache):
>      distname = xml.prj.text('suite')
>      pbuilderrc_fname = os.path.join(builddir, "pbuilderrc")
>      fp = open(pbuilderrc_fname, "w")
> @@ -60,9 +60,16 @@ def pbuilder_write_config(builddir, xml):
>      fp.write('PBUILDERSATISFYDEPENDSCMD='
>               '/usr/lib/pbuilder/pbuilder-satisfydepends-experimental\n')
>  
> +    if not noccache:
> +        fp.write('export CCACHE_DIR="%s/ccache"\n' % builddir)
> +        fp.write('export PATH="/usr/lib/ccache:${PATH}"\n')
> +        fp.write('EXTRAPACKAGES=ccache\n')
> +        fp.write('export CCACHE_CONFIGPATH="%s/ccache/ccache.conf"\n' %
> +                 builddir)
> +        fp.write('BINDMOUNTS="${CCACHE_DIR}"')
>      fp.close()
>  
> -def pbuilder_write_cross_config(builddir, xml):
> +def pbuilder_write_cross_config(builddir, xml, noccache):
>      distname = xml.prj.text('suite')
>      pbuilderrc_fname = os.path.join(builddir, "cross_pbuilderrc")
>      fp = open(pbuilderrc_fname, "w")
> @@ -83,6 +90,13 @@ def pbuilder_write_cross_config(builddir, xml):
>      fp.write('HOOKDIR="%s"\n' % os.path.join(builddir, 'pbuilder_cross', 'hooks.d'))
>      fp.write('PBUILDERSATISFYDEPENDSCMD='
>               '/usr/lib/pbuilder/pbuilder-satisfydepends-apt\n')
> +    if not noccache:
> +        fp.write('export CCACHE_DIR="%s/ccache"\n' % builddir)
> +        fp.write('export PATH="/usr/lib/ccache:${PATH}"\n')
> +        fp.write('EXTRAPACKAGES=ccache\n')
> +        fp.write('export CCACHE_CONFIGPATH="%s/ccache/ccache.conf"\n' %
> +                 builddir)
> +        fp.write('BINDMOUNTS="${CCACHE_DIR}"')
>      fp.close()
>  
>  
> -- 
> 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