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

Christian Teklenborg chris at linutronix.de
Tue Mar 10 17:49:41 CET 2020


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)
             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'% (
+                       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"))
+
+                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 "
@@ -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
+        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




More information about the elbe-devel mailing list