Skip to contentSkip to conversation

sstate: Fix sstate mirrors with BB_FETCH_PREMIRRORONLY

PATCH In review [email protected] 2 participants 2 messages Feb 10, 2025 – Feb 20, 2025

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 sstate: Fix sstate mirrors with BB_FETCH_PREMIRRORONLY

From: Julian Haller <[email protected]>

In case BB_FETCH_PREMIRRORONLY is set, the fetcher.download() function sets BB_NO_NETWORK = "1" after downloading the first file. This alters the precondition for the second and third loop run, disallowing network access entirely. As a consequence, the .siginfo and .sig files can never be downloaded.

Fix this by creating a new copy of localdata for each loop run.

Alternative solutions would be:
- Setting BB_FETCH_PREMIRRORONLY = "0" in localdata
- Setting BB_NO_NETWORK = "0" in each loop run

Both alternatives are highly dependent on the concrete implementation of the fetcher function, thus making them likely to break in the future.

---
 meta/classes-global/sstate.bbclass | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)
meta/classes-global/sstate.bbclass +4 -3
index 2c259a6657..eb988b2ca8 100644
@@ -747,10 +747,11 @@ def pstaging_fetch(sstatefetch, d):
         uris += ['file://{0}.sig;downloadfilename={0}.sig'.format(sstatefetch)]
 
     for srcuri in uris:
-        localdata.delVar('SRC_URI')
-        localdata.setVar('SRC_URI', srcuri)
+        localdata2 = bb.data.createCopy(localdata)
+        localdata2.delVar('SRC_URI')
+        localdata2.setVar('SRC_URI', srcuri)
         try:
-            fetcher = bb.fetch2.Fetch([srcuri], localdata, cache=False)
+            fetcher = bb.fetch2.Fetch([srcuri], localdata2, cache=False)
             fetcher.checkstatus()
             fetcher.download()
 
Signature · 1 line
2.43.0
#1 lore raw
Quoted 14 lines · Julian Haller via lists.openembedded.org

From: Julian Haller <[email protected]>

In case BB_FETCH_PREMIRRORONLY is set, the fetcher.download() function sets BB_NO_NETWORK = "1" after downloading the first file. This alters the precondition for the second and third loop run, disallowing network access entirely. As a consequence, the .siginfo and .sig files can never be downloaded.

Fix this by creating a new copy of localdata for each loop run.

Alternative solutions would be:
- Setting BB_FETCH_PREMIRRORONLY = "0" in localdata
- Setting BB_NO_NETWORK = "0" in each loop run

Quoted 8 lines

Both alternatives are highly dependent on the concrete implementation of the fetcher function, thus making them likely to break in the future.

---
 meta/classes-global/sstate.bbclass | 7 ++++---

 1 file changed, 4 insertions(+), 3 deletions(-)

Thanks for the patch and raising this.

Having looked at the code, I think that rather than working around it, we need to fix this in bitbake properly. I've copied you on such a patch, testing/review would be appreciated.

Thanks,

Richard