* gitsm fetcher fails when `PREMIRRORS_ONLY` is set
@ 2026-11-19 14:13 tiago.mlb.vasconcelos
2026-11-20 22:16 ` [bitbake-devel] " Richard Purdie
0 siblings, 1 reply; 5+ messages in thread
From: tiago.mlb.vasconcelos @ 2026-11-19 14:13 UTC (permalink / raw)
To: bitbake-devel
[-- Attachment #1: Type: text/plain, Size: 2938 bytes --]
Hi all,
I have encountered a gitsm submodule fetch failure that appears to be
related to the following change:
https://lists.openembedded.org/g/bitbake-devel/message/17506
This change prevents Git fetcher to silently contact upstream
despite BB_FETCH_PREMIRRORONLY being enabled.
However, for gitsm, this datastore is also passed to the nested submodule
Fetch. The submodule therefore inherits BB_NO_NETWORK = "1", blocking its
HTTP PREMIRROR download, even though the parent repository was downloaded from
the same PREMIRROR:
The resulting error is:
gitsm: submodule download failed: NetworkAccess Network access disabled
through BB_NO_NETWORK (or set indirectly due to use of
BB_FETCH_PREMIRRORONLY) but access requested with command wget ...
I have considered the following approaches. The snippets below are
illustrative examples, not complete patches.
*
Reset BB_NO_NETWORK in gitsm's download_submodule() at:
https://git.openembedded.org/bitbake/tree/lib/bb/fetch/gitsm.py#n212
Before creating the nested Fetch instance:
if bb.utils.to_boolean(d.getVar("BB_FETCH_PREMIRRORONLY")):
d.setVar("BB_NO_NETWORK", "0")
try:
newfetch = Fetch([url], d, cache=False)
newfetch.download()
except Exception as e:
logger.error(
'gitsm: submodule download failed: %s %s'
% (type(e).__name__, str(e))
)
raise
This allows the submodule to access the HTTP PREMIRROR.
*
Scope the restriction more narrowly:
https://git.openembedded.org/bitbake/tree/lib/bb/fetch/__init__.py#n1160
Instead of passing the modified BB_NO_NETWORK = "1" value to nested
submodule fetches, apply the restriction specifically to the Git
operations.
*
Preserve and restore the original BB_NO_NETWORK value at:
https://git.openembedded.org/bitbake/tree/lib/bb/fetch/__init__.py#n1157
In try_mirror_url(), preserve the original value before applying
the temporary restriction:
network = ld.getVarFlag("BB_NO_NETWORK", "original_bb_no_network")
if network is None:
network = ld.getVar("BB_NO_NETWORK") or "0"
ld.setVarFlag(
"BB_NO_NETWORK", "original_bb_no_network", network
)
Restore that value before downloading from the mirror:
if not verify_donestamp(ud, ld, origud) or ud.method.need_update(ud, ld):
if bb.utils.to_boolean(ld.getVar("BB_FETCH_PREMIRRORONLY")):
ld.setVar("BB_NO_NETWORK", network)
ud.method.download(ud, ld)
if hasattr(ud.method, "build_mirror_data"):
ud.method.build_mirror_data(ud, ld)
The intention is to distinguish the user's original network policy
from the temporary restriction applied during mirror processing.
The intended behaviour is to allow both the parent repository and its
submodules to be fetched from configured PREMIRRORS, without permitting
upstream access.
I would appreciate your thoughts on these approaches.
Best regards,
Tiago Vasconcelos
[-- Attachment #2: Type: text/html, Size: 3709 bytes --]
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [bitbake-devel] gitsm fetcher fails when `PREMIRRORS_ONLY` is set
2026-11-19 14:13 gitsm fetcher fails when `PREMIRRORS_ONLY` is set tiago.mlb.vasconcelos
@ 2026-11-20 22:16 ` Richard Purdie
2026-11-23 10:35 ` tiago.mlb.vasconcelos
0 siblings, 1 reply; 5+ messages in thread
From: Richard Purdie @ 2026-11-20 22:16 UTC (permalink / raw)
To: tiago.mlb.vasconcelos, bitbake-devel
On Thu, 2026-11-19 at 06:13 -0800, tiago.mlb.vasconcelos via bitbake-devel wrote:
> I have encountered a gitsm submodule fetch failure that appears to be
> related to the following change:
> https://lists.openembedded.org/g/bitbake-devel/message/17506
> This change prevents Git fetcher to silently contact upstream
> despite BB_FETCH_PREMIRRORONLY being enabled.
> However, for gitsm, this datastore is also passed to the nested
> submodule
> Fetch. The submodule therefore inherits BB_NO_NETWORK = "1", blocking
> its
> HTTP PREMIRROR download, even though the parent repository was
> downloaded from
> the same PREMIRROR:
The best advice I can give is to write a new test case for bitbake-
selftest (in lib/bb/tests/fetch.py) which shows the issue you're
seeing.
Once we have that, we can likely more easily understand it and try and
come up with a solution.
Cheers,
Richard
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: gitsm fetcher fails when `PREMIRRORS_ONLY` is set
2026-11-20 22:16 ` [bitbake-devel] " Richard Purdie
@ 2026-11-23 10:35 ` tiago.mlb.vasconcelos
2026-11-25 18:13 ` tiago.mlb.vasconcelos
0 siblings, 1 reply; 5+ messages in thread
From: tiago.mlb.vasconcelos @ 2026-11-23 10:35 UTC (permalink / raw)
To: bitbake-devel
[-- Attachment #1: Type: text/plain, Size: 6852 bytes --]
Hi Richard,
Thank you for the feedback. Below are new bitbake-selftest cases in
lib/bb/tests/fetch.py that show the issue, together with a possible fix.
Without the gitsm.py change, `test_submodule_premirroronly` and
`test_shallow_submodule_premirroronly` will fail:
Signed-off-by: Tiago Vasconcelos <tiago.mlb.vasconcelos@gmail.com>
---
diff --git a/lib/bb/fetch2/gitsm.py b/lib/bb/fetch2/gitsm.py
index 5869e1b99..727462ea3 100644
--- a/lib/bb/fetch2/gitsm.py
+++ b/lib/bb/fetch2/gitsm.py
@@ -194,6 +194,12 @@ class GitSM(Git):
# Is the following still needed?
#url += ";nocheckout=1"
+ # BB_NO_NETWORK may have been set by the parent fetch for its mirror
+ # tarball. The submodule Fetch applies BB_FETCH_PREMIRRORONLY itself,
+ # blocking upstream but still allowing PREMIRRORS.
+ if bb.utils.to_boolean(d.getVar("BB_FETCH_PREMIRRORONLY")):
+ d.setVar("BB_NO_NETWORK", "0")
+
try:
newfetch = Fetch([url], d, cache=False)
newfetch.download()
diff --git a/lib/bb/tests/fetch.py b/lib/bb/tests/fetch.py
index cc133c1f5..106643d82 100644
--- a/lib/bb/tests/fetch.py
+++ b/lib/bb/tests/fetch.py
@@ -2092,6 +2092,102 @@ class GitShallowTest(FetcherTest):
# Verify the submodule is also shallow
self.assertRevCount(1, cwd=os.path.join(self.gitdir, 'gitsubmodule'))
+ def use_http_premirror(self, mirrordir):
+ # Serve the prepared downloads locally and allow this host in mirror-only mode.
+ server = HTTPService(mirrordir, host='127.0.0.1')
+ server.start()
+ self.addCleanup(server.stop)
+ self.d.setVar('PREMIRRORS', 'gitsm://.*/.* http://127.0.0.1:%s/' % server.port)
+ self.d.setVar('BB_FETCH_PREMIRRORONLY', '1')
+ self.d.setVar('BB_NO_NETWORK', '0')
+ self.d.setVar('BB_ALLOWED_NETWORKS', '127.0.0.1')
+
+ def check_submodule_premirroronly(self, shallow):
+ if not shallow:
+ self.d.setVar('BB_GIT_SHALLOW', '0')
+ self.d.setVar('BB_GENERATE_MIRROR_TARBALLS', '1')
+ self.d.setVar('BB_GENERATE_SHALLOW_TARBALLS', '0')
+
+ # Create a submodule with two commits so its fetched history can be checked.
+ self.add_empty_file('a')
+ self.add_empty_file('b')
+
+ smdir = os.path.join(self.tempdir, 'gitsubmodule')
+ bb.utils.mkdirhier(smdir)
+ self.git_init(cwd=smdir)
+ # Make this look like it was cloned from a remote...
+ self.git('config --add remote.origin.url "%s"' % smdir, cwd=smdir)
+ self.git('config --add remote.origin.fetch "+refs/heads/*:refs/remotes/origin/*"', cwd=smdir)
+ self.add_empty_file('asub', cwd=smdir)
+ self.add_empty_file('bsub', cwd=smdir)
+
+ self.git('submodule init', cwd=self.srcdir)
+ self.git('-c protocol.file.allow=always submodule add file://%s' % smdir, cwd=self.srcdir)
+ self.git('submodule update', cwd=self.srcdir)
+ self.git('commit -m submodule -a', cwd=self.srcdir)
+
+ uri = 'gitsm://%s;protocol=file;subdir=${S};branch=master' % self.srcdir
+
+ # Fetch once to generate the mirror tarballs
+ self.fetch(uri)
+
+ # Stop generating tarballs during the mirror-only fetch.
+ self.d.setVar('BB_GENERATE_MIRROR_TARBALLS', '0')
+ self.d.setVar('BB_GENERATE_SHALLOW_TARBALLS', '0')
+ mirrordir = os.path.join(self.tempdir, 'mirror')
+ bb.utils.rename(self.dldir, mirrordir)
+ bb.utils.mkdirhier(self.dldir)
+ # Remove the original repositories so the fetch must use the premirror.
+ bb.utils.remove(self.gitdir, recurse=True)
+ bb.utils.remove(self.srcdir, recurse=True)
+ bb.utils.remove(smdir, recurse=True)
+
+ self.use_http_premirror(mirrordir)
+ self.fetch_and_unpack(uri)
+
+ # Shallow fetches retain only the tip commit; full fetches retain all commits.
+ expected_revisions = 1 if shallow else 3
+ self.assertRevCount(expected_revisions)
+ self.assertTrue(os.listdir(os.path.join(self.gitdir, 'gitsubmodule')))
+ expected_submodule_revisions = 1 if shallow else 2
+ self.assertRevCount(expected_submodule_revisions, cwd=os.path.join(self.gitdir, 'gitsubmodule'))
+
+ def test_submodule_premirroronly(self):
+ """Submodules must be fetched from a network PREMIRRORS with BB_FETCH_PREMIRRORONLY"""
+ self.check_submodule_premirroronly(shallow=False)
+
+ def test_shallow_submodule_premirroronly(self):
+ """Shallow submodules must be fetched from a network PREMIRRORS with BB_FETCH_PREMIRRORONLY"""
+ self.check_submodule_premirroronly(shallow=True)
+
+ def test_submodule_premirroronly_no_upstream(self):
+ """A submodule missing from PREMIRRORS must not be fetched from upstream"""
+ self.add_empty_file('a')
+ sha = self.git('rev-parse HEAD', cwd=self.srcdir).strip()
+ # Point the submodule at an unavailable upstream and add its gitlink to the parent.
+ with open(os.path.join(self.srcdir, '.gitmodules'), 'w') as f:
+ f.write('[submodule "sub"]\n\tpath = sub\n\turl = https://git.invalid/sub.git\n')
+ self.git('add .gitmodules', cwd=self.srcdir)
+ self.git('update-index --add --cacheinfo 160000,%s,sub' % sha, cwd=self.srcdir)
+ self.git('commit -m submodule', cwd=self.srcdir)
+
+ self.d.setVar('BB_GIT_SHALLOW', '0')
+ self.d.setVar('BB_GENERATE_MIRROR_TARBALLS', '1')
+ self.d.setVar('BB_GENERATE_SHALLOW_TARBALLS', '0')
+
+ _, ud = self.fetch('git://%s;protocol=file;branch=master' % self.srcdir)
+ mirrordir = os.path.join(self.tempdir, 'mirror')
+ bb.utils.rename(self.dldir, mirrordir)
+ self.d.setVar('BB_GENERATE_MIRROR_TARBALLS', '0')
+ bb.utils.remove(self.srcdir, recurse=True)
+ bb.utils.mkdirhier(self.dldir)
+
+ self.use_http_premirror(mirrordir)
+ # The missing submodule premirror must fail instead of falling back to upstream.
+ with self.assertRaises(bb.fetch2.NetworkAccess) as cm:
+ self.fetch('gitsm://%s;protocol=file;subdir=${S};branch=master' % self.srcdir)
+ self.assertIn('git.invalid', cm.exception.url)
+
if any(os.path.exists(os.path.join(p, 'git-annex')) for p in os.environ.get('PATH').split(':')):
def test_shallow_annex(self):
self.add_empty_file('a')
[-- Attachment #2: Type: text/html, Size: 9270 bytes --]
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: gitsm fetcher fails when `PREMIRRORS_ONLY` is set
2026-11-23 10:35 ` tiago.mlb.vasconcelos
@ 2026-11-25 18:13 ` tiago.mlb.vasconcelos
2026-11-26 11:43 ` [bitbake-devel] " Richard Purdie
0 siblings, 1 reply; 5+ messages in thread
From: tiago.mlb.vasconcelos @ 2026-11-25 18:13 UTC (permalink / raw)
To: bitbake-devel
[-- Attachment #1: Type: text/plain, Size: 139 bytes --]
Hi all.
Is there any extra information I can provide to help solve this issue?
Looking forward to hear from you,
Tiago Vasconcelos
[-- Attachment #2: Type: text/html, Size: 217 bytes --]
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [bitbake-devel] gitsm fetcher fails when `PREMIRRORS_ONLY` is set
2026-11-25 18:13 ` tiago.mlb.vasconcelos
@ 2026-11-26 11:43 ` Richard Purdie
0 siblings, 0 replies; 5+ messages in thread
From: Richard Purdie @ 2026-11-26 11:43 UTC (permalink / raw)
To: tiago.mlb.vasconcelos, bitbake-devel
On Wed, 2026-11-25 at 10:13 -0800, tiago.mlb.vasconcelos via bitbake-devel wrote:
> Is there any extra information I can provide to help solve this
> issue?
I'm in the middle of implementing some major architecture changes and I
need to think really carefully about those so I'm afraid this kind of
change is taking a lower priority for me right now. We don't have many
other people with the review bandwidth for gitsm.
I appreciate this isn't the answer you'd like :/.
I did see your test case and really appreciate having it as when I do
find time to look at this, it will help a lot.
Cheers,
Richard
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2026-11-26 11:43 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-19 14:13 gitsm fetcher fails when `PREMIRRORS_ONLY` is set tiago.mlb.vasconcelos
2026-11-20 22:16 ` [bitbake-devel] " Richard Purdie
2026-11-23 10:35 ` tiago.mlb.vasconcelos
2026-11-25 18:13 ` tiago.mlb.vasconcelos
2026-11-26 11:43 ` [bitbake-devel] " Richard Purdie
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.