[elbe-devel] [PATCH v3] elbepack: elbeproject.py: pbuild: download sources from target mirrors

Viraj Shah viraj.shah at linutronix.de
Fri Sep 23 16:32:10 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.
* Once the package source is downloaded in chroot, move it to the
  pbuilder environment 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 | 14 +++++++++++---
 1 file changed, 11 insertions(+), 3 deletions(-)

diff --git a/elbepack/elbeproject.py b/elbepack/elbeproject.py
index aec56f0a8..4c388e845 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_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')
+            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:
@@ -574,7 +582,7 @@ class ElbeProject:
                 self.create_pbuilder(cross=False, noccache=False,
                                      ccachesize="10G")
             for p in self.xml.node('target/pbuilder'):
-                self.pbuild(p)
+                self.pbuild(p, build_sources)
                 # the package might be needed by a following pbuild, so update
                 # the project repo that it can be installed in as
                 # build-dependency
-- 
2.30.2



More information about the elbe-devel mailing list