[elbe-devel] [PATCH v2 2/4] pbuilder: adjust pdebuild_build and create_pbuilder
Christian Teklenborg
chris at linutronix.de
Fri Mar 20 17:41:02 CET 2020
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.
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
More information about the elbe-devel
mailing list