diff options
Diffstat (limited to 'import-layers/yocto-poky/scripts/bitbake-whatchanged')
-rwxr-xr-x | import-layers/yocto-poky/scripts/bitbake-whatchanged | 41 |
1 files changed, 16 insertions, 25 deletions
diff --git a/import-layers/yocto-poky/scripts/bitbake-whatchanged b/import-layers/yocto-poky/scripts/bitbake-whatchanged index af54d16f8b..0207777e63 100755 --- a/import-layers/yocto-poky/scripts/bitbake-whatchanged +++ b/import-layers/yocto-poky/scripts/bitbake-whatchanged @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 # ex:ts=4:sw=4:sts=4:et # -*- tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*- @@ -17,7 +17,6 @@ # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -from __future__ import print_function import os import sys import getopt @@ -25,7 +24,7 @@ import shutil import re import warnings import subprocess -from optparse import OptionParser +import argparse scripts_path = os.path.abspath(os.path.dirname(os.path.abspath(sys.argv[0]))) lib_path = scripts_path + '/lib' @@ -38,6 +37,8 @@ bitbakepath = scriptpath.add_bitbake_lib_path() if not bitbakepath: sys.stderr.write("Unable to find bitbake by searching parent directory of this script or PATH\n") sys.exit(1) +scriptpath.add_oe_lib_path() +import argparse_oe import bb.siggen import bb.process @@ -118,7 +119,7 @@ def print_added(d_new = None, d_old = None): Print the newly added tasks """ added = {} - for k in d_new.keys(): + for k in list(d_new.keys()): if k not in d_old: # Add the new one to added dict, and remove it from # d_new, so the remaining ones are the changed ones @@ -153,7 +154,7 @@ def print_vrchanged(d_new = None, d_old = None, vr = None): """ pvchanged = {} counter = 0 - for k in d_new.keys(): + for k in list(d_new.keys()): if d_new.get(k).get(vr) != d_old.get(k).get(vr): counter += 1 pn, task = split_pntask(k) @@ -219,9 +220,7 @@ def main(): 3) Use bb.siggen.compare_sigfiles to diff the old and new stamps """ - parser = OptionParser( - version = "1.0", - usage = """%prog [options] [package ...] + parser = argparse_oe.ArgumentParser(usage = """%(prog)s [options] [package ...] print what will be done between the current and last builds, for example: $ bitbake core-image-sato @@ -236,17 +235,9 @@ Note: The "nostamp" task is not included. """ ) - parser.add_option("-v", "--verbose", help = "print the verbose changes", - action = "store_true", dest = "verbose") - - options, args = parser.parse_args(sys.argv) - - verbose = options.verbose - - if len(args) != 2: - parser.error("Incorrect number of arguments") - else: - recipe = args[1] + parser.add_argument("recipe", help="recipe to check") + parser.add_argument("-v", "--verbose", help = "print the verbose changes", action = "store_true") + args = parser.parse_args() # Get the STAMPS_DIR print("Figuring out the STAMPS_DIR ...") @@ -256,7 +247,7 @@ Note: except: raise if not stampsdir: - print("ERROR: No STAMPS_DIR found for '%s'" % recipe, file=sys.stderr) + print("ERROR: No STAMPS_DIR found for '%s'" % args.recipe, file=sys.stderr) return 2 stampsdir = stampsdir.rstrip("\n") if not os.path.isdir(stampsdir): @@ -272,7 +263,7 @@ Note: try: # Generate the new stamps dir print("Generating the new stamps ... (need several minutes)") - cmdline = "STAMPS_DIR=%s bitbake -S none %s" % (new_stampsdir, recipe) + cmdline = "STAMPS_DIR=%s bitbake -S none %s" % (new_stampsdir, args.recipe) # FIXME # The "bitbake -S" may fail, not fatal error, the stamps will still # be generated, this might be a bug of "bitbake -S". @@ -287,7 +278,7 @@ Note: # Remove the same one from both stamps. cnt_unchanged = 0 - for k in new_dict.keys(): + for k in list(new_dict.keys()): if k in old_dict: cnt_unchanged += 1 del(new_dict[k]) @@ -310,17 +301,17 @@ Note: # PV (including PE) and PR changed # Let the bb.siggen handle them if verbose cnt_rv = {} - if not verbose: + if not args.verbose: for i in ('pv', 'pr'): cnt_rv[i] = print_vrchanged(new_recon, old_recon, i) # Dependencies changed (use bitbake-diffsigs) - cnt_dep = print_depchanged(new_recon, old_recon, verbose) + cnt_dep = print_depchanged(new_recon, old_recon, args.verbose) total_changed = cnt_added + (cnt_rv.get('pv') or 0) + (cnt_rv.get('pr') or 0) + cnt_dep print("\n=== Summary: (%s changed, %s unchanged)" % (total_changed, cnt_unchanged)) - if verbose: + if args.verbose: print("Newly added: %s\nDependencies changed: %s\n" % \ (cnt_added, cnt_dep)) else: |