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

-=-=-=-=-=-=-=-=-=-=-=-
Links: You receive all messages sent to this group.
View/Reply Online (#247200): 
https://lists.openembedded.org/g/openembedded-core/message/247200
Mute This Topic: https://lists.openembedded.org/mt/121578099/21656
Group Owner: [email protected]
Unsubscribe: https://lists.openembedded.org/g/openembedded-core/unsub 
[[email protected]]
-=-=-=-=-=-=-=-=-=-=-=-

Reply via email to