]> code.ossystems Code Review - openembedded-core.git/commitdiff
classes/crate-fetch: Ensure crate fetcher is available
authorJoshua Watt <JPEWhacker@gmail.com>
Fri, 19 Nov 2021 02:12:49 +0000 (20:12 -0600)
committerRichard Purdie <richard.purdie@linuxfoundation.org>
Tue, 23 Nov 2021 10:53:12 +0000 (10:53 +0000)
Reworks the crate fetcher class to have it install the fetcher at recipe
finalization so that it is always available before SRC_URI is expanded.
In addition, override the value of SRCPV to also install the fetcher
when SRCPV is expanded so that AUTOREV works.

[YOCTO #10867]

Signed-off-by: Joshua Watt <JPEWhacker@gmail.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
meta/classes/crate-fetch.bbclass

index c0ed434a96e55b5f59842d53310af7e4de110b94..a7fa22b2a06c8f5bf5a055a0f50a5dbbbce0b8f3 100644 (file)
@@ -7,7 +7,22 @@
 # crate://<packagename>/<version>
 #
 
-python () {
-        import crate
-        bb.fetch2.methods.append( crate.Crate() )
+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)
+    return bb.fetch2.get_srcrev(d)
+
+# Override SRCPV to make sure it imports the fetcher first
+SRCPV = "${@crate_get_srcrev(d)}"