Bug 13697

Summary: Regression due to "fetch2: Ensure cached url data is matched to a datastore" patch
Product: [Build System, Metadata & Runtime] BitBake Reporter: Enrico Scholz <enrico.scholz>
Component: bitbakeAssignee: Richard Purdie <richard.purdie>
Status: RESOLVED NOTABUG QA Contact:
Severity: normal    
Priority: Medium+ CC: poky.bs.watcher, poky.watcher
Version: unspecified   
Target Milestone: 3.1 M4   
Hardware: x86   
OS: Multiple   
Whiteboard:
OS type for building Yocto: --- Type of Regression: ---
Verified: Documentation change: Don't know

Description Enrico Scholz 2019-12-10 14:54:52 UTC
The "fetch2: Ensure cached url data is matched to a datastore" patch (e.g. 4ce50bbd34eefeabfeca89a6a66c71598d3c58f6 in 1.42 branch) causes regressions in recipes which call `bb.fetch2.Fetch()` in early stages.

E.g.

------
LICENSE = "CLOSED"

SRC_URI = "file://foo;name=bootsplash"

def _find_bootsplash(d):
    fetch = bb.fetch2.Fetch([], d)
    for url in fetch.urls:
        urldata = fetch.ud[url]
        parm = urldata.parm
        if parm.get('name') == 'bootsplash':
            return urldata

    raise Exception("no bootsplash")

def get_bootsplash_convert(d):
    uri = _find_bootsplash(d)

    if not uri.localpath:
        # happens in early parsing stage; skip further processing
        return None

    ## construct an image magick command to rotate/scale bootsplash
    ## ...

    return "true"

LOGO_CONVERT_CMD = "${@get_bootsplash_convert(d)}"

do_unpack[postfuncs] += "do_logo_preprocess do_unpack_logo"

do_logo_preprocess() {
    ${LOGO_CONVERT_CMD}
    false
}
---------

fails after this patch but worked before.
Comment 1 Richard Purdie 2020-03-27 14:38:38 UTC
Sorry about the delay in getting to this. The issue is actually an API one.

The API is that for localpath to be valid, you need to call:

        urldata = fetch.ud[url]
        urldata.setup_localpath(d)

and your example doesn't.

In previous code you got a cached object that had this called already, with the patch applied, you no longer get the cached object and therefore need the call.