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

Torben Hohn torben.hohn at linutronix.de
Thu Mar 12 11:46:27 CET 2020


On Tue, Mar 10, 2020 at 05:49:41PM +0100, Christian Teklenborg wrote:
> Add 'self.cross = False' to the ElbeProject and change it to True if the
> 'elbe pbuilder create --cross' command is called. 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 'self.cross = True'
> pbuilder runs with the '--host-arch' option.
> 
> Signed-off-by: Christian Teklenborg <chris at linutronix.de>
> ---
>  elbepack/elbeproject.py | 61 +++++++++++++++++++++++++++--------------
>  1 file changed, 40 insertions(+), 21 deletions(-)
> 
> diff --git a/elbepack/elbeproject.py b/elbepack/elbeproject.py
> index b64a5fcb..ca1a33c2 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
> @@ -151,6 +152,8 @@ class ElbeProject (object):
>  
>          self.private_data = private_data
>  
> +        self.cross = False
> +
>          # Apt-Cache will be created on demand with the specified notifier by
>          # the get_rpcaptcache method
>          self._rpcaptcache = None
> @@ -506,7 +509,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(self.cross)

you pass self.cross to a method that has access to self.cross.
That does not make sense.


>              for p in self.xml.node('target/pbuilder'):
>                  self.pbuild(p)
>                  # the package might be needed by a following pbuild, so update
> @@ -692,24 +695,36 @@ 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(",", " ")})
> -
> -            self.repo.remove(os.path.join(self.builddir,
> -                                          "pdebuilder",
> -                                          "current",
> -                                          "debian",
> -                                          "control"))
> -
> -            self.repo.include(os.path.join(self.builddir,
> -                                           "pbuilder", "result", "*.changes"))
> +            if self.cross:
> +                do('cd "%s"; dpkg-source -b .; %s '
> +                   'pbuilder build --host-arch %s --configfile "%s" '
> +                   '--basetgz "%s" --buildresult "%s" '
> +                   '../*.dsc'% (

one space is missing...         ^

https://www.python.org/dev/peps/pep-0008/#should-a-line-break-before-or-after-a-binary-operator

suggest, the we format it like this:

                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(",", " ")})

> +                       os.path.join(self.builddir, "pdebuilder", "current"),
> +                       cpuset_cmd,
> +                       self.arch, os.path.join(self.builddir, "pbuilderrc"),
> +                       os.path.join(self.builddir, "pbuilder", "base.tgz"),
> +                       os.path.join(self.builddir, "pbuilder", "result")),
> +                   env_add={'DEB_BUILD_PROFILES': profile.replace(",", " ")})
> +            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.remove(os.path.join(self.builddir,
> +                                           "pdebuilder",
> +                                           "current",
> +                                           "debian",
> +                                           "control"))

formatting looks broken                       ^ not aligned below s

> +
> +                self.repo.include(os.path.join(self.builddir,
> +                                                   "pbuilder", "result", "*.changes"))

formatting looks broken                               ^ not aligned below s

>          except CommandError:
>              logging.exception("Package fails to build.\n"
>                                "Please make sure, that the submited package "
> @@ -720,7 +735,7 @@ 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"))
>  
> @@ -733,7 +748,11 @@ class ElbeProject (object):
>             os.path.join(self.builddir, "aptconfdir", "apt.conf.d"))
>  
>          # write config files
> -        pbuilder_write_config(self.builddir, self.xml)
> +        if cross:
> +            pbuilder_write_cross_config(self.builddir, self.xml)
> +            self.cross = cross

self.cross is not persistent.
If you restart the initvm, it will be back to false.
no matter what kind of pbuilder is created there.

Its also not reset to False, if i create another pbuilder.

We have 3 options.

Save the cross flag into the database.

Save a file into the project directory.

Create the cross pbuilder and the noncross pbuilder into separate
directories. 

This allows to mix cross and non cross builds in the xml file.
Because we can prepare 2 pbuilders.

And we can evaluate the cross flag on pbuilder build also.

> +        else:
> +            pbuilder_write_config(self.builddir, self.xml)
>          pbuilder_write_apt_conf(self.builddir, self.xml)
>          pbuilder_write_repo_hook(self.builddir, self.xml)
>          do('chmod -R 755 "%s"' %
> -- 
> 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