All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] classes: add devupstream class
@ 2017-03-09 17:00 Ross Burton
  0 siblings, 0 replies; only message in thread
From: Ross Burton @ 2017-03-09 17:00 UTC (permalink / raw)
  To: openembedded-core

This class lets you use BBCLASSEXTEND to add a variant of the recipe that
fetches from an alternative URI (such as git:) instead of a tarball.

For example:

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

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

 DEPENDS_append_class-devupstream = " gperf-native"

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

It currently only supports creating a development variant of the target recipe,
not native or nativesdk.  The BBCLASSEXTEND syntax (devupstream:target) was
chosen so that support for native and nativesdk can be added at a later date.

Support for other version control systems such as subversion is limited, as
bitbake's automatic fetch dependencies on for example subversion-native are not
generated.

[ YOCTO #10215 ]

Signed-off-by: Ross Burton <ross.burton@intel.com>
---
 meta/classes/devupstream.bbclass | 48 ++++++++++++++++++++++++++++++++++++++++
 1 file changed, 48 insertions(+)
 create mode 100644 meta/classes/devupstream.bbclass

diff --git a/meta/classes/devupstream.bbclass b/meta/classes/devupstream.bbclass
new file mode 100644
index 0000000..7d4113f
--- /dev/null
+++ b/meta/classes/devupstream.bbclass
@@ -0,0 +1,48 @@
+# Class for use in BBCLASSEXTEND to make it easier to have a single recipe that
+# can build both stable tarballs and snapshots from upstream source
+# repoistories.
+#
+# Usage:
+# BBCLASSEXTEND = "devupstream:target"
+# SRC_URI_class-devupstream = "git://git.example.com/example"
+# SRCREV_class-devupstream = "abcdef"
+#
+# If the first entry in SRC_URI is a git: URL then S is rewritten to
+# WORKDIR/git.
+#
+# There are a few caveats that remain to be solved:
+# - You can't build native or nativesdk recipes using for example
+#   devupstream:native, you can only build target recipes.
+# - If the fetcher requires native tools (such as subversion-native) then
+#   bitbake won't be able to add them automatically.
+
+CLASSOVERRIDE .= ":class-devupstream"
+
+python devupstream_virtclass_handler () {
+    # Do nothing if this is inherited, as it's for BBCLASSEXTEND
+    if "devupstream" not in (d.getVar('BBCLASSEXTEND') or ""):
+        bb.error("Don't inherit devupstream, use BBCLASSEXTEND")
+        return
+
+    variant = d.getVar("BBEXTENDVARIANT")
+    if variant not in ("target"):
+        bb.error("Pass the variant when using devupstream, for example devupstream:target")
+        return
+
+    # Develpment releases are never preferred by default
+    d.setVar("DEFAULT_PREFERENCE", "-1")
+
+    uri = bb.fetch2.URI(d.getVar("SRC_URI").split()[0])
+
+    if uri.scheme == "git":
+        d.setVar("S", "${WORKDIR}/git")
+
+    # Modify the PV if the recipe hasn't already overridden it
+    pv = d.getVar("PV")
+    proto_marker = "+" + uri.scheme
+    if proto_marker not in pv:
+        d.setVar("PV", pv + proto_marker + "${SRCPV}")
+}
+
+addhandler devupstream_virtclass_handler
+devupstream_virtclass_handler[eventmask] = "bb.event.RecipePreFinalise"
-- 
2.8.1



^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2017-03-09 17:01 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-03-09 17:00 [PATCH] classes: add devupstream class Ross Burton

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.