[elbe-devel] [PATCH v2 2/4] pbuilder: adjust pdebuild_build and create_pbuilder

Torben Hohn torben.hohn at linutronix.de
Thu Apr 2 13:33:08 CEST 2020


On Fri, Mar 20, 2020 at 05:41:02PM +0100, Christian Teklenborg wrote:
> Create two build environments if the 'elbe pbuilder create --cross' command
> is called. One environment with qemu-debootstrap and the other one for
> crossbuilding packages. Now you can run 'elbe pbuilder --cross build' to use
> the environment for crossbuilding and without --cross it will use the other
> environment. Change the create_pbuilder function that it will write the correct
> pbuilder config file. Revise the pdebuild_build function to make sure that in
> case of --cross used with the build command pbuilder runs with the '--host-arch'
> option.

Hi Chris, 

sorry for the late reply. I was busy with another project.


why should pbuilder create --cross create a normal environment ?
this takes pretty long, and in most cases, we only need one of the
environments.

Please add an else in the right spot.

I also dont see the check, whether the correct pbuilder environment
has been created.

Do you add that in a lter patch ?

The rest of this patch looks good.

> 
> Signed-off-by: Christian Teklenborg <chris at linutronix.de>
> ---
>  elbepack/elbeproject.py | 75 +++++++++++++++++++++++++++++++----------
>  1 file changed, 57 insertions(+), 18 deletions(-)
> 
> diff --git a/elbepack/elbeproject.py b/elbepack/elbeproject.py
> index b64a5fcb..3c860fba 100644
> --- a/elbepack/elbeproject.py
> +++ b/elbepack/elbeproject.py
> @@ -31,6 +31,7 @@ from elbepack.dump import check_full_pkgs
>  from elbepack.cdroms import mk_source_cdrom, mk_binary_cdrom
>  
>  from elbepack.pbuilder import (pbuilder_write_config, pbuilder_write_repo_hook,
> +                               pbuilder_write_cross_config,
>                                 pbuilder_write_apt_conf)
>  
>  from elbepack.repomanager import ProjectRepo
> @@ -506,7 +507,7 @@ 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()
> +                self.create_pbuilder(cross=False)
>              for p in self.xml.node('target/pbuilder'):
>                  self.pbuild(p)
>                  # the package might be needed by a following pbuild, so update
> @@ -657,7 +658,7 @@ class ElbeProject (object):
>          do('mkdir -p "%s"' % os.path.join(self.builddir,
>                                            "pbuilder", "result"))
>  
> -    def pdebuild(self, cpuset, profile):
> +    def pdebuild(self, cpuset, profile, cross):
>          self.pdebuild_init()
>  
>          pbdir = os.path.join(self.builddir, "pdebuilder", "current")
> @@ -677,10 +678,10 @@ class ElbeProject (object):
>          do('tar xfz "%s" -C "%s"' %
>             (os.path.join(self.builddir, "current_pdebuild.tar.gz"), pbdir))
>  
> -        self.pdebuild_build(cpuset, profile)
> +        self.pdebuild_build(cpuset, profile, cross)
>          self.repo.finalize()
>  
> -    def pdebuild_build(self, cpuset, profile):
> +    def pdebuild_build(self, cpuset, profile, cross):
>          # check whether we have to use taskset to run pdebuild
>          # this might be useful, when things like java dont
>          # work with multithreading
> @@ -692,15 +693,35 @@ class ElbeProject (object):
>              cpuset_cmd = ''
>  
>          try:
> -            do('cd "%s"; %s pdebuild --debbuildopts "-j%s -sa" '
> -               '--configfile "%s" '
> -               '--use-pdebuild-internal --buildresult "%s"' % (
> -                   os.path.join(self.builddir, "pdebuilder", "current"),
> -                   cpuset_cmd,
> -                   cfg['pbuilder_jobs'],
> -                   os.path.join(self.builddir, "pbuilderrc"),
> -                   os.path.join(self.builddir, "pbuilder", "result")),
> -               env_add={'DEB_BUILD_PROFILES': profile.replace(",", " ")})
> +            if cross:
> +                do('cd "%s"; dpkg-source -b .; %s '
> +                   'pbuilder build --host-arch %s --configfile "%s" '
> +                   '--basetgz "%s" --buildresult "%s" '
> +                   '../*.dsc' % (
> +                       os.path.join(self.builddir, "pdebuilder", "current"),
> +                       cpuset_cmd, self.arch,
> +                       os.path.join(self.builddir, "cross_pbuilderrc"),
> +                       os.path.join(self.builddir, "pbuilder_cross", "base.tgz"),
> +                       os.path.join(self.builddir, "pbuilder_cross", "result")),
> +                   env_add={'DEB_BUILD_PROFILES': profile.replace(",", " ")})
> +                self.repo.include(os.path.join(self.builddir,
> +                                               "pbuilder_cross",
> +                                               "result",
> +                                               "*.changes"))
> +            else:
> +                do('cd "%s"; %s pdebuild --debbuildopts "-j%s -sa" '
> +                   '--configfile "%s" '
> +                   '--use-pdebuild-internal --buildresult "%s"' % (
> +                       os.path.join(self.builddir, "pdebuilder", "current"),
> +                       cpuset_cmd,
> +                       cfg['pbuilder_jobs'],
> +                       os.path.join(self.builddir, "pbuilderrc"),
> +                       os.path.join(self.builddir, "pbuilder", "result")),
> +                   env_add={'DEB_BUILD_PROFILES': profile.replace(",", " ")})
> +                self.repo.include(os.path.join(self.builddir,
> +                                               "pbuilder",
> +                                               "result",
> +                                               "*.changes"))
>  
>              self.repo.remove(os.path.join(self.builddir,
>                                            "pdebuilder",
> @@ -708,11 +729,9 @@ class ElbeProject (object):
>                                            "debian",
>                                            "control"))
>  
> -            self.repo.include(os.path.join(self.builddir,
> -                                           "pbuilder", "result", "*.changes"))
>          except CommandError:
>              logging.exception("Package fails to build.\n"
> -                              "Please make sure, that the submited package "
> +                              "Please make sure, that the submitted package "
>                                "builds in pbuilder")
>  
>      def update_pbuilder(self):
> @@ -720,11 +739,17 @@ class ElbeProject (object):
>             (os.path.join(self.builddir, "pbuilderrc"),
>              os.path.join(self.builddir, "aptconfdir")))
>  
> -    def create_pbuilder(self):
> +    def create_pbuilder(self, cross):
>          # Remove old pbuilder directory, if it exists
> -        do('rm -rf "%s"' % os.path.join(self.builddir, "pbuilder"))
> +        do('rm -rf "%s" "%s"' % (os.path.join(self.builddir, "pbuilder"),
> +                                 os.path.join(self.builddir, "pbuilder_cross")))
>  
>          # make hooks.d and pbuilder directory
> +        if cross:
> +            do('mkdir -p "%s"' %
> +               os.path.join(self.builddir, "pbuilder_cross", "hooks.d"))
> +            do('mkdir -p "%s"' %
> +               os.path.join(self.builddir, "pbuilder_cross", "aptcache"))
>          do('mkdir -p "%s"' %
>             os.path.join(self.builddir, "pbuilder", "hooks.d"))
>          do('mkdir -p "%s"' %
> @@ -733,6 +758,10 @@ class ElbeProject (object):
>             os.path.join(self.builddir, "aptconfdir", "apt.conf.d"))
>  
>          # write config files
> +        if cross:
> +            pbuilder_write_cross_config(self.builddir, self.xml)
> +            do('chmod -R 755 "%s"' %
> +               os.path.join(self.builddir, "pbuilder_cross", "hooks.d"))
>          pbuilder_write_config(self.builddir, self.xml)
>          pbuilder_write_apt_conf(self.builddir, self.xml)
>          pbuilder_write_repo_hook(self.builddir, self.xml)
> @@ -740,6 +769,16 @@ class ElbeProject (object):
>             os.path.join(self.builddir, "pbuilder", "hooks.d"))
>  
>          # Run pbuilder --create
> +        if cross:
> +            do('pbuilder --create --buildplace "%s" '
> +               '--configfile "%s" --aptconfdir "%s" '
> +               '--debootstrapopts --include="git gnupg";'
> +               'mv %s %s' %
> +               (os.path.join(self.builddir, "pbuilder_cross"),
> +                os.path.join(self.builddir, "cross_pbuilderrc"),
> +                os.path.join(self.builddir, "aptconfdir"),
> +                os.path.join(self.builddir, "pbuilder", "base.tgz"),
> +                os.path.join(self.builddir, "pbuilder_cross")))
>          do('pbuilder --create --configfile "%s" --aptconfdir "%s" '
>             '--debootstrapopts --include="git gnupg"' %
>             (os.path.join(self.builddir, "pbuilderrc"),
> -- 
> 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