aboutsummaryrefslogtreecommitdiffstats
path: root/classes
diff options
context:
space:
mode:
authorKhem Raj <raj.khem@gmail.com>2009-08-25 23:08:08 -0700
committerKhem Raj <raj.khem@gmail.com>2009-08-25 23:08:08 -0700
commitc0be71ee071b99b841a7063944d6784616c26b56 (patch)
tree572ae00f6d5dbaa8724d58c7092c449431e37eb9 /classes
parentaa34eaf616e1eed709d0d8f370695dd0211c7891 (diff)
parente5b751653cb17d60665a648c8f9aaeda028aa122 (diff)
downloadopenembedded-c0be71ee071b99b841a7063944d6784616c26b56.tar.gz
Merge branch 'org.openembedded.dev' of git@git.openembedded.org:openembedded into org.openembedded.dev
Diffstat (limited to 'classes')
-rw-r--r--classes/gitver.bbclass54
-rw-r--r--classes/package_ipk.bbclass7
-rw-r--r--classes/srctree.bbclass141
3 files changed, 198 insertions, 4 deletions
diff --git a/classes/gitver.bbclass b/classes/gitver.bbclass
new file mode 100644
index 0000000000..92c053ae24
--- /dev/null
+++ b/classes/gitver.bbclass
@@ -0,0 +1,54 @@
+# Copyright (C) 2009 Chris Larson <clarson@kergoth.com>
+# Released under the MIT license (see COPYING.MIT for the terms)
+#
+# gitver.bbclass provides a GITVER variable which is a (fairly) sane version,
+# for use in ${PV}, extracted from the ${S} git checkout, assuming it is one.
+# This is most useful in concert with srctree.bbclass.
+
+
+GITVER = "${@get_git_pv('${S}', d)}"
+
+def gitver_mark_dependency(d):
+ from bb.data import expand
+ from bb.parse import mark_dependency
+ from os.path import abspath
+
+ fn = abspath(expand("${S}/.git/HEAD", d))
+ mark_dependency(d, fn)
+
+def get_git_pv(path, d, tagadjust=None):
+ from subprocess import Popen, PIPE
+ from os.path import join
+ from bb import error
+
+ env = {"GIT_DIR": join(d.getVar("S", True), ".git")}
+
+ def popen(cmd, **kwargs):
+ kwargs["stderr"] = PIPE
+ kwargs["stdout"] = PIPE
+ kwargs["env"] = env
+ try:
+ pipe = Popen(cmd, **kwargs)
+ except OSError, e:
+ #error("Execution of %s failed: %s" % (cmd, e))
+ return
+
+ (stdout, stderr) = pipe.communicate(None)
+ if pipe.returncode != 0:
+ #error("Execution of %s failed: %s" % (cmd, stderr))
+ return
+ return stdout.rstrip()
+
+ gitver_mark_dependency(d)
+
+ ver = popen(["git", "describe", "--tags"], cwd=path)
+ if not ver:
+ ver = popen(["git", "rev-parse", "--short", "HEAD"], cwd=path)
+ if ver:
+ return "0.0-%s" % ver
+ else:
+ return "0.0"
+ else:
+ if tagadjust:
+ ver = tagadjust(ver)
+ return ver
diff --git a/classes/package_ipk.bbclass b/classes/package_ipk.bbclass
index e3a7522619..e5561082fd 100644
--- a/classes/package_ipk.bbclass
+++ b/classes/package_ipk.bbclass
@@ -266,10 +266,9 @@ python do_package_ipk () {
ctrlfile.write("Replaces: %s\n" % ", ".join(rreplaces))
if rconflicts:
ctrlfile.write("Conflicts: %s\n" % ", ".join(rconflicts))
- src_uri = bb.data.getVar("SRC_URI", localdata, 1)
- if src_uri:
- src_uri = re.sub("\s+", " ", src_uri)
- ctrlfile.write("Source: %s\n" % " ".join(src_uri.split()))
+ src_uri = bb.data.getVar("SRC_URI", localdata, 1) or d.getVar("FILE", True)
+ src_uri = re.sub("\s+", " ", src_uri)
+ ctrlfile.write("Source: %s\n" % " ".join(src_uri.split()))
ctrlfile.close()
for script in ["preinst", "postinst", "prerm", "postrm"]:
diff --git a/classes/srctree.bbclass b/classes/srctree.bbclass
new file mode 100644
index 0000000000..2a324cf1be
--- /dev/null
+++ b/classes/srctree.bbclass
@@ -0,0 +1,141 @@
+# Copyright (C) 2009 Chris Larson <clarson@kergoth.com>
+# Released under the MIT license (see COPYING.MIT for the terms)
+#
+# srctree.bbclass enables operation inside of an existing source tree for a
+# project, rather than using the fetch/unpack/patch idiom.
+#
+# By default, it expects that you're keeping the recipe(s) inside the
+# aforementioned source tree, but you could override S to point at an external
+# directory and place the recipes in a normal collection/overlay, if you so
+# chose.
+#
+# It also provides some convenience python functions for assembling your
+# do_clean, if you want to leverage things like 'git clean' to simplify the
+# operation.
+
+
+S = "${FILE_DIRNAME}"
+SRC_URI = ""
+
+#TYPE = "${@'${PN}'.replace('${BPN}', '').strip()}"
+#WORKDIR = "${S}/tmp${TYPE}.${MULTIMACH_HOST_SYS}"
+#STAMP = "${WORKDIR}/tasks/stamp"
+#WORKDIR_LOCAL = "${S}/tmp${TYPE}.${MULTIMACH_HOST_SYS}"
+#T = "${WORKDIR_LOCAL}/bitbake-tasks"
+
+# Hack, so things don't explode in builds that don't inherit package
+do_package ?= " pass"
+do_package[func] = "1"
+do_package[python] = "1"
+
+# Ensure that do_package depends on populate_staging, rather than install
+addtask package after do_populate_staging
+
+# This stuff is needed to facilitate variants (normal, native, cross, sdk)
+# that share a ${S}. It's ugly as hell. Only really necessary for recipes
+# that can't use a ${B}, and which have variants like native. Not sure what
+# the best solution is long term.
+#
+# We merge configure+compile+install into the populate_staging task, uses a
+# lock file. This ensures that none of the tasks which access ${S} can
+# interleave amongst the recipes that share that ${S}.
+
+def variant_hack(d):
+ from itertools import chain
+
+ # Kill dependencies on the fromtasks
+ fromtasks = ["do_configure", "do_compile", "do_install"]
+ for key in d.keys():
+ task = d.getVarFlag(key, "task")
+ if task:
+ deps = d.getVarFlag(key, "deps")
+ for task_ in fromtasks:
+ if task_ in deps:
+ deps.remove(task_)
+ # if not key in fromtasks + ["do_populate_staging"]:
+ # deps.append("do_populate_staging")
+ d.setVarFlag(key, "deps", deps)
+
+ # Pull the task deps from fromtasks over to the new task, minus deltasks
+ deltasks = ("do_patch", "do_unpack", "do_fetch")
+ deps = set(chain(*[(d.getVarFlag(old, "deps")) for old in fromtasks + ["do_populate_staging"]]))
+ d.setVarFlag("do_populate_staging", "deps", deps.difference(deltasks))
+
+ # Pull cross recipe task deps over
+ d.setVarFlag("do_populate_staging", "depends", " ".join((d.getVarFlag(old, "depends") or "" for old in fromtasks)))
+
+python () {
+ variant_hack(d)
+}
+
+python do_populate_staging () {
+ from bb.build import exec_task, exec_func
+
+ exec_task("do_configure", d)
+ exec_task("do_compile", d)
+ exec_task("do_install", d)
+ exec_func("do_stage", d)
+}
+do_populate_staging[lockfiles] += "${S}/.lock"
+
+make_do_clean () {
+ oe_runmake clean
+}
+
+def clean_builddir(d):
+ from shutil import rmtree
+
+ builddir = d.getVar("B", True)
+ srcdir = d.getVar("S", True)
+ if builddir != srcdir:
+ rmtree(builddir, ignore_errors=True)
+
+def clean_stamps(d):
+ from glob import glob
+ from bb import note
+ from bb.data import expand
+ from os import unlink
+
+ note("Removing stamps")
+ for stamp in glob(expand('${STAMP}.*', d)):
+ try:
+ unlink(stamp)
+ except OSError:
+ pass
+
+def clean_workdir(d):
+ from shutil import rmtree
+ from bb import note
+
+ workdir = d.getVar("WORKDIR", 1)
+ note("Removing %s" % workdir)
+ rmtree(workdir, ignore_errors=True)
+
+def clean_git(d):
+ from subprocess import call
+
+ call(["git", "clean", "-d", "-f", "-X"], cwd=d.getVar("S", True))
+
+def clean_make(d):
+ import bb
+
+ bb.note("Running make clean")
+ try:
+ bb.build.exec_func("make_do_clean", d)
+ except bb.build.FuncFailed:
+ pass
+
+python do_clean () {
+ from os.path import exists
+ from bb.build import FuncFailed
+ from bb.data import expand
+
+ clean_stamps(d)
+ clean_workdir(d)
+ if exists(expand("${S}/.git", d)) and \
+ exists(expand("${S}/.gitignore", d)):
+ clean_git(d)
+ else:
+ clean_builddir(d)
+ clean_make(d)
+}