[elbe-devel] [PATCH v2 3/3] elbepack: elbeproject.py: build sources with pbuilder

Viraj Shah viraj.shah at linutronix.de
Mon Aug 1 16:32:28 CEST 2022


* Changing directory to pbuilder path and doing "apt-get source" results
  in using the mirrors from the initvm and not from the target mirrors.
* Use chroot instead. Build env, and use chroot to use the target mirror
  configured in xml file.
* Add dependency of dpkg-dev that would be used in later step for
  apt-get  source.
* Once the package source is downloaded in chroot, move it to the
  pbuilder enviornment where the source package should belong. And
  remove the unnecessary files later.

Signed-off-by: Viraj Shah <viraj.shah at linutronix.de>
---
 elbepack/elbeproject.py | 12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)

diff --git a/elbepack/elbeproject.py b/elbepack/elbeproject.py
index aec56f0a8..59ea55a4f 100644
--- a/elbepack/elbeproject.py
+++ b/elbepack/elbeproject.py
@@ -417,7 +417,7 @@ class ElbeProject:
         do("cd %s; chmod +x %s" % (self.builddir, n))
         do("cd %s; rm sdk.txz" % self.builddir)
 
-    def pbuild(self, p):
+    def pbuild(self, p, build_bin=True, build_sources=True):
         self.pdebuild_init()
         src_path = os.path.join(self.builddir, "pdebuilder", "current")
 
@@ -439,7 +439,15 @@ class ElbeProject:
             apt_args = '--yes -q --download-only'
             if self.xml.prj.has('noauth'):
                 apt_args += ' --allow-unauthenticated'
-            do('cd "%s";apt-get source %s "%s"' % (pdb_path, apt_args, src_uri))
+            do('mkdir -p "%s"' % self.chrootpath)
+            self.buildenv = BuildEnv(self.xml, self.chrootpath,
+                                     build_sources=build_sources, clean=True)
+            cmd = ('/bin/apt-get update;/bin/apt-get install -y dpkg-dev')
+            chroot(self.chrootpath, cmd)
+            cmd = ('/bin/apt-get source %s "%s"'% (apt_args, src_uri))
+            chroot(self.chrootpath, cmd)
+            do('mv "%s"/%s* "%s"' % (self.chrootpath, src_uri, pdb_path))
+            do('rm -rf "%s"' % (self.chrootpath))
 
             do('dpkg-source -x %s/*.dsc "%s"' % (pdb_path, src_path))
         else:
-- 
2.30.2



More information about the elbe-devel mailing list