summaryrefslogtreecommitdiffstats
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:11:14 +0100
commit21af6c60b0b5368bacd809dbea91125bc717ce43 (patch)
tree1b8b8d3391e51f29a448ffe2d7c19a304164ec17
parentaac36591db785922aba262e6c5b5fca11a115d4c (diff)
downloadpoky-21af6c60b0b5368bacd809dbea91125bc717ce43.tar.gz
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] (From OE-Core rev: b6c71616e66708bb1c456b83f98913b198f49a4a) Signed-off-by: Humberto Ibarra <humberto.ibarra.lopez@intel.com> Signed-off-by: Ross Burton <ross.burton@intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
-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
25import re 25import re
26import warnings 26import warnings
27import subprocess 27import subprocess
28from optparse import OptionParser 28import argparse
29 29
30scripts_path = os.path.abspath(os.path.dirname(os.path.abspath(sys.argv[0]))) 30scripts_path = os.path.abspath(os.path.dirname(os.path.abspath(sys.argv[0])))
31lib_path = scripts_path + '/lib' 31lib_path = scripts_path + '/lib'
@@ -38,6 +38,8 @@ bitbakepath = scriptpath.add_bitbake_lib_path()
38if not bitbakepath: 38if not bitbakepath:
39 sys.stderr.write("Unable to find bitbake by searching parent directory of this script or PATH\n") 39 sys.stderr.write("Unable to find bitbake by searching parent directory of this script or PATH\n")
40 sys.exit(1) 40 sys.exit(1)
41scriptpath.add_oe_lib_path()
42import argparse_oe
41 43
42import bb.siggen 44import bb.siggen
43import bb.process 45import bb.process
@@ -219,9 +221,7 @@ def main():
219 3) Use bb.siggen.compare_sigfiles to diff the old and new stamps 221 3) Use bb.siggen.compare_sigfiles to diff the old and new stamps
220 """ 222 """
221 223
222 parser = OptionParser( 224 parser = argparse_oe.ArgumentParser(usage = """%(prog)s [options] [package ...]
223 version = "1.0",
224 usage = """%prog [options] [package ...]
225print what will be done between the current and last builds, for example: 225print what will be done between the current and last builds, for example:
226 226
227 $ bitbake core-image-sato 227 $ bitbake core-image-sato
@@ -236,17 +236,9 @@ Note:
236 The "nostamp" task is not included. 236 The "nostamp" task is not included.
237""" 237"""
238) 238)
239 parser.add_option("-v", "--verbose", help = "print the verbose changes", 239 parser.add_argument("recipe", help="recipe to check")
240 action = "store_true", dest = "verbose") 240 parser.add_argument("-v", "--verbose", help = "print the verbose changes", action = "store_true")
241 241 args = parser.parse_args()
242 options, args = parser.parse_args(sys.argv)
243
244 verbose = options.verbose
245
246 if len(args) != 2:
247 parser.error("Incorrect number of arguments")
248 else:
249 recipe = args[1]
250 242
251 # Get the STAMPS_DIR 243 # Get the STAMPS_DIR
252 print("Figuring out the STAMPS_DIR ...") 244 print("Figuring out the STAMPS_DIR ...")
@@ -256,7 +248,7 @@ Note:
256 except: 248 except:
257 raise 249 raise
258 if not stampsdir: 250 if not stampsdir:
259 print("ERROR: No STAMPS_DIR found for '%s'" % recipe, file=sys.stderr) 251 print("ERROR: No STAMPS_DIR found for '%s'" % args.recipe, file=sys.stderr)
260 return 2 252 return 2
261 stampsdir = stampsdir.rstrip("\n") 253 stampsdir = stampsdir.rstrip("\n")
262 if not os.path.isdir(stampsdir): 254 if not os.path.isdir(stampsdir):
@@ -272,7 +264,7 @@ Note:
272 try: 264 try:
273 # Generate the new stamps dir 265 # Generate the new stamps dir
274 print("Generating the new stamps ... (need several minutes)") 266 print("Generating the new stamps ... (need several minutes)")
275 cmdline = "STAMPS_DIR=%s bitbake -S none %s" % (new_stampsdir, recipe) 267 cmdline = "STAMPS_DIR=%s bitbake -S none %s" % (new_stampsdir, args.recipe)
276 # FIXME 268 # FIXME
277 # The "bitbake -S" may fail, not fatal error, the stamps will still 269 # The "bitbake -S" may fail, not fatal error, the stamps will still
278 # be generated, this might be a bug of "bitbake -S". 270 # be generated, this might be a bug of "bitbake -S".
@@ -310,17 +302,17 @@ Note:
310 # PV (including PE) and PR changed 302 # PV (including PE) and PR changed
311 # Let the bb.siggen handle them if verbose 303 # Let the bb.siggen handle them if verbose
312 cnt_rv = {} 304 cnt_rv = {}
313 if not verbose: 305 if not args.verbose:
314 for i in ('pv', 'pr'): 306 for i in ('pv', 'pr'):
315 cnt_rv[i] = print_vrchanged(new_recon, old_recon, i) 307 cnt_rv[i] = print_vrchanged(new_recon, old_recon, i)
316 308
317 # Dependencies changed (use bitbake-diffsigs) 309 # Dependencies changed (use bitbake-diffsigs)
318 cnt_dep = print_depchanged(new_recon, old_recon, verbose) 310 cnt_dep = print_depchanged(new_recon, old_recon, args.verbose)
319 311
320 total_changed = cnt_added + (cnt_rv.get('pv') or 0) + (cnt_rv.get('pr') or 0) + cnt_dep 312 total_changed = cnt_added + (cnt_rv.get('pv') or 0) + (cnt_rv.get('pr') or 0) + cnt_dep
321 313
322 print("\n=== Summary: (%s changed, %s unchanged)" % (total_changed, cnt_unchanged)) 314 print("\n=== Summary: (%s changed, %s unchanged)" % (total_changed, cnt_unchanged))
323 if verbose: 315 if args.verbose:
324 print("Newly added: %s\nDependencies changed: %s\n" % \ 316 print("Newly added: %s\nDependencies changed: %s\n" % \
325 (cnt_added, cnt_dep)) 317 (cnt_added, cnt_dep))
326 else: 318 else: