From ecfad70aae36a382459e53c9a16c82e9604d4421 Mon Sep 17 00:00:00 2001 From: Chris Larson Date: Thu, 19 Feb 2009 15:51:57 -0700 Subject: bitbake.conf: rework FILESPATH generation. Rework FILESPATH generation to be done in bitbake.conf, avoiding the confusion about it being in multiple places. Adds FILESPATHBASE and FILESPATHPKG which can be manipulated rather than manipulating FILESPATH directly. One usage possibility: FILESPATHBASE =. "${TOPDIR}/files:" Which would let me provide a custom busybox config for this build by copying the defconfig from the openembedded metadata into my build/files/busybox-1.0/ directory, for example. Signed-off-by: Chris Larson --- classes/base.bbclass | 12 ------------ 1 file changed, 12 deletions(-) (limited to 'classes/base.bbclass') diff --git a/classes/base.bbclass b/classes/base.bbclass index f1fee83a14..1b61895b07 100644 --- a/classes/base.bbclass +++ b/classes/base.bbclass @@ -180,18 +180,6 @@ def base_package_name(d): return pn -def base_set_filespath(path, d): - import os, bb - filespath = [] - # The ":" ensures we have an 'empty' override - overrides = (bb.data.getVar("OVERRIDES", d, 1) or "") + ":" - for p in path: - for o in overrides.split(":"): - filespath.append(os.path.join(p, o)) - return ":".join(filespath) - -FILESPATH = "${@base_set_filespath([ "${FILE_DIRNAME}/${PF}", "${FILE_DIRNAME}/${P}", "${FILE_DIRNAME}/${PN}", "${FILE_DIRNAME}/${BP}", "${FILE_DIRNAME}/${BPN}", "${FILE_DIRNAME}/files", "${FILE_DIRNAME}" ], d)}" - def oe_filter(f, str, d): from re import match return " ".join(filter(lambda x: match(f, x, 0), str.split())) -- cgit v1.2.3 From 515fc2744996506d8394f90dfe237175e51dc441 Mon Sep 17 00:00:00 2001 From: Chris Larson Date: Wed, 25 Feb 2009 14:12:24 -0800 Subject: base.bbclass: Kill the 'Pkg' messages in the event handler. Now that bitbake operates at a task level, not a package level, the package messages are, at best, useless, and at worst, confusing for the user. Signed-off-by: Chris Larson --- classes/base.bbclass | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) (limited to 'classes/base.bbclass') diff --git a/classes/base.bbclass b/classes/base.bbclass index 1b61895b07..d386d89a71 100644 --- a/classes/base.bbclass +++ b/classes/base.bbclass @@ -856,10 +856,7 @@ python base_eventhandler() { name = getName(e) msg = "" - if name.startswith("Pkg"): - msg += "package %s: " % data.getVar("P", e.data, 1) - msg += messages.get(name[3:]) or name[3:] - elif name.startswith("Task"): + if name.startswith("Task"): msg += "package %s: task %s: " % (data.getVar("PF", e.data, 1), e.task) msg += messages.get(name[4:]) or name[4:] elif name.startswith("Build"): @@ -867,6 +864,8 @@ python base_eventhandler() { msg += messages.get(name[5:]) or name[5:] elif name == "UnsatisfiedDep": msg += "package %s: dependency %s %s" % (e.pkg, e.dep, name[:-3].lower()) + else: + return NotHandled # Only need to output when using 1.8 or lower, the UI code handles it # otherwise -- cgit v1.2.3 From 65530068f30a5eea3db1b7da0e85d8e23d1dce00 Mon Sep 17 00:00:00 2001 From: Chris Larson Date: Wed, 25 Feb 2009 15:05:41 -0800 Subject: classes/base.bbclass: Locate the scm base path via BBPATH. Currently, if the first item in BBFILES isn't in the main OE repository, the build fails entirely due to a ValueError. This isn't optimal. Rather than searching through BBFILES to find it, which could be slow when BBFILES contains thousands of files, let's just find base.bbclass and use that repository. Also, use better methods to find the git revision and branch, and identify the scm based on the existance of .svn/.git/_MTN to avoid calling out subprocesses unnecessarily. Signed-off-by: Chris Larson --- classes/base.bbclass | 87 +++++++++++++++++++++++++--------------------------- 1 file changed, 42 insertions(+), 45 deletions(-) (limited to 'classes/base.bbclass') diff --git a/classes/base.bbclass b/classes/base.bbclass index d386d89a71..cf4b5c5e1d 100644 --- a/classes/base.bbclass +++ b/classes/base.bbclass @@ -758,21 +758,45 @@ python base_do_unpack() { raise bb.build.FuncFailed() } -def base_get_scmbasepath(d): - import bb - path_to_bbfiles = bb.data.getVar( 'BBFILES', d, 1 ).split() +METADATA_SCM = "${@base_get_scm(d)}" +METADATA_REVISION = "${@base_get_scm_revision(d)}" +METADATA_BRANCH = "${@base_get_scm_branch(d)}" +def base_get_scm(d): + import os + from bb import which + baserepo = os.path.dirname(os.path.dirname(which(d.getVar("BBPATH", 1), "classes/base.bbclass"))) + for (scm, scmpath) in {"svn": ".svn", + "git": ".git", + "monotone": "_MTN"}.iteritems(): + if os.path.exists(os.path.join(baserepo, scmpath)): + return "%s %s" % (scm, baserepo) + return " %s" % baserepo + +def base_get_scm_revision(d): + (scm, path) = d.getVar("METADATA_SCM", 1).split() try: - index = path_to_bbfiles[0].rindex( "recipes" ) - except ValueError: - index = path_to_bbfiles[0].rindex( "packages" ) + if scm != "": + return globals()["base_get_metadata_%s_revision" % scm](path, d) + else: + return scm + except KeyError: + return "" - return path_to_bbfiles[0][:index] +def base_get_scm_branch(d): + (scm, path) = d.getVar("METADATA_SCM", 1).split() + try: + if scm != "": + return globals()["base_get_metadata_%s_branch" % scm](path, d) + else: + return scm + except KeyError: + return "" -def base_get_metadata_monotone_branch(d): +def base_get_metadata_monotone_branch(path, d): monotone_branch = "" try: - monotone_branch = file( "%s/_MTN/options" % base_get_scmbasepath(d) ).read().strip() + monotone_branch = file( "%s/_MTN/options" % path ).read().strip() if monotone_branch.startswith( "database" ): monotone_branch_words = monotone_branch.split() monotone_branch = monotone_branch_words[ monotone_branch_words.index( "branch" )+1][1:-1] @@ -780,10 +804,10 @@ def base_get_metadata_monotone_branch(d): pass return monotone_branch -def base_get_metadata_monotone_revision(d): +def base_get_metadata_monotone_revision(path, d): monotone_revision = "" try: - monotone_revision = file( "%s/_MTN/revision" % base_get_scmbasepath(d) ).read().strip() + monotone_revision = file( "%s/_MTN/revision" % path ).read().strip() if monotone_revision.startswith( "format_version" ): monotone_revision_words = monotone_revision.split() monotone_revision = monotone_revision_words[ monotone_revision_words.index( "old_revision" )+1][1:-1] @@ -791,56 +815,29 @@ def base_get_metadata_monotone_revision(d): pass return monotone_revision -def base_get_metadata_svn_revision(d): +def base_get_metadata_svn_revision(path, d): revision = "" try: - revision = file( "%s/.svn/entries" % base_get_scmbasepath(d) ).readlines()[3].strip() + revision = file( "%s/.svn/entries" % path ).readlines()[3].strip() except IOError: pass return revision -def base_get_metadata_git_branch(d): +def base_get_metadata_git_branch(path, d): import os - branch = os.popen('cd %s; git branch | grep "^* " | tr -d "* "' % base_get_scmbasepath(d)).read() + branch = os.popen('cd %s; git symbolic-ref HEAD' % path).read() if len(branch) != 0: - return branch + return branch.replace("refs/heads/", "") return "" -def base_get_metadata_git_revision(d): +def base_get_metadata_git_revision(path, d): import os - rev = os.popen("cd %s; git log -n 1 --pretty=oneline --" % base_get_scmbasepath(d)).read().split(" ")[0] + rev = os.popen("cd %s; git show-ref HEAD" % path).read().split(" ")[0] if len(rev) != 0: return rev return "" -def base_detect_revision(d): - scms = [base_get_metadata_monotone_revision, \ - base_get_metadata_svn_revision, \ - base_get_metadata_git_revision] - - for scm in scms: - rev = scm(d) - if rev <> "": - return rev - - return "" - -def base_detect_branch(d): - scms = [base_get_metadata_monotone_branch, \ - base_get_metadata_git_branch] - - for scm in scms: - rev = scm(d) - if rev <> "": - return rev.strip() - - return "" - - - -METADATA_BRANCH ?= "${@base_detect_branch(d)}" -METADATA_REVISION ?= "${@base_detect_revision(d)}" addhandler base_eventhandler python base_eventhandler() { -- cgit v1.2.3 From 630555abb7ed906d6cb4bedecc94c34db84328ea Mon Sep 17 00:00:00 2001 From: Chris Larson Date: Thu, 26 Feb 2009 15:39:59 -0800 Subject: base.bbclass: make oe_unpack_file of dirs use FILESPATH, not FILESDIR. Signed-off-by: Chris Larson --- classes/base.bbclass | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) (limited to 'classes/base.bbclass') diff --git a/classes/base.bbclass b/classes/base.bbclass index cf4b5c5e1d..caaa6b2da1 100644 --- a/classes/base.bbclass +++ b/classes/base.bbclass @@ -689,15 +689,18 @@ def oe_unpack_file(file, data, url = None): cmd = '%s -a' % cmd cmd = '%s %s' % (cmd, file) elif os.path.isdir(file): - filesdir = os.path.realpath(bb.data.getVar("FILESDIR", data, 1)) destdir = "." - if file[0:len(filesdir)] == filesdir: - destdir = file[len(filesdir):file.rfind('/')] - destdir = destdir.strip('/') - if len(destdir) < 1: - destdir = "." - elif not os.access("%s/%s" % (os.getcwd(), destdir), os.F_OK): - os.makedirs("%s/%s" % (os.getcwd(), destdir)) + filespath = bb.data.getVar("FILESPATH", data, 1).split(":") + for fp in filespath: + if file[0:len(fp)] == fp: + destdir = file[len(fp):file.rfind('/')] + destdir = destdir.strip('/') + if len(destdir) < 1: + destdir = "." + elif not os.access("%s/%s" % (os.getcwd(), destdir), os.F_OK): + os.makedirs("%s/%s" % (os.getcwd(), destdir)) + break + cmd = 'cp -pPR %s %s/%s/' % (file, os.getcwd(), destdir) else: (type, host, path, user, pswd, parm) = bb.decodeurl(url) -- cgit v1.2.3 From 06e6fddcf04474cd1006ee8ad3e51c2c2dbfde2a Mon Sep 17 00:00:00 2001 From: Chris Larson Date: Thu, 26 Feb 2009 14:31:29 -0800 Subject: bitbake.conf: Move the list of vars shown in the pre-build config display to here. Now a distro or machine can add their own variables to display. Signed-off-by: Chris Larson --- classes/base.bbclass | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'classes/base.bbclass') diff --git a/classes/base.bbclass b/classes/base.bbclass index caaa6b2da1..11f6554d2d 100644 --- a/classes/base.bbclass +++ b/classes/base.bbclass @@ -875,12 +875,12 @@ python base_eventhandler() { if name.startswith("BuildStarted"): bb.data.setVar( 'BB_VERSION', bb.__version__, e.data ) - statusvars = ['BB_VERSION', 'METADATA_BRANCH', 'METADATA_REVISION', 'TARGET_ARCH', 'TARGET_OS', 'MACHINE', 'DISTRO', 'DISTRO_VERSION','TARGET_FPU'] + statusvars = bb.data.getVar("BUILDCFG_VARS", e.data, 1).split() statuslines = ["%-17s = \"%s\"" % (i, bb.data.getVar(i, e.data, 1) or '') for i in statusvars] statusmsg = "\nOE Build Configuration:\n%s\n" % '\n'.join(statuslines) print statusmsg - needed_vars = [ "TARGET_ARCH", "TARGET_OS" ] + needed_vars = bb.data.getVar("BUILDCFG_NEEDEDVARS", e.data, 1).split() pesteruser = [] for v in needed_vars: val = bb.data.getVar(v, e.data, 1) -- cgit v1.2.3 From 4cd7e03d78aed8ee6f3bd18d569a0ee9b2587633 Mon Sep 17 00:00:00 2001 From: Chris Larson Date: Fri, 13 Mar 2009 13:35:56 -0700 Subject: base.bbclass: Add base_path_relative. base_path_relative returns a relative path from src to dest. Examples: >>> base_path_relative("/usr/bin", "/tmp/foo/bar") ../../tmp/foo/bar >>> base_path_relative("/usr/bin", "/usr/lib") ../lib >>> base_path_relative("/tmp", "/tmp/foo/bar") foo/bar Signed-off-by: Chris Larson --- classes/base.bbclass | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) (limited to 'classes/base.bbclass') diff --git a/classes/base.bbclass b/classes/base.bbclass index 11f6554d2d..9bcd2abb3c 100644 --- a/classes/base.bbclass +++ b/classes/base.bbclass @@ -10,6 +10,35 @@ def base_path_join(a, *p): path += '/' + b return path +def base_path_relative(src, dest): + """ Return a relative path from src to dest. + + >>> base_path_relative("/usr/bin", "/tmp/foo/bar") + ../../tmp/foo/bar + + >>> base_path_relative("/usr/bin", "/usr/lib") + ../lib + + >>> base_path_relative("/tmp", "/tmp/foo/bar") + foo/bar + """ + from os.path import sep, pardir, normpath, commonprefix + + destlist = normpath(dest).split(sep) + srclist = normpath(src).split(sep) + + # Find common section of the path + common = commonprefix([destlist, srclist]) + commonlen = len(common) + + # Climb back to the point where they differentiate + relpath = [ pardir ] * (len(srclist) - commonlen) + if commonlen < len(destlist): + # Add remaining portion + relpath += destlist[commonlen:] + + return sep.join(relpath) + # for MD5/SHA handling def base_chk_load_parser(config_path): import ConfigParser, os, bb -- cgit v1.2.3 From f3a6785d8a91e1f1763f48a5981f7e2a8d37f151 Mon Sep 17 00:00:00 2001 From: Chris Larson Date: Sat, 21 Mar 2009 21:34:03 -0700 Subject: base.bbclass: revert removal of base_set_filespath until the refs can be removed. Also added a deprecation message to it. Signed-off-by: Chris Larson --- classes/base.bbclass | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'classes/base.bbclass') diff --git a/classes/base.bbclass b/classes/base.bbclass index 9bcd2abb3c..952952b7fe 100644 --- a/classes/base.bbclass +++ b/classes/base.bbclass @@ -209,6 +209,17 @@ def base_package_name(d): return pn +def base_set_filespath(path, d): + import os, bb + bb.note("base_set_filespath usage is deprecated, %s should be fixed" % d.getar("P", 1)) + filespath = [] + # The ":" ensures we have an 'empty' override + overrides = (bb.data.getVar("OVERRIDES", d, 1) or "") + ":" + for p in path: + for o in overrides.split(":"): + filespath.append(os.path.join(p, o)) + return ":".join(filespath) + def oe_filter(f, str, d): from re import match return " ".join(filter(lambda x: match(f, x, 0), str.split())) -- cgit v1.2.3 From d9a3e7e7679f0ebd11c11f5a96c19b4137fb4ec0 Mon Sep 17 00:00:00 2001 From: Chris Larson Date: Sat, 21 Mar 2009 22:11:46 -0700 Subject: base.bbclass: Fix typo. Signed-off-by: Chris Larson --- classes/base.bbclass | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'classes/base.bbclass') diff --git a/classes/base.bbclass b/classes/base.bbclass index 952952b7fe..f39059ecc0 100644 --- a/classes/base.bbclass +++ b/classes/base.bbclass @@ -211,7 +211,7 @@ def base_package_name(d): def base_set_filespath(path, d): import os, bb - bb.note("base_set_filespath usage is deprecated, %s should be fixed" % d.getar("P", 1)) + bb.note("base_set_filespath usage is deprecated, %s should be fixed" % d.getVar("P", 1)) filespath = [] # The ":" ensures we have an 'empty' override overrides = (bb.data.getVar("OVERRIDES", d, 1) or "") + ":" -- cgit v1.2.3