summaryrefslogtreecommitdiffstats
path: root/meta/classes-recipe/devupstream.bbclass
diff options
context:
space:
mode:
authorRichard Purdie <richard.purdie@linuxfoundation.org>2022-08-10 14:35:29 +0100
committerRichard Purdie <richard.purdie@linuxfoundation.org>2022-08-12 15:27:17 +0100
commitfd1517e2b51a170f2427122c6b95396db251d827 (patch)
treedabfe3e631339c2fc99a9ee7febb0f9c128e325e /meta/classes-recipe/devupstream.bbclass
parent10317912ee319ccf7f83605d438b5cbf9663f296 (diff)
downloadpoky-fd1517e2b51a170f2427122c6b95396db251d827.tar.gz
classes: Update classes to match new bitbake class scope functionality
Move classes to classes-global or classes-recipe as appropriate to take advantage of new bitbake functionality to check class scope/usage. (From OE-Core rev: f5c128008365e141082c129417eb72d2751e8045) Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta/classes-recipe/devupstream.bbclass')
-rw-r--r--meta/classes-recipe/devupstream.bbclass61
1 files changed, 61 insertions, 0 deletions
diff --git a/meta/classes-recipe/devupstream.bbclass b/meta/classes-recipe/devupstream.bbclass
new file mode 100644
index 0000000000..1529cc8fca
--- /dev/null
+++ b/meta/classes-recipe/devupstream.bbclass
@@ -0,0 +1,61 @@
1#
2# Copyright OpenEmbedded Contributors
3#
4# SPDX-License-Identifier: MIT
5#
6
7# Class for use in BBCLASSEXTEND to make it easier to have a single recipe that
8# can build both stable tarballs and snapshots from upstream source
9# repositories.
10#
11# Usage:
12# BBCLASSEXTEND = "devupstream:target"
13# SRC_URI:class-devupstream = "git://git.example.com/example;branch=master"
14# SRCREV:class-devupstream = "abcdef"
15#
16# If the first entry in SRC_URI is a git: URL then S is rewritten to
17# WORKDIR/git.
18#
19# There are a few caveats that remain to be solved:
20# - You can't build native or nativesdk recipes using for example
21# devupstream:native, you can only build target recipes.
22# - If the fetcher requires native tools (such as subversion-native) then
23# bitbake won't be able to add them automatically.
24
25python devupstream_virtclass_handler () {
26 # Do nothing if this is inherited, as it's for BBCLASSEXTEND
27 if "devupstream" not in (d.getVar('BBCLASSEXTEND') or ""):
28 bb.error("Don't inherit devupstream, use BBCLASSEXTEND")
29 return
30
31 variant = d.getVar("BBEXTENDVARIANT")
32 if variant not in ("target", "native"):
33 bb.error("Unsupported variant %s. Pass the variant when using devupstream, for example devupstream:target" % variant)
34 return
35
36 # Develpment releases are never preferred by default
37 d.setVar("DEFAULT_PREFERENCE", "-1")
38
39 src_uri = d.getVar("SRC_URI:class-devupstream") or d.getVar("SRC_URI")
40 uri = bb.fetch2.URI(src_uri.split()[0])
41
42 if uri.scheme == "git" and not d.getVar("S:class-devupstream"):
43 d.setVar("S", "${WORKDIR}/git")
44
45 # Modify the PV if the recipe hasn't already overridden it
46 pv = d.getVar("PV")
47 proto_marker = "+" + uri.scheme
48 if proto_marker not in pv and not d.getVar("PV:class-devupstream"):
49 d.setVar("PV", pv + proto_marker + "${SRCPV}")
50
51 if variant == "native":
52 pn = d.getVar("PN")
53 d.setVar("PN", "%s-native" % (pn))
54 fn = d.getVar("FILE")
55 bb.parse.BBHandler.inherit("native", fn, 0, d)
56
57 d.appendVar("CLASSOVERRIDE", ":class-devupstream")
58}
59
60addhandler devupstream_virtclass_handler
61devupstream_virtclass_handler[eventmask] = "bb.event.RecipePreFinalise"