Files
poky/meta/classes/crate-fetch.bbclass
Anuj Mittal d8cd104e66 crate-fetch: fix setscene failures
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

[YOCTO #14680]

(From OE-Core rev: 73b6c53ceea30a3f81c6de88c5bea452fe1c0018)

Signed-off-by: Anuj Mittal <anuj.mittal@intel.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2022-03-24 11:05:16 +00:00

32 lines
771 B
Plaintext

#
# crate-fetch class
#
# Registers 'crate' method for Bitbake fetch2.
#
# Adds support for following format in recipe SRC_URI:
# crate://<packagename>/<version>
#
def import_crate(d):
import crate
if not getattr(crate, 'imported', False):
bb.fetch2.methods.append(crate.Crate())
crate.imported = True
python crate_import_handler() {
import_crate(d)
}
addhandler crate_import_handler
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
SRCPV = "${@crate_get_srcrev(d)}"