diff options
| author | Richard Purdie <richard@openedhand.com> | 2008-09-30 15:08:33 +0000 | 
|---|---|---|
| committer | Richard Purdie <richard@openedhand.com> | 2008-09-30 15:08:33 +0000 | 
| commit | c30eddb243e7e65f67f656e62848a033cf6f2e5c (patch) | |
| tree | 110dd95788b76f55d31cb8d30aac2de8400b6f4a /bitbake-dev/lib/bb/manifest.py | |
| parent | 5ef0510474004eeb2ae8a99b64e2febb1920e077 (diff) | |
| download | openembedded-core-c30eddb243e7e65f67f656e62848a033cf6f2e5c.tar.gz openembedded-core-c30eddb243e7e65f67f656e62848a033cf6f2e5c.tar.bz2 openembedded-core-c30eddb243e7e65f67f656e62848a033cf6f2e5c.zip | |
Add bitbake-dev to allow ease of testing and development of bitbake trunk
git-svn-id: https://svn.o-hand.com/repos/poky/trunk@5337 311d38ba-8fff-0310-9ca6-ca027cbcb966
Diffstat (limited to 'bitbake-dev/lib/bb/manifest.py')
| -rw-r--r-- | bitbake-dev/lib/bb/manifest.py | 144 | 
1 files changed, 144 insertions, 0 deletions
| diff --git a/bitbake-dev/lib/bb/manifest.py b/bitbake-dev/lib/bb/manifest.py new file mode 100644 index 0000000000..4e4b7d98ec --- /dev/null +++ b/bitbake-dev/lib/bb/manifest.py @@ -0,0 +1,144 @@ +# ex:ts=4:sw=4:sts=4:et +# -*- tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*- +# +# Copyright (C) 2003, 2004  Chris Larson +#  +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License version 2 as +# published by the Free Software Foundation. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License along +# with this program; if not, write to the Free Software Foundation, Inc., +# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + +import os, sys +import bb, bb.data + +def getfields(line): +    fields = {} +    fieldmap = ( "pkg", "src", "dest", "type", "mode", "uid", "gid", "major", "minor", "start", "inc", "count" ) +    for f in xrange(len(fieldmap)): +        fields[fieldmap[f]] = None + +    if not line: +        return None + +    splitline = line.split() +    if not len(splitline): +        return None + +    try: +        for f in xrange(len(fieldmap)): +            if splitline[f] == '-': +                continue +            fields[fieldmap[f]] = splitline[f] +    except IndexError: +        pass +    return fields + +def parse (mfile, d): +    manifest = [] +    while 1: +        line = mfile.readline() +        if not line: +            break +        if line.startswith("#"): +            continue +        fields = getfields(line) +        if not fields: +            continue +        manifest.append(fields) +    return manifest + +def emit (func, manifest, d): +#str = "%s () {\n" % func +    str = "" +    for line in manifest: +        emittedline = emit_line(func, line, d) +        if not emittedline: +            continue +        str += emittedline + "\n" +#       str += "}\n" +    return str + +def mangle (func, line, d): +    import copy +    newline = copy.copy(line) +    src = bb.data.expand(newline["src"], d) + +    if src: +        if not os.path.isabs(src): +            src = "${WORKDIR}/" + src + +    dest = newline["dest"] +    if not dest: +        return + +    if dest.startswith("/"): +        dest = dest[1:] + +    if func is "do_install": +        dest = "${D}/" + dest + +    elif func is "do_populate": +        dest = "${WORKDIR}/install/" + newline["pkg"] + "/" + dest + +    elif func is "do_stage": +        varmap = {} +        varmap["${bindir}"] = "${STAGING_DIR}/${HOST_SYS}/bin" +        varmap["${libdir}"] = "${STAGING_DIR}/${HOST_SYS}/lib" +        varmap["${includedir}"] = "${STAGING_DIR}/${HOST_SYS}/include" +        varmap["${datadir}"] = "${STAGING_DATADIR}" + +        matched = 0 +        for key in varmap.keys(): +            if dest.startswith(key): +                dest = varmap[key] + "/" + dest[len(key):] +                matched = 1 +        if not matched: +            newline = None +            return +    else: +        newline = None +        return + +    newline["src"] = src +    newline["dest"] = dest +    return newline + +def emit_line (func, line, d): +    import copy +    newline = copy.deepcopy(line) +    newline = mangle(func, newline, d) +    if not newline: +        return None + +    str = "" +    type = newline["type"] +    mode = newline["mode"] +    src = newline["src"] +    dest = newline["dest"] +    if type is "d": +        str = "install -d " +        if mode: +            str += "-m %s " % mode +        str += dest +    elif type is "f": +        if not src: +            return None +        if dest.endswith("/"): +            str = "install -d " +            str += dest + "\n" +            str += "install " +        else: +            str = "install -D " +        if mode: +            str += "-m %s " % mode +        str += src + " " + dest +    del newline +    return str | 
