aboutsummaryrefslogtreecommitdiffstats
path: root/oe-init-build-env-memres
blob: 9b9e0f44b009a16f6ca9d64df396024c003edcc7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
#!/bin/sh

# OE Build Environment Setup Script
#
# Copyright (C) 2006-2011 Linux Foundation
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# 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., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA

#
# Normally this is called as '. ./oe-init-build-env builddir <portnumber> <builddir>'
#
# This works in most shells (not dash), but not all of them pass arg1 when
# being sourced.   To workaround the shell limitation use "set arg1" prior 
# to sourcing this script.
#
if [ -z "$1" ]; then
    echo "No port specified, using dynamically selected port"
    port=-1
else
    port=$1
    shift
fi
if [ -z "$ZSH_NAME" ] && [ "x$0" = "x./oe-init-build-env" ]; then
   echo "Error: This script needs to be sourced. Please run as '. ./oe-init-build-env'"
else
   if [ -n "$BASH_SOURCE" ]; then
      OEROOT="`dirname $BASH_SOURCE`"
   elif [ -n "$ZSH_NAME" ]; then
      OEROOT="`dirname $0`"
   else
      OEROOT="`pwd`"
   fi
   if [ -n "$BBSERVER" ]; then
      unset BBSERVER
   fi
            
   OEROOT=`readlink -f "$OEROOT"`
   export OEROOT
   . $OEROOT/scripts/oe-buildenv-internal && \
        $OEROOT/scripts/oe-setup-builddir && \
        [ -n "$BUILDDIR" ] && cd $BUILDDIR
   unset OEROOT
   unset BBPATH
fi
res=1
if [ -e bitbake.lock ] && grep : bitbake.lock > /dev/null ; then
    BBSERVER=`cat bitbake.lock` bitbake --status-only
    res=$?
fi

if [ $res != 0 ] ; then
    bitbake --server-only -t xmlrpc -B localhost:$port
fi

if [ $port = -1 ] ; then
    export BBSERVER=localhost:-1
    echo "Bitbake server started on demand as needed, use bitbake -m to shut it down"
else
    export BBSERVER=`cat bitbake.lock`

    if [ $res = 0 ] ; then
	echo "Using existing bitbake server at: $BBSERVER, use bitbake -m to shut it down"
    else
	echo "Bitbake server started at: $BBSERVER, use bitbake -m to shut it down"
    fi
    unset res
fi
ommand('findSigInfo', pn, taskname, sigs) if ret: while True: event = tinfoil.wait_event(1) if event: if isinstance(event, bb.command.CommandCompleted): break elif isinstance(event, bb.command.CommandFailed): logger.error(str(event)) sys.exit(2) elif isinstance(event, bb.event.FindSigInfoResult): result = event.result elif isinstance(event, logging.LogRecord): logger.handle(event) else: logger.error('No result returned from findSigInfo command') sys.exit(2) return result def find_siginfo_task(bbhandler, pn, taskname, sig1=None, sig2=None): """ Find the most recent signature files for the specified PN/task """ if not taskname.startswith('do_'): taskname = 'do_%s' % taskname if sig1 and sig2: sigfiles = find_siginfo(bbhandler, pn, taskname, [sig1, sig2]) if len(sigfiles) == 0: logger.error('No sigdata files found matching %s %s matching either %s or %s' % (pn, taskname, sig1, sig2)) sys.exit(1) elif not sig1 in sigfiles: logger.error('No sigdata files found matching %s %s with signature %s' % (pn, taskname, sig1)) sys.exit(1) elif not sig2 in sigfiles: logger.error('No sigdata files found matching %s %s with signature %s' % (pn, taskname, sig2)) sys.exit(1) latestfiles = [sigfiles[sig1], sigfiles[sig2]] else: filedates = find_siginfo(bbhandler, pn, taskname) latestfiles = sorted(filedates.keys(), key=lambda f: filedates[f])[-2:] if not latestfiles: logger.error('No sigdata files found matching %s %s' % (pn, taskname)) sys.exit(1) return latestfiles # Define recursion callback def recursecb(key, hash1, hash2): hashes = [hash1, hash2] hashfiles = find_siginfo(tinfoil, key, None, hashes) recout = [] if len(hashfiles) == 0: recout.append("Unable to find matching sigdata for %s with hashes %s or %s" % (key, hash1, hash2)) elif not hash1 in hashfiles: recout.append("Unable to find matching sigdata for %s with hash %s" % (key, hash1)) elif not hash2 in hashfiles: recout.append("Unable to find matching sigdata for %s with hash %s" % (key, hash2)) else: out2 = bb.siggen.compare_sigfiles(hashfiles[hash1], hashfiles[hash2], recursecb, color=color) for change in out2: for line in change.splitlines(): recout.append(' ' + line) return recout parser = argparse.ArgumentParser( description=("Dumps" if is_dump else "Compares") + " siginfo/sigdata files written out by BitBake") parser.add_argument('-D', '--debug', help='Enable debug output', action='store_true') if is_dump: parser.add_argument("-t", "--task", help="find the signature data file for the last run of the specified task", action="store", dest="taskargs", nargs=2, metavar=('recipename', 'taskname')) parser.add_argument("sigdatafile1", help="Signature file to dump. Not used when using -t/--task.", action="store", nargs='?', metavar="sigdatafile") else: parser.add_argument('-c', '--color', help='Colorize the output (where %(metavar)s is %(choices)s)', choices=['auto', 'always', 'never'], default='auto', metavar='color') parser.add_argument('-d', '--dump', help='Dump the last signature data instead of comparing (equivalent to using bitbake-dumpsig)', action='store_true') parser.add_argument("-t", "--task", help="find the signature data files for the last two runs of the specified task and compare them", action="store", dest="taskargs", nargs=2, metavar=('recipename', 'taskname')) parser.add_argument("-s", "--signature", help="With -t/--task, specify the signatures to look for instead of taking the last two", action="store", dest="sigargs", nargs=2, metavar=('fromsig', 'tosig')) parser.add_argument("sigdatafile1", help="First signature file to compare (or signature file to dump, if second not specified). Not used when using -t/--task.", action="store", nargs='?') parser.add_argument("sigdatafile2", help="Second signature file to compare", action="store", nargs='?') options = parser.parse_args() if is_dump: options.color = 'never' options.dump = True options.sigdatafile2 = None options.sigargs = None if options.debug: logger.setLevel(logging.DEBUG) color = (options.color == 'always' or (options.color == 'auto' and sys.stdout.isatty())) if options.taskargs: with bb.tinfoil.Tinfoil() as tinfoil: tinfoil.prepare(config_only=True) if not options.dump and options.sigargs: files = find_siginfo_task(tinfoil, options.taskargs[0], options.taskargs[1], options.sigargs[0], options.sigargs[1]) else: files = find_siginfo_task(tinfoil, options.taskargs[0], options.taskargs[1]) if options.dump: logger.debug("Signature file: %s" % files[-1]) output = bb.siggen.dump_sigfile(files[-1]) else: if len(files) < 2: logger.error('Only one matching sigdata file found for the specified task (%s %s)' % (options.taskargs[0], options.taskargs[1])) sys.exit(1) # Recurse into signature comparison logger.debug("Signature file (previous): %s" % files[-2]) logger.debug("Signature file (latest): %s" % files[-1]) output = bb.siggen.compare_sigfiles(files[-2], files[-1], recursecb, color=color) else: if options.sigargs: logger.error('-s/--signature can only be used together with -t/--task') sys.exit(1) try: if not options.dump and options.sigdatafile1 and options.sigdatafile2: with bb.tinfoil.Tinfoil() as tinfoil: tinfoil.prepare(config_only=True) output = bb.siggen.compare_sigfiles(options.sigdatafile1, options.sigdatafile2, recursecb, color=color) elif options.sigdatafile1: output = bb.siggen.dump_sigfile(options.sigdatafile1) else: logger.error('Must specify signature file(s) or -t/--task') parser.print_help() sys.exit(1) except IOError as e: logger.error(str(e)) sys.exit(1) except (pickle.UnpicklingError, EOFError): logger.error('Invalid signature data - ensure you are specifying sigdata/siginfo files') sys.exit(1) if output: print('\n'.join(output))