aboutsummaryrefslogtreecommitdiffstats
path: root/meta-selftest
AgeCommit message (Collapse)Author
2015-05-19recipetool: add appendfile subcommandPaul Eggleton
Locating which recipe provides a file in an image that you want to modify and then figuring out how to bbappend the recipe in order to replace it can be a tedious process. Thus, add a new appendfile subcommand to recipetool, providing the ability to create a bbappend file to add/replace any file in the target system. Without the -r option, it will search for the recipe packaging the specified file (using pkgdata from previously built recipes). The bbappend will be created at the appropriate path within the specified layer directory (which may or may not be in your bblayers.conf) or if one already exists it will be updated appropriately. Fairly extensive oe-selftest tests are also provided. Implements [YOCTO #6447]. Signed-off-by: Paul Eggleton <paul.eggleton@linux.intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2015-03-20oe-selftest: add a test for devtool deploy-targetPaul Eggleton
Whilst this test would seemingly be better placed as a runtime test, unfortunately the runtime tests run under bitbake and you can't run devtool within bitbake (since devtool needs to run bitbake itself). Additionally we are testing build-time functionality as well, so really this has to be done as an oe-selftest test. This test does have a few perhaps unusual requirements in order to run: * pexpect is installed * MACHINE is set to one of the qemu machines * runqemu tap devices have been set up Signed-off-by: Paul Eggleton <paul.eggleton@linux.intel.com> Signed-off-by: Ross Burton <ross.burton@intel.com>
2015-03-09lib/oeqa/selftest/lic-checksum: Verify failure when checksum changes.Randy Witt
The test added verifies that when a file with an absolute path in LIC_FILES_CHKSUM changes without a corresponding change to the md5sum, it triggers the license qa test again with a failure. [Yocto #6450] Signed-off-by: Randy Witt <randy.e.witt@linux.intel.com> Signed-off-by: Ross Burton <ross.burton@intel.com>
2014-01-02Basic recipe formatting fixesPaul Eggleton
Fix statement indenting and spacing issues that I happened to notice. Signed-off-by: Paul Eggleton <paul.eggleton@linux.intel.com>
2014-01-02Replace one-line DESCRIPTION with SUMMARYPaul Eggleton
A lot of our recipes had short one-line DESCRIPTION values and no SUMMARY value set. In this case it's much better to just set SUMMARY since DESCRIPTION is defaulted from SUMMARY anyway and then the SUMMARY is at least useful. I also took the opportunity to fix up a lot of the new SUMMARY values, making them concisely explain the function of the recipe / package where possible. Signed-off-by: Paul Eggleton <paul.eggleton@linux.intel.com>
2013-12-03meta-selftest: create a new test layer to be used by oe-selftest scriptCorneliu Stoicescu
Everything in this layer is meant to be used by tests called by scripts/oe-selftest. These are helper recipes/appends to test various bitbake options or scripts. Currently most of these files here only have "include test_recipe.inc" which is the file tests will actually use. Signed-off-by: Corneliu Stoicescu <corneliux.stoicescu@intel.com> Signed-off-by: Stefan Stanacar <stefanx.stanacar@intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
0 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281
#!/usr/bin/env python
# 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
# Copyright (C) 2003, 2004  Phil Blundell
# Copyright (C) 2003 - 2005 Michael 'Mickey' Lauer
# Copyright (C) 2005        Holger Hans Peter Freyther
# Copyright (C) 2005        ROAD GmbH
# Copyright (C) 2006        Richard Purdie
#
# 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
import sys, logging
sys.path.insert(0, os.path.join(os.path.dirname(os.path.dirname(__file__)),
                                'lib'))

import optparse
import warnings
from traceback import format_exception
try:
    import bb
except RuntimeError as exc:
    sys.exit(str(exc))
from bb import event
import bb.msg
from bb import cooker
from bb import ui
from bb import server

__version__ = "1.18.0"
logger = logging.getLogger("BitBake")

# Unbuffer stdout to avoid log truncation in the event
# of an unorderly exit as well as to provide timely
# updates to log files for use with tail
try:
    if sys.stdout.name == '<stdout>':
        sys.stdout = os.fdopen(sys.stdout.fileno(), 'w', 0)
except:
    pass

class BBConfiguration(object):
    """
    Manages build options and configurations for one run
    """

    def __init__(self, options):
        for key, val in options.__dict__.items():
            setattr(self, key, val)
        self.pkgs_to_build = []


def get_ui(config):
    if not config.ui:
        # modify 'ui' attribute because it is also read by cooker
        config.ui = os.environ.get('BITBAKE_UI', 'knotty')

    interface = config.ui

    try:
        # Dynamically load the UI based on the ui name. Although we
        # suggest a fixed set this allows you to have flexibility in which
        # ones are available.
        module = __import__("bb.ui", fromlist = [interface])
        return getattr(module, interface).main
    except AttributeError:
        sys.exit("FATAL: Invalid user interface '%s' specified.\n"
                 "Valid interfaces: depexp, goggle, ncurses, hob, knotty [default]." % interface)


# Display bitbake/OE warnings via the BitBake.Warnings logger, ignoring others"""
warnlog = logging.getLogger("BitBake.Warnings")
_warnings_showwarning = warnings.showwarning
def _showwarning(message, category, filename, lineno, file=None, line=None):
    if file is not None:
        if _warnings_showwarning is not None:
            _warnings_showwarning(message, category, filename, lineno, file, line)
    else:
        s = warnings.formatwarning(message, category, filename, lineno)
        warnlog.warn(s)

warnings.showwarning = _showwarning
warnings.filterwarnings("ignore")
warnings.filterwarnings("default", module="(<string>$|(oe|bb)\.)")
warnings.filterwarnings("ignore", category=PendingDeprecationWarning)
warnings.filterwarnings("ignore", category=ImportWarning)
warnings.filterwarnings("ignore", category=DeprecationWarning, module="<string>$")
warnings.filterwarnings("ignore", message="With-statements now directly support multiple context managers")


def main():
    parser = optparse.OptionParser(
        version = "BitBake Build Tool Core version %s, %%prog version %s" % (bb.__version__, __version__),
        usage = """%prog [options] [package ...]

Executes the specified task (default is 'build') for a given set of BitBake files.
It expects that BBFILES is defined, which is a space separated list of files to
be executed.  BBFILES does support wildcards.
Default BBFILES are the .bb files in the current directory.""")

    parser.add_option("-b", "--buildfile", help = "execute the task against this .bb file, rather than a package from BBFILES. Does not handle any dependencies.",
               action = "store", dest = "buildfile", default = None)

    parser.add_option("-k", "--continue", help = "continue as much as possible after an error. While the target that failed, and those that depend on it, cannot be remade, the other dependencies of these targets can be processed all the same.",
               action = "store_false", dest = "abort", default = True)

    parser.add_option("-a", "--tryaltconfigs", help = "continue with builds by trying to use alternative providers where possible.",
               action = "store_true", dest = "tryaltconfigs", default = False)

    parser.add_option("-f", "--force", help = "force run of specified cmd, regardless of stamp status",
               action = "store_true", dest = "force", default = False)

    parser.add_option("-c", "--cmd", help = "Specify task to execute. Note that this only executes the specified task for the providee and the packages it depends on, i.e. 'compile' does not implicitly call stage for the dependencies (IOW: use only if you know what you are doing). Depending on the base.bbclass a listtasks tasks is defined and will show available tasks",
               action = "store", dest = "cmd")

    parser.add_option("-C", "--clear-stamp", help = "Invalidate the stamp for the specified cmd such as 'compile' and run the default task for the specified target(s)",
                action = "store", dest = "invalidate_stamp")

    parser.add_option("-r", "--read", help = "read the specified file before bitbake.conf",
               action = "append", dest = "prefile", default = [])

    parser.add_option("-R", "--postread", help = "read the specified file after bitbake.conf",
                      action = "append", dest = "postfile", default = [])

    parser.add_option("-v", "--verbose", help = "output more chit-chat to the terminal",
               action = "store_true", dest = "verbose", default = False)

    parser.add_option("-D", "--debug", help = "Increase the debug level. You can specify this more than once.",
               action = "count", dest="debug", default = 0)

    parser.add_option("-n", "--dry-run", help = "don't execute, just go through the motions",
               action = "store_true", dest = "dry_run", default = False)

    parser.add_option("-S", "--dump-signatures", help = "don't execute, just dump out the signature construction information",
               action = "store_true", dest = "dump_signatures", default = False)

    parser.add_option("-p", "--parse-only", help = "quit after parsing the BB files (developers only)",
               action = "store_true", dest = "parse_only", default = False)

    parser.add_option("-s", "--show-versions", help = "show current and preferred versions of all recipes",
               action = "store_true", dest = "show_versions", default = False)

    parser.add_option("-e", "--environment", help = "show the global or per-package environment (this is what used to be bbread)",
               action = "store_true", dest = "show_environment", default = False)

    parser.add_option("-g", "--graphviz", help = "emit the dependency trees of the specified packages in the dot syntax, and the pn-buildlist to show the build list",
                action = "store_true", dest = "dot_graph", default = False)

    parser.add_option("-I", "--ignore-deps", help = """Assume these dependencies don't exist and are already provided (equivalent to ASSUME_PROVIDED). Useful to make dependency graphs more appealing""",
                action = "append", dest = "extra_assume_provided", default = [])

    parser.add_option("-l", "--log-domains", help = """Show debug logging for the specified logging domains""",
                action = "append", dest = "debug_domains", default = [])

    parser.add_option("-P", "--profile", help = "profile the command and print a report",
               action = "store_true", dest = "profile", default = False)

    parser.add_option("-u", "--ui", help = "userinterface to use",
               action = "store", dest = "ui")

    parser.add_option("-t", "--servertype", help = "Choose which server to use, none, process or xmlrpc",
               action = "store", dest = "servertype")

    parser.add_option("", "--revisions-changed", help = "Set the exit code depending on whether upstream floating revisions have changed or not",
               action = "store_true", dest = "revisions_changed", default = False)

    parser.add_option("", "--server-only", help = "Run bitbake without UI,  the frontend can connect with bitbake server itself",
               action = "store_true", dest = "server_only", default = False)

    parser.add_option("-B", "--bind", help = "The name/address for the bitbake server to bind to",
               action = "store", dest = "bind", default = False)
    parser.add_option("", "--no-setscene", help = "Do not run any setscene tasks, forces builds",
               action = "store_true", dest = "nosetscene", default = False)
    options, args = parser.parse_args(sys.argv)

    configuration = BBConfiguration(options)
    configuration.pkgs_to_build.extend(args[1:])

    ui_main = get_ui(configuration)

    # Server type can be xmlrpc, process or none currently, if nothing is specified,
    # the default server is process
    if configuration.servertype:
        server_type = configuration.servertype
    else:
        server_type = 'process'

    try:
        module = __import__("bb.server", fromlist = [server_type])
        server = getattr(module, server_type)
    except AttributeError:
        sys.exit("FATAL: Invalid server type '%s' specified.\n"
                 "Valid interfaces: xmlrpc, process [default], none." % servertype)

    if configuration.server_only:
        if configuration.servertype != "xmlrpc":
            sys.exit("FATAL: If '--server-only' is defined, we must set the servertype as 'xmlrpc'.\n")
        if not configuration.bind:
            sys.exit("FATAL: The '--server-only' option requires a name/address to bind to with the -B option.\n")

    if configuration.bind and configuration.servertype != "xmlrpc":
        sys.exit("FATAL: If '-B' or '--bind' is defined, we must set the servertype as 'xmlrpc'.\n")

    if "BBDEBUG" in os.environ:
        level = int(os.environ["BBDEBUG"])
        if level > configuration.debug:
            configuration.debug = level

    bb.msg.init_msgconfig(configuration.verbose, configuration.debug,
                         configuration.debug_domains)

    # Ensure logging messages get sent to the UI as events
    handler = bb.event.LogHandler()
    logger.addHandler(handler)

    # Before we start modifying the environment we should take a pristine
    # copy for possible later use
    initialenv = os.environ.copy()
    # Clear away any spurious environment variables while we stoke up the cooker
    cleanedvars = bb.utils.clean_environment()

    server = server.BitBakeServer()
    if configuration.bind:
        server.initServer((configuration.bind, 0))
    else:
        server.initServer()

    idle = server.getServerIdleCB()

    cooker = bb.cooker.BBCooker(configuration, idle, initialenv)
    cooker.parseCommandLine()

    server.addcooker(cooker)
    server.saveConnectionDetails()
    server.detach()

    # Should no longer need to ever reference cooker
    del cooker

    logger.removeHandler(handler)

    if not configuration.server_only:
        # Setup a connection to the server (cooker)
        server_connection = server.establishConnection()

        # Restore the environment in case the UI needs it
        for k in cleanedvars:
            os.environ[k] = cleanedvars[k]

        try:
            return server.launchUI(ui_main, server_connection.connection, server_connection.events)
        finally:
            bb.event.ui_queue = []
            server_connection.terminate()
    else:
        print("server address: %s, server port: %s" % (server.serverinfo.host, server.serverinfo.port))

    return 1

if __name__ == "__main__":
    try:
        ret = main()
    except Exception:
        ret = 1
        import traceback
        traceback.print_exc(5)
    sys.exit(ret)