1# Class for use in BBCLASSEXTEND to make it easier to have a single recipe that 2# can build both stable tarballs and snapshots from upstream source 3# repositories. 4# 5# Usage: 6# BBCLASSEXTEND = "devupstream:target" 7# SRC_URI:class-devupstream = "git://git.example.com/example;branch=master" 8# SRCREV:class-devupstream = "abcdef" 9# 10# If the first entry in SRC_URI is a git: URL then S is rewritten to 11# WORKDIR/git. 12# 13# There are a few caveats that remain to be solved: 14# - You can't build native or nativesdk recipes using for example 15# devupstream:native, you can only build target recipes. 16# - If the fetcher requires native tools (such as subversion-native) then 17# bitbake won't be able to add them automatically. 18 19python devupstream_virtclass_handler () { 20 # Do nothing if this is inherited, as it's for BBCLASSEXTEND 21 if "devupstream" not in (d.getVar('BBCLASSEXTEND') or ""): 22 bb.error("Don't inherit devupstream, use BBCLASSEXTEND") 23 return 24 25 variant = d.getVar("BBEXTENDVARIANT") 26 if variant not in ("target", "native"): 27 bb.error("Unsupported variant %s. Pass the variant when using devupstream, for example devupstream:target" % variant) 28 return 29 30 # Develpment releases are never preferred by default 31 d.setVar("DEFAULT_PREFERENCE", "-1") 32 33 src_uri = d.getVar("SRC_URI:class-devupstream") or d.getVar("SRC_URI") 34 uri = bb.fetch2.URI(src_uri.split()[0]) 35 36 if uri.scheme == "git" and not d.getVar("S:class-devupstream"): 37 d.setVar("S", "${WORKDIR}/git") 38 39 # Modify the PV if the recipe hasn't already overridden it 40 pv = d.getVar("PV") 41 proto_marker = "+" + uri.scheme 42 if proto_marker not in pv and not d.getVar("PV:class-devupstream"): 43 d.setVar("PV", pv + proto_marker + "${SRCPV}") 44 45 if variant == "native": 46 pn = d.getVar("PN") 47 d.setVar("PN", "%s-native" % (pn)) 48 fn = d.getVar("FILE") 49 bb.parse.BBHandler.inherit("native", fn, 0, d) 50 51 d.appendVar("CLASSOVERRIDE", ":class-devupstream") 52} 53 54addhandler devupstream_virtclass_handler 55devupstream_virtclass_handler[eventmask] = "bb.event.RecipePreFinalise" 56