summaryrefslogtreecommitdiff
path: root/scripts/bitbake-whatchanged
diff options
context:
space:
mode:
authorHumberto Ibarra <humberto.ibarra.lopez@intel.com>2016-05-19 14:51:54 -0500
committerRichard Purdie <richard.purdie@linuxfoundation.org>2016-05-22 16:09:22 +0100
commitb6c71616e66708bb1c456b83f98913b198f49a4a (patch)
tree37e254c7c2484bd58db2abdf70896aa5bb4ae024 /scripts/bitbake-whatchanged
parent8016b51d81ca9ed1567effa9d2870b1d98684350 (diff)
downloadopenembedded-core-b6c71616e66708bb1c456b83f98913b198f49a4a.tar.gz
openembedded-core-b6c71616e66708bb1c456b83f98913b198f49a4a.tar.bz2
openembedded-core-b6c71616e66708bb1c456b83f98913b198f49a4a.zip
scripts/bitbake-whatchanged: migrate from optparse to argparse
The script bitbake-whatchanged uses optparse library, which is deprecated since python 2.7. This migrates to argparse library. [Yocto #9634] Signed-off-by: Humberto Ibarra <humberto.ibarra.lopez@intel.com> Signed-off-by: Ross Burton <ross.burton@intel.com>
Diffstat (limited to 'scripts/bitbake-whatchanged')
-rwxr-xr-xscripts/bitbake-whatchanged32
1 files changed, 12 insertions, 20 deletions
diff --git a/scripts/bitbake-whatchanged b/scripts/bitbake-whatchanged
index af54d16f8b..a20adb2841 100755
--- a/scripts/bitbake-whatchanged
+++ b/scripts/bitbake-whatchanged
@@ -25,7 +25,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 +38,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
@@ -219,9 +221,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 +236,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 +248,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 +264,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".
@@ -310,17 +302,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: