devupstream.bbclass 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  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"
  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. CLASSOVERRIDE .= ":class-devupstream"
  19. python 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. variant = d.getVar("BBEXTENDVARIANT")
  25. if variant not in ("target"):
  26. bb.error("Pass the variant when using devupstream, for example devupstream:target")
  27. return
  28. # Develpment releases are never preferred by default
  29. d.setVar("DEFAULT_PREFERENCE", "-1")
  30. uri = bb.fetch2.URI(d.getVar("SRC_URI").split()[0])
  31. if uri.scheme == "git":
  32. d.setVar("S", "${WORKDIR}/git")
  33. # Modify the PV if the recipe hasn't already overridden it
  34. pv = d.getVar("PV")
  35. proto_marker = "+" + uri.scheme
  36. if proto_marker not in pv:
  37. d.setVar("PV", pv + proto_marker + "${SRCPV}")
  38. }
  39. addhandler devupstream_virtclass_handler
  40. devupstream_virtclass_handler[eventmask] = "bb.event.RecipePreFinalise"