[4/4] meta: migrate fetcher references to bb.fetch

Message ID 20261104092215.3567061-5-clara.kowalsky@siemens.com
State New
Headers show
Series [1/4] base: replace BitBake's outdated persist_data | expand

Commit Message

Clara Kowalsky Nov. 4, 2026, 9:22 a.m. UTC
BitBake v2.20 includes commit 34ea7cb48090 ("lib: rename fetch2 as
fetch; invert compat shim to make bb.fetch2 = bb.fetch"), which renames
the fetcher API to bb.fetch and keeps bb.fetch2 only for deprecated
compatibility.

In preparation for an update of BitBake in Isar, migrate to bb.fetch to
avoid relying on a deprecated API. The current BitBake v2.8 already
provides bb.fetch as an alias of bb.fetch2, so this change is a pure
rename.

Signed-off-by: Clara Kowalsky <clara.kowalsky@siemens.com>
---
 meta/classes-global/base.bbclass           | 14 +++++++-------
 meta/classes-global/sstate.bbclass         | 14 +++++++-------
 meta/classes-recipe/bootstrap.bbclass      |  4 ++--
 meta/classes-recipe/dpkg-base.bbclass      |  6 +++---
 meta/classes-recipe/dpkg.bbclass           |  2 +-
 meta/conf/bitbake.conf                     |  6 +++---
 meta/lib/aptsrc_fetcher.py                 |  8 ++++----
 meta/lib/container_fetcher.py              | 12 ++++++------
 meta/lib/oe/patch.py                       | 10 +++++-----
 meta/recipes-devtools/base-apt/base-apt.bb |  2 +-
 10 files changed, 39 insertions(+), 39 deletions(-)

Patch

diff --git a/meta/classes-global/base.bbclass b/meta/classes-global/base.bbclass
index c61e59b4..54da1421 100644
--- a/meta/classes-global/base.bbclass
+++ b/meta/classes-global/base.bbclass
@@ -161,7 +161,7 @@  python() {
                 needsrcrev = True
 
     if needsrcrev:
-        d.setVar("SRCPV", "${@bb.fetch2.get_srcrev(d)}")
+        d.setVar("SRCPV", "${@bb.fetch.get_srcrev(d)}")
 
     for e in d.keys():
         flags = d.getVarFlags(e)
@@ -244,9 +244,9 @@  python do_fetch() {
         return
 
     try:
-        fetcher = bb.fetch2.Fetch(src_uri, d)
+        fetcher = bb.fetch.Fetch(src_uri, d)
         fetcher.download()
-    except bb.fetch2.BBFetchException as e:
+    except bb.fetch.BBFetchException as e:
         bb.fatal(str(e))
 }
 
@@ -263,9 +263,9 @@  python do_unpack() {
     rootdir = d.getVar('WORKDIR')
 
     try:
-        fetcher = bb.fetch2.Fetch(src_uri, d)
+        fetcher = bb.fetch.Fetch(src_uri, d)
         fetcher.unpack(rootdir)
-    except bb.fetch2.BBFetchException as e:
+    except bb.fetch.BBFetchException as e:
         bb.fatal(str(e))
 }
 
@@ -314,9 +314,9 @@  python do_cleanall() {
         return
 
     try:
-        fetcher = bb.fetch2.Fetch(src_uri, d)
+        fetcher = bb.fetch.Fetch(src_uri, d)
         fetcher.clean()
-    except bb.fetch2.BBFetchException as e:
+    except bb.fetch.BBFetchException as e:
         bb.fatal(str(e))
 }
 
diff --git a/meta/classes-global/sstate.bbclass b/meta/classes-global/sstate.bbclass
index 76a7b596..4c50f7dd 100644
--- a/meta/classes-global/sstate.bbclass
+++ b/meta/classes-global/sstate.bbclass
@@ -731,7 +731,7 @@  def sstate_package(ss, d):
 sstate_package[vardepsexclude] += "SSTATE_SIG_KEY"
 
 def pstaging_fetch(sstatefetch, d):
-    import bb.fetch2
+    import bb.fetch
 
     # Only try and fetch if the user has configured a mirror
     mirrors = d.getVar('SSTATE_MIRRORS')
@@ -766,11 +766,11 @@  def pstaging_fetch(sstatefetch, d):
         localdata.delVar('SRC_URI')
         localdata.setVar('SRC_URI', srcuri)
         try:
-            fetcher = bb.fetch2.Fetch([srcuri], localdata, cache=False)
+            fetcher = bb.fetch.Fetch([srcuri], localdata, cache=False)
             fetcher.checkstatus()
             fetcher.download()
 
-        except bb.fetch2.BBFetchException:
+        except bb.fetch.BBFetchException:
             pass
 
 def sstate_setscene(d):
@@ -1017,7 +1017,7 @@  def sstate_checkhashes(sq_data, d, siginfo=False, currentcount=0, summary=True,
                 bb.utils.to_boolean(localdata.getVar('SSTATE_MIRROR_ALLOW_NETWORK')):
             localdata.delVar('BB_NO_NETWORK')
 
-        from bb.fetch2 import FetchConnectionCache
+        from bb.fetch import FetchConnectionCache
         def checkstatus_init():
             while not connection_cache_pool.full():
                 connection_cache_pool.put(FetchConnectionCache())
@@ -1039,13 +1039,13 @@  def sstate_checkhashes(sq_data, d, siginfo=False, currentcount=0, summary=True,
             import traceback
 
             try:
-                fetcher = bb.fetch2.Fetch(srcuri.split(), localdata2,
+                fetcher = bb.fetch.Fetch(srcuri.split(), localdata2,
                             connection_cache=connection_cache)
                 fetcher.checkstatus()
                 bb.debug(2, "SState: Successful fetch test for %s" % srcuri)
                 found.add(tid)
                 missed.remove(tid)
-            except bb.fetch2.FetchError as e:
+            except bb.fetch.FetchError as e:
                 bb.debug(2, "SState: Unsuccessful fetch test for %s (%s)\n%s" % (srcuri, repr(e), traceback.format_exc()))
             except Exception as e:
                 bb.error("SState: cannot test %s: %s\n%s" % (srcuri, repr(e), traceback.format_exc()))
@@ -1072,7 +1072,7 @@  def sstate_checkhashes(sq_data, d, siginfo=False, currentcount=0, summary=True,
                 bb.event.fire(bb.event.ProcessStarted(msg, len(tasklist)), d)
 
             # Have to setup the fetcher environment here rather than in each thread as it would race
-            fetcherenv = bb.fetch2.get_fetcher_environment(d)
+            fetcherenv = bb.fetch.get_fetcher_environment(d)
             with bb.utils.environment(**fetcherenv):
                 bb.event.enable_threadlock()
                 import concurrent.futures
diff --git a/meta/classes-recipe/bootstrap.bbclass b/meta/classes-recipe/bootstrap.bbclass
index c1a59fd2..2671602f 100644
--- a/meta/classes-recipe/bootstrap.bbclass
+++ b/meta/classes-recipe/bootstrap.bbclass
@@ -45,12 +45,12 @@  python () {
             distro_bootstrap_keys += own_pub_key.split()
 
     for key in distro_bootstrap_keys:
-        fetcher = bb.fetch2.Fetch([key], d)
+        fetcher = bb.fetch.Fetch([key], d)
         filename = os.path.relpath(fetcher.localpath(key), topdir)
         d.appendVar("DISTRO_BOOTSTRAP_KEYFILES", " ${TOPDIR}/%s" % filename)
 
     for key in third_party_apt_keys:
-        fetcher = bb.fetch2.Fetch([key], d)
+        fetcher = bb.fetch.Fetch([key], d)
         filename = os.path.relpath(fetcher.localpath(key), topdir)
         d.appendVar("THIRD_PARTY_APT_KEYFILES", " ${TOPDIR}/%s" % filename)
 
diff --git a/meta/classes-recipe/dpkg-base.bbclass b/meta/classes-recipe/dpkg-base.bbclass
index 4ec0ddbe..a237af8f 100644
--- a/meta/classes-recipe/dpkg-base.bbclass
+++ b/meta/classes-recipe/dpkg-base.bbclass
@@ -49,7 +49,7 @@  python do_adjust_git() {
 
     for src_uri in (d.getVar("SRC_URI") or "").split():
         try:
-            fetcher = bb.fetch2.Fetch([src_uri], d)
+            fetcher = bb.fetch.Fetch([src_uri], d)
             ud = fetcher.ud[src_uri]
             if ud.type != 'git':
                 continue
@@ -83,7 +83,7 @@  python do_adjust_git() {
                 bb.note(' '.join(cmd))
                 if subprocess.call(cmd) != 0:
                     bb.fatal("git alternates adjustment failed")
-        except bb.fetch2.BBFetchException as e:
+        except bb.fetch.BBFetchException as e:
             bb.fatal(str(e))
 }
 
@@ -94,7 +94,7 @@  inherit patch
 addtask patch after do_adjust_git
 
 python() {
-    from bb.fetch2 import methods
+    from bb.fetch import methods
 
     # apt-src fetcher
     import aptsrc_fetcher
diff --git a/meta/classes-recipe/dpkg.bbclass b/meta/classes-recipe/dpkg.bbclass
index 35408495..737915b8 100644
--- a/meta/classes-recipe/dpkg.bbclass
+++ b/meta/classes-recipe/dpkg.bbclass
@@ -75,7 +75,7 @@  dpkg_runbuild() {
         [ "${var}" = "DEB_BUILD_OPTIONS" ] && continue
 
         # Don't warn environment variables exported to the bitbake fetcher
-        case " ${@" ".join(bb.fetch2.FETCH_EXPORT_VARS)} " in
+        case " ${@" ".join(bb.fetch.FETCH_EXPORT_VARS)} " in
             *" ${var} "*) continue;;
         esac
 
diff --git a/meta/conf/bitbake.conf b/meta/conf/bitbake.conf
index c31719b8..4ffe6d14 100644
--- a/meta/conf/bitbake.conf
+++ b/meta/conf/bitbake.conf
@@ -37,10 +37,10 @@  PR = "${@bb.parse.vars_from_file(d.getVar('FILE', False),d)[2] or 'r0'}"
 PROVIDES = ""
 S = "${WORKDIR}/${P}"
 SRCREV ??= "INVALID"
-AUTOREV = "${@bb.fetch2.get_autorev(d)}"
+AUTOREV = "${@bb.fetch.get_autorev(d)}"
 AUTOREV[vardepvalue] = "${SRCPV}"
 # Set Dynamically in base.bbclass
-# SRCPV = "${@bb.fetch2.get_srcrev(d)}"
+# SRCPV = "${@bb.fetch.get_srcrev(d)}"
 SRCPV[vardepvalue] = "${SRCPV}"
 SRC_URI = ""
 STAMPS_DIR ?= "${TMPDIR}/stamps"
@@ -50,7 +50,7 @@  SVNDIR = "${DL_DIR}/svn"
 T = "${WORKDIR}/temp"
 TMPDIR = "${TOPDIR}/tmp"
 PERSISTENT_DIR = "${TMPDIR}/cache"
-GITPKGV = "${@bb.fetch2.get_srcrev(d, 'gitpkgv_revision')}"
+GITPKGV = "${@bb.fetch.get_srcrev(d, 'gitpkgv_revision')}"
 
 # Isar specific config
 WORKDIR = "${TMPDIR}/work/${DISTRO}-${DISTRO_ARCH}/${PN}/${PV}-${PR}"
diff --git a/meta/lib/aptsrc_fetcher.py b/meta/lib/aptsrc_fetcher.py
index fe8f1cd3..8de86fce 100644
--- a/meta/lib/aptsrc_fetcher.py
+++ b/meta/lib/aptsrc_fetcher.py
@@ -3,10 +3,10 @@ 
 #
 # SPDX-License-Identifier: MIT
 
-from bb.fetch2 import FetchError
-from bb.fetch2 import FetchMethod
-from bb.fetch2 import logger
-from bb.fetch2 import runfetchcmd
+from bb.fetch import FetchError
+from bb.fetch import FetchMethod
+from bb.fetch import logger
+from bb.fetch import runfetchcmd
 import os
 
 class AptSrc(FetchMethod):
diff --git a/meta/lib/container_fetcher.py b/meta/lib/container_fetcher.py
index 52a75ac9..7f9bfdbe 100644
--- a/meta/lib/container_fetcher.py
+++ b/meta/lib/container_fetcher.py
@@ -7,12 +7,12 @@  import oe.path
 import os
 import tempfile
 import json
-from   bb.fetch2 import FetchMethod
-from   bb.fetch2 import logger
-from   bb.fetch2 import MissingChecksumEvent
-from   bb.fetch2 import NoChecksumError
-from   bb.fetch2 import ChecksumError
-from   bb.fetch2 import runfetchcmd
+from   bb.fetch import FetchMethod
+from   bb.fetch import logger
+from   bb.fetch import MissingChecksumEvent
+from   bb.fetch import NoChecksumError
+from   bb.fetch import ChecksumError
+from   bb.fetch import runfetchcmd
 
 class Container(FetchMethod):
     def supports(self, ud, d):
diff --git a/meta/lib/oe/patch.py b/meta/lib/oe/patch.py
index 52c0aa4d..a4dda29b 100644
--- a/meta/lib/oe/patch.py
+++ b/meta/lib/oe/patch.py
@@ -92,14 +92,14 @@  class PatchSet(object):
             if not patch.get("remote"):
                 raise PatchError("Patch file must be specified in patch import.")
             else:
-                patch["file"] = bb.fetch2.localpath(patch["remote"], self.d)
+                patch["file"] = bb.fetch.localpath(patch["remote"], self.d)
 
         for param in PatchSet.defaults:
             if not patch.get(param):
                 patch[param] = PatchSet.defaults[param]
 
         if patch.get("remote"):
-            patch["file"] = self.d.expand(bb.fetch2.localpath(patch["remote"], self.d))
+            patch["file"] = self.d.expand(bb.fetch.localpath(patch["remote"], self.d))
 
         patch["filemd5"] = bb.utils.md5_file(patch["file"])
 
@@ -560,7 +560,7 @@  class GitApplyTree(PatchTree):
             shutil.rmtree(tempdir)
 
     def _need_dirty_check(self):
-        fetch = bb.fetch2.Fetch([], self.d)
+        fetch = bb.fetch.Fetch([], self.d)
         check_dirtyness = False
         for url in fetch.urls:
             url_data = fetch.ud[url]
@@ -778,7 +778,7 @@  class QuiltTree(PatchSet):
             if type == "file":
                 import shutil
                 if not patch.get("file") and patch.get("remote"):
-                    patch["file"] = bb.fetch2.localpath(patch["remote"], self.d)
+                    patch["file"] = bb.fetch.localpath(patch["remote"], self.d)
 
                 shutil.copyfile(patch["quiltfile"], patch["file"])
             else:
@@ -908,7 +908,7 @@  def patch_path(url, fetch, workdir, expand=True):
 
 def src_patches(d, all=False, expand=True):
     workdir = d.getVar('WORKDIR')
-    fetch = bb.fetch2.Fetch([], d)
+    fetch = bb.fetch.Fetch([], d)
     patches = []
     sources = []
     for url in fetch.urls:
diff --git a/meta/recipes-devtools/base-apt/base-apt.bb b/meta/recipes-devtools/base-apt/base-apt.bb
index 97e3ae16..d54786ec 100644
--- a/meta/recipes-devtools/base-apt/base-apt.bb
+++ b/meta/recipes-devtools/base-apt/base-apt.bb
@@ -81,7 +81,7 @@  python do_cache() {
 
     for key in d.getVar('BASE_REPO_KEY').split():
         d.appendVar("SRC_URI", " %s" % key)
-        fetcher = bb.fetch2.Fetch([key], d)
+        fetcher = bb.fetch.Fetch([key], d)
         filename = fetcher.localpath(key)
         d.appendVar("KEYFILES", " %s" % filename)