Skip to contentSkip to conversation

crate-fetch: fix setscene failures

PATCH New Anuj Mittal 1 participant 1 message Mar 24, 2022

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 crate-fetch: fix setscene failures

From: Richard Purdie <[email protected]>

In sstate.bbclass, when fetching an sstate object we have:

pstaging_fetch(sstatefetch, d):
[...]
localdata.setVar('SRCPV', d.getVar('SRCPV'))

i.e. some code which expands SRCPV before it changes SRC_URI for the sstate tarball fetching. In crate-fetch.bbclass we have:

def import_crate(d):
import crate
if not getattr(crate, 'imported', False):
bb.fetch2.methods.append(crate.Crate())
crate.imported = True

def crate_get_srcrev(d):
import_crate(d)
return bb.fetch2.get_srcrev(d)

SRCPV = "${@crate_get_srcrev(d)}"

and so an "import crate" occurs when pstating_fetch() is called. That succeeds and all is well but the bb.fetch2.get_srcrev(d) call fails since there is no url in SRC_URI which supports srcrev() resulting in:

| WARNING: rust-cross-core2-32-musl-1.54.0-r0 do_deploy_source_date_epoch_setscene: ExpansionError('SRCPV', '${@crate_get_srcrev(d)}', FetchError('SRCREV was used yet no valid SCM was found in SRC_URI', None))
| WARNING: Logfile for failed setscene task is /home/pokybuild/yocto-worker/musl-qemux86/build/build/tmp/work/x86_64-linux/rust-cross-core2-32-musl/1.54.0-r0/temp/log.do_deploy_source_date_epoch_setscene.3133099
| WARNING: Setscene task (/home/pokybuild/yocto-worker/musl-qemux86/build/meta/recipes-devtools/rust/rust-cross_1.54.0.bb:do_deploy_source_date_epoch_setscene) failed with exit code '1' - real task will be run instead
---
 meta/classes/crate-fetch.bbclass | 3 +++
 1 file changed, 3 insertions(+)
meta/classes/crate-fetch.bbclass +3 -0
index a7fa22b2a0..04d76c0de8 100644
@@ -22,6 +22,9 @@ crate_import_handler[eventmask] = "bb.event.RecipePreFinalise"
 
 def crate_get_srcrev(d):
     import_crate(d)
+    srcuri = d.getVar("SRC_URI")
+    if "crate://" not in srcuri and "git://" not in srcuri:
+        return "Invalid"
     return bb.fetch2.get_srcrev(d)
 
 # Override SRCPV to make sure it imports the fetcher first
Signature · 1 line
2.35.1