Skip to contentSkip to conversation

classes: add gitupstream class

RFC PATCH In review Ross Burton 1 participant 2 messages Nov 17, 2016

lore
Share & tools
lore
#0 lore raw

RFC PATCH 1/1 classes: add gitupstream class

This class lets you use BBCLASSEXTEND to add a variant of the recipe that fetches from git instead of a tarball.

For example:

BBCLASSEXTEND = "gitupstream" SRC_URI_class-gitupstream = "git://git.example.com/example" SRCREV_class-gitupstream = "abcd1234"

This variant will have DEFAULT_PREFERENCE set to -1 so it needs to be selected to be used, and any git-specific tweaks can be done with the class-gitupstream override, for example:

DEPENDS_append_class-gitupstream = " gperf-native"

 do_configure_prepend_class-gitupstream() {
    touch ${S}/README

}

It currently only supports creating a git variant of the target recipe, not native or nativesdk.

---
 meta/classes/gitupstream.bbclass | 23 +++++++++++++++++++++++
 1 file changed, 23 insertions(+)
 create mode 100644 meta/classes/gitupstream.bbclass
meta/classes/gitupstream.bbclass new file +23 -0
new file mode 100644
index 0000000..64aab61
@@ -0,0 +1,23 @@
+CLASSOVERRIDE = "class-gitupstream"
+
+# TODO doesn't let you gitupstream a native recipe yet
+
+python gitupstream_virtclass_handler () {
+    # Do nothing if this is inherited, as it's for BBCLASSEXTEND
+    if "gitupstream" not in (e.data.getVar('BBCLASSEXTEND', True) or ""):
+        bb.warn("Don't inherit gitupstream, use BBCLASSEXTEND")
+        return
+
+    # TODO sanity check somehow?
+
+    d.setVar("DEFAULT_PREFERENCE", "-1")
+    d.setVar("S", "${WORKDIR}/git")
+
+    # Modify the SRCREV, if the recipe hasn't used PV_class-gitupstream to
+    # assign a +gitX PV already.
+    pv = d.getVar("PV", True)
+    if "+git" not in pv:
+        d.setVar("PV", pv + "+git${SRCPV}")
+}
+addhandler gitupstream_virtclass_handler
+gitupstream_virtclass_handler[eventmask] = "bb.event.RecipePreFinalise"
Signature · 1 line
2.8.1
#1 lore raw
Quoted 4 lines · Ross Burton

BBCLASSEXTEND = "gitupstream" SRC_URI_class-gitupstream = "git://git.example.com/example" SRCREV_class-gitupstream = "abcd1234"

This isn't quite right, if you don't want to patch bitbake then use BBCLASSEXTEND="gitupstream:foo".

I have patches to extend this to native recipes but they're rather ugly so are not ready yet.

Ross