[RFC,10/12] apt-fetcher: prepare for chroot specific fetching

Message ID 20260218115827.3947145-11-felix.moessbauer@siemens.com
State New
Headers show
Series add support to build isar unprivileged | expand

Commit Message

MOESSBAUER, Felix Feb. 18, 2026, 11:58 a.m. UTC
The implementation of the fetching depends on the chroot mode (e.g.
schroot or unshare). As a preparation for the unshare mode, we hide the
concrete fetcher implementation behind a factory, so that we will be
able to dispatch based on the mode.

Signed-off-by: Felix Moessbauer <felix.moessbauer@siemens.com>
---
 meta/classes-recipe/dpkg-base.bbclass |  2 +-
 meta/lib/aptsrc_fetcher.py            | 12 +++++++++---
 2 files changed, 10 insertions(+), 4 deletions(-)

Patch

diff --git a/meta/classes-recipe/dpkg-base.bbclass b/meta/classes-recipe/dpkg-base.bbclass
index df3dd1fd..5841d6ee 100644
--- a/meta/classes-recipe/dpkg-base.bbclass
+++ b/meta/classes-recipe/dpkg-base.bbclass
@@ -84,7 +84,7 @@  python() {
 
     # apt-src fetcher
     import aptsrc_fetcher
-    methods.append(aptsrc_fetcher.AptSrc())
+    methods.append(aptsrc_fetcher.AptSrc.create(d))
 
     src_uri = (d.getVar('SRC_URI', False) or "").split()
     for u in src_uri:
diff --git a/meta/lib/aptsrc_fetcher.py b/meta/lib/aptsrc_fetcher.py
index dfa784a9..37c84fa7 100644
--- a/meta/lib/aptsrc_fetcher.py
+++ b/meta/lib/aptsrc_fetcher.py
@@ -9,6 +9,10 @@  from bb.fetch2 import logger
 from bb.fetch2 import runfetchcmd
 
 class AptSrc(FetchMethod):
+    @classmethod
+    def create(cls, d):
+        return AptSrcSchroot()
+
     def supports(self, ud, d):
         return ud.type in ['apt']
 
@@ -20,6 +24,11 @@  class AptSrc(FetchMethod):
         codename = d.getVar('BASE_DISTRO_CODENAME')
         ud.localfile='deb-src/' + base_distro + '-' + codename + '/' + ud.host
 
+    def clean(self, ud, d):
+        bb.utils.remove(ud.localpath, recurse=True)
+
+
+class AptSrcSchroot(AptSrc):
     def download(self, ud, d):
         bb.utils.exec_flat_python_func('isar_export_proxies', d)
         bb.build.exec_func('schroot_create_configs', d)
@@ -83,6 +92,3 @@  class AptSrc(FetchMethod):
         finally:
             runfetchcmd(f'schroot -q -f -e -c {session_id}', d)
             bb.build.exec_func('schroot_delete_configs', d)
-
-    def clean(self, ud, d):
-        bb.utils.remove(ud.localpath, recurse=True)