Hi Richard, Sorry for the late reply. Patch v2 (Proposed fix) addresses the concern with the previous approach: it no longer copies the datastore or rewrites SRC_URI during package version calculation.
Instead, externalsrc saves the formatted source-version suffix in EXTERNALSRC_PKGV_SUFFIX before filtering SCM URLs. The package and PR-service paths reuse it, while the normal fetcher path remains unchanged for non-externalsrc builds. Validation used git-submodule-test for both requested transitions: BitBake to devtool: both builds produce the same hash-bearing PKGV and no version-going-backwards QA error. devtool to BitBake: both builds produce the same PKGV with no regression in the reverse transition. Changes since v1: - replace the copied datastore/SRC_URI override with a saved suffix; - use the suffix for both PKGV and AUTOINC PR-service handling. [PATCH v2 1/1] externalsrc: preserve source revision in PKGV externalsrc removes SCM URLs from SRC_URI before packaging, so the packaging fetcher cannot derive the source revision for devtool builds. Capture the formatted source-version suffix before filtering and reuse it for package version and AUTOINC PR-service handling. This keeps the normal fetcher path unchanged and avoids restoring a copied datastore. Signed-off-by: Paddy Chiu <[email protected]> --- meta/classes-global/package.bbclass | 8 ++++++-- meta/classes/externalsrc.bbclass | 3 +++ 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/meta/classes-global/package.bbclass b/meta/classes-global/package.bbclass index 67148fc1ac..f57397e83d 100644 --- a/meta/classes-global/package.bbclass +++ b/meta/classes-global/package.bbclass @@ -299,7 +299,9 @@ python package_get_auto_pr() { pr = d.getVar('PR') # Strip PR to make AUTOINC can increase when SRCREV is changed base_ver = "AUTOINC-%s" % version[:-len(pr)] - srcpv = bb.fetch2.get_srcrev(d) + srcpv = d.getVar("EXTERNALSRC_PKGV_SUFFIX") + if srcpv is None: + srcpv = bb.fetch2.get_srcrev(d) value = conn.getPR(base_ver, pkgarch, srcpv) d.setVar("PRSERV_PV_AUTOINC", str(value)) @@ -319,7 +321,9 @@ python package_get_auto_pr() { python package_setup_pkgv() { pkgv = d.getVar("PKGV") # Expand SRCPV into PKGV if not present - srcpv = bb.fetch.get_pkgv_string(d) + srcpv = d.getVar("EXTERNALSRC_PKGV_SUFFIX") + if srcpv is None: + srcpv = bb.fetch.get_pkgv_string(d) if srcpv and "+" in pkgv: d.appendVar("PKGV", srcpv) pkgv = d.getVar("PKGV") diff --git a/meta/classes/externalsrc.bbclass b/meta/classes/externalsrc.bbclass index 902ff2604f..47c1b06788 100644 --- a/meta/classes/externalsrc.bbclass +++ b/meta/classes/externalsrc.bbclass @@ -78,6 +78,9 @@ python () { d.setVar('B', '${WORKDIR}/${BPN}-${PV}') bb.fetch.get_hashvalue(d) + # Keep the source version available for packaging. SCM URLs are removed + # below so externalsrc does not fetch or unpack the external source. + d.setVar('EXTERNALSRC_PKGV_SUFFIX', bb.fetch.get_pkgv_string(d)) local_srcuri = [] fetch = bb.fetch2.Fetch((d.getVar('SRC_URI') or '').split(), d) for url in fetch.urls: -- 2.34.1 Please let me know if further changes or discussion are needed. Best Regards, Paddy On Wed, Sep 23, 2026 at 10:08 PM Richard Purdie < [email protected]> wrote: > On Tue, 2026-09-22 at 02:20 -0700, Paddy Chiu via lists.openembedded.org > wrote: > > Without this fix, PKGV will be the same as PV when using devtool build. > > Since SRC_URI is set to local_srcuri in externalsrc.bbclass and > consequently cause missing git commit hash in PKGV. > > This fix can prevent buildhistory package-version QA failures in devtool > build. > > --- > > meta/classes-global/package.bbclass | 12 ++++++++++-- > > meta/classes/externalsrc.bbclass | 4 ++++ > > 2 files changed, 14 insertions(+), 2 deletions(-) > > > > diff --git a/meta/classes-global/package.bbclass > b/meta/classes-global/package.bbclass > > index 67148fc1ac..c5f8b2136f 100644 > > --- a/meta/classes-global/package.bbclass > > +++ b/meta/classes-global/package.bbclass > > @@ -242,6 +242,14 @@ python () { > > d.appendVarFlag('do_package', 'deptask', " do_packagedata") > > } > > > > +def package_get_srcdata(d): > > + srcuri = d.getVar("EXTERNALSRC_ORIG_SRC_URI") > > + if not srcuri: > > + return d > > + > > + srcdata = d.createCopy() > > + srcdata.setVar("SRC_URI", srcuri) > > + return srcdata > > > > PRSERV_ACTIVE = "${@bool(d.getVar("PRSERV_HOST"))}" > > PRSERV_ACTIVE[vardepvalue] = "${PRSERV_ACTIVE}" > > @@ -299,7 +307,7 @@ python package_get_auto_pr() { > > pr = d.getVar('PR') > > # Strip PR to make AUTOINC can increase when SRCREV is > changed > > base_ver = "AUTOINC-%s" % version[:-len(pr)] > > - srcpv = bb.fetch2.get_srcrev(d) > > + srcpv = bb.fetch2.get_srcrev(package_get_srcdata(d)) > > value = conn.getPR(base_ver, pkgarch, srcpv) > > d.setVar("PRSERV_PV_AUTOINC", str(value)) > > > > @@ -319,7 +327,7 @@ python package_get_auto_pr() { > > python package_setup_pkgv() { > > pkgv = d.getVar("PKGV") > > # Expand SRCPV into PKGV if not present > > - srcpv = bb.fetch.get_pkgv_string(d) > > + srcpv = bb.fetch.get_pkgv_string(package_get_srcdata(d)) > > if srcpv and "+" in pkgv: > > d.appendVar("PKGV", srcpv) > > pkgv = d.getVar("PKGV") > > diff --git a/meta/classes/externalsrc.bbclass > b/meta/classes/externalsrc.bbclass > > index 902ff2604f..a1bb92a418 100644 > > --- a/meta/classes/externalsrc.bbclass > > +++ b/meta/classes/externalsrc.bbclass > > @@ -78,6 +78,10 @@ python () { > > d.setVar('B', '${WORKDIR}/${BPN}-${PV}') > > > > bb.fetch.get_hashvalue(d) > > + # Keep the original URI available for packaging. SCM URLs are > removed > > + # below so externalsrc does not fetch or unpack the external > source, > > + # but package_setup_pkgv() still needs them to derive PKGV. > > + d.setVar('EXTERNALSRC_ORIG_SRC_URI', d.getVar('SRC_URI')) > > local_srcuri = [] > > fetch = bb.fetch2.Fetch((d.getVar('SRC_URI') or '').split(), d) > > for url in fetch.urls: > > > We really need to find a different way to fix this. I don't doubt there > is an issue here but change the datastore and it's variables around mid > function like that is really a hacky workaround, not a proper fix. > > If we did this each time we found a bug, the code would become > unmaintainable. > > Cheers, > > Richard >
-=-=-=-=-=-=-=-=-=-=-=- Links: You receive all messages sent to this group. View/Reply Online (#247202): https://lists.openembedded.org/g/openembedded-core/message/247202 Mute This Topic: https://lists.openembedded.org/mt/121372440/21656 Group Owner: [email protected] Unsubscribe: https://lists.openembedded.org/g/openembedded-core/unsub [[email protected]] -=-=-=-=-=-=-=-=-=-=-=-
