diff options
Diffstat (limited to 'scripts/lib')
| -rw-r--r-- | scripts/lib/devtool/standard.py | 100 | ||||
| -rw-r--r-- | scripts/lib/devtool/upgrade.py | 2 |
2 files changed, 80 insertions, 22 deletions
diff --git a/scripts/lib/devtool/standard.py b/scripts/lib/devtool/standard.py index 1285974d44..7d7c77a6e9 100644 --- a/scripts/lib/devtool/standard.py +++ b/scripts/lib/devtool/standard.py | |||
| @@ -238,7 +238,29 @@ def extract(args, config, basepath, workspace): | |||
| 238 | return 1 | 238 | return 1 |
| 239 | 239 | ||
| 240 | srctree = os.path.abspath(args.srctree) | 240 | srctree = os.path.abspath(args.srctree) |
| 241 | initial_rev = _extract_source(srctree, args.keep_temp, args.branch, rd) | 241 | initial_rev = _extract_source(srctree, args.keep_temp, args.branch, False, rd) |
| 242 | logger.info('Source tree extracted to %s' % srctree) | ||
| 243 | |||
| 244 | if initial_rev: | ||
| 245 | return 0 | ||
| 246 | else: | ||
| 247 | return 1 | ||
| 248 | |||
| 249 | def sync(args, config, basepath, workspace): | ||
| 250 | """Entry point for the devtool 'sync' subcommand""" | ||
| 251 | import bb | ||
| 252 | |||
| 253 | tinfoil = _prep_extract_operation(config, basepath, args.recipename) | ||
| 254 | if not tinfoil: | ||
| 255 | # Error already shown | ||
| 256 | return 1 | ||
| 257 | |||
| 258 | rd = parse_recipe(config, tinfoil, args.recipename, True) | ||
| 259 | if not rd: | ||
| 260 | return 1 | ||
| 261 | |||
| 262 | srctree = os.path.abspath(args.srctree) | ||
| 263 | initial_rev = _extract_source(srctree, args.keep_temp, args.branch, True, rd) | ||
| 242 | logger.info('Source tree extracted to %s' % srctree) | 264 | logger.info('Source tree extracted to %s' % srctree) |
| 243 | 265 | ||
| 244 | if initial_rev: | 266 | if initial_rev: |
| @@ -293,7 +315,7 @@ def _prep_extract_operation(config, basepath, recipename): | |||
| 293 | return tinfoil | 315 | return tinfoil |
| 294 | 316 | ||
| 295 | 317 | ||
| 296 | def _extract_source(srctree, keep_temp, devbranch, d): | 318 | def _extract_source(srctree, keep_temp, devbranch, sync, d): |
| 297 | """Extract sources of a recipe""" | 319 | """Extract sources of a recipe""" |
| 298 | import bb.event | 320 | import bb.event |
| 299 | import oe.recipeutils | 321 | import oe.recipeutils |
| @@ -312,21 +334,26 @@ def _extract_source(srctree, keep_temp, devbranch, d): | |||
| 312 | 334 | ||
| 313 | _check_compatible_recipe(pn, d) | 335 | _check_compatible_recipe(pn, d) |
| 314 | 336 | ||
| 315 | if os.path.exists(srctree): | 337 | if sync: |
| 316 | if not os.path.isdir(srctree): | 338 | if not os.path.exists(srctree): |
| 317 | raise DevtoolError("output path %s exists and is not a directory" % | 339 | raise DevtoolError("output path %s does not exist" % srctree) |
| 318 | srctree) | 340 | else: |
| 319 | elif os.listdir(srctree): | 341 | if os.path.exists(srctree): |
| 320 | raise DevtoolError("output path %s already exists and is " | 342 | if not os.path.isdir(srctree): |
| 321 | "non-empty" % srctree) | 343 | raise DevtoolError("output path %s exists and is not a directory" % |
| 344 | srctree) | ||
| 345 | elif os.listdir(srctree): | ||
| 346 | raise DevtoolError("output path %s already exists and is " | ||
| 347 | "non-empty" % srctree) | ||
| 322 | 348 | ||
| 323 | if 'noexec' in (d.getVarFlags('do_unpack', False) or []): | 349 | if 'noexec' in (d.getVarFlags('do_unpack', False) or []): |
| 324 | raise DevtoolError("The %s recipe has do_unpack disabled, unable to " | 350 | raise DevtoolError("The %s recipe has do_unpack disabled, unable to " |
| 325 | "extract source" % pn) | 351 | "extract source" % pn) |
| 326 | 352 | ||
| 327 | # Prepare for shutil.move later on | 353 | if not sync: |
| 328 | bb.utils.mkdirhier(srctree) | 354 | # Prepare for shutil.move later on |
| 329 | os.rmdir(srctree) | 355 | bb.utils.mkdirhier(srctree) |
| 356 | os.rmdir(srctree) | ||
| 330 | 357 | ||
| 331 | # We don't want notes to be printed, they are too verbose | 358 | # We don't want notes to be printed, they are too verbose |
| 332 | origlevel = bb.logger.getEffectiveLevel() | 359 | origlevel = bb.logger.getEffectiveLevel() |
| @@ -430,13 +457,35 @@ def _extract_source(srctree, keep_temp, devbranch, d): | |||
| 430 | if haspatches: | 457 | if haspatches: |
| 431 | bb.process.run('git checkout patches', cwd=srcsubdir) | 458 | bb.process.run('git checkout patches', cwd=srcsubdir) |
| 432 | 459 | ||
| 433 | # Move oe-local-files directory to srctree | 460 | tempdir_localdir = os.path.join(tempdir, 'oe-local-files') |
| 434 | if os.path.exists(os.path.join(tempdir, 'oe-local-files')): | 461 | srctree_localdir = os.path.join(srctree, 'oe-local-files') |
| 435 | logger.info('Adding local source files to srctree...') | ||
| 436 | shutil.move(os.path.join(tempdir, 'oe-local-files'), srcsubdir) | ||
| 437 | 462 | ||
| 463 | if sync: | ||
| 464 | bb.process.run('git fetch file://' + srcsubdir + ' ' + devbranch + ':' + devbranch, cwd=srctree) | ||
| 465 | |||
| 466 | # Move oe-local-files directory to srctree | ||
| 467 | # As the oe-local-files is not part of the constructed git tree, | ||
| 468 | # remove them directly during the synchrounizating might surprise | ||
| 469 | # the users. Instead, we move it to oe-local-files.bak and remind | ||
| 470 | # user in the log message. | ||
| 471 | if os.path.exists(srctree_localdir + '.bak'): | ||
| 472 | shutil.rmtree(srctree_localdir, srctree_localdir + '.bak') | ||
| 473 | |||
| 474 | if os.path.exists(srctree_localdir): | ||
| 475 | logger.info('Backing up current local file directory %s' % srctree_localdir) | ||
| 476 | shutil.move(srctree_localdir, srctree_localdir + '.bak') | ||
| 477 | |||
| 478 | if os.path.exists(tempdir_localdir): | ||
| 479 | logger.info('Syncing local source files to srctree...') | ||
| 480 | shutil.copytree(tempdir_localdir, srctree_localdir) | ||
| 481 | else: | ||
| 482 | # Move oe-local-files directory to srctree | ||
| 483 | if os.path.exists(tempdir_localdir): | ||
| 484 | logger.info('Adding local source files to srctree...') | ||
| 485 | shutil.move(tempdir_localdir, srcsubdir) | ||
| 486 | |||
| 487 | shutil.move(srcsubdir, srctree) | ||
| 438 | 488 | ||
| 439 | shutil.move(srcsubdir, srctree) | ||
| 440 | finally: | 489 | finally: |
| 441 | bb.logger.setLevel(origlevel) | 490 | bb.logger.setLevel(origlevel) |
| 442 | 491 | ||
| @@ -544,7 +593,7 @@ def modify(args, config, basepath, workspace): | |||
| 544 | commits = [] | 593 | commits = [] |
| 545 | srctree = os.path.abspath(args.srctree) | 594 | srctree = os.path.abspath(args.srctree) |
| 546 | if args.extract: | 595 | if args.extract: |
| 547 | initial_rev = _extract_source(args.srctree, False, args.branch, rd) | 596 | initial_rev = _extract_source(args.srctree, False, args.branch, False, rd) |
| 548 | if not initial_rev: | 597 | if not initial_rev: |
| 549 | return 1 | 598 | return 1 |
| 550 | logger.info('Source tree extracted to %s' % srctree) | 599 | logger.info('Source tree extracted to %s' % srctree) |
| @@ -1119,6 +1168,15 @@ def register_commands(subparsers, context): | |||
| 1119 | parser_extract.add_argument('--keep-temp', action="store_true", help='Keep temporary directory (for debugging)') | 1168 | parser_extract.add_argument('--keep-temp', action="store_true", help='Keep temporary directory (for debugging)') |
| 1120 | parser_extract.set_defaults(func=extract) | 1169 | parser_extract.set_defaults(func=extract) |
| 1121 | 1170 | ||
| 1171 | parser_sync = subparsers.add_parser('sync', help='Synchronize the source for an existing recipe', | ||
| 1172 | description='Synchronize the source for an existing recipe', | ||
| 1173 | formatter_class=argparse.ArgumentDefaultsHelpFormatter) | ||
| 1174 | parser_sync.add_argument('recipename', help='Name for recipe to sync the source for') | ||
| 1175 | parser_sync.add_argument('srctree', help='Path to where to sync the source tree') | ||
| 1176 | parser_sync.add_argument('--branch', '-b', default="devtool", help='Name for development branch to checkout') | ||
| 1177 | parser_sync.add_argument('--keep-temp', action="store_true", help='Keep temporary directory (for debugging)') | ||
| 1178 | parser_sync.set_defaults(func=sync) | ||
| 1179 | |||
| 1122 | parser_update_recipe = subparsers.add_parser('update-recipe', help='Apply changes from external source tree to recipe', | 1180 | parser_update_recipe = subparsers.add_parser('update-recipe', help='Apply changes from external source tree to recipe', |
| 1123 | description='Applies changes from external source tree to a recipe (updating/adding/removing patches as necessary, or by updating SRCREV)') | 1181 | description='Applies changes from external source tree to a recipe (updating/adding/removing patches as necessary, or by updating SRCREV)') |
| 1124 | parser_update_recipe.add_argument('recipename', help='Name of recipe to update') | 1182 | parser_update_recipe.add_argument('recipename', help='Name of recipe to update') |
diff --git a/scripts/lib/devtool/upgrade.py b/scripts/lib/devtool/upgrade.py index d38762373e..5410c9dd02 100644 --- a/scripts/lib/devtool/upgrade.py +++ b/scripts/lib/devtool/upgrade.py | |||
| @@ -312,7 +312,7 @@ def upgrade(args, config, basepath, workspace): | |||
| 312 | 312 | ||
| 313 | rf = None | 313 | rf = None |
| 314 | try: | 314 | try: |
| 315 | rev1 = standard._extract_source(args.srctree, False, 'devtool-orig', rd) | 315 | rev1 = standard._extract_source(args.srctree, False, 'devtool-orig', False, rd) |
| 316 | rev2, md5, sha256 = _extract_new_source(args.version, args.srctree, args.no_patch, | 316 | rev2, md5, sha256 = _extract_new_source(args.version, args.srctree, args.no_patch, |
| 317 | args.srcrev, args.branch, args.keep_temp, | 317 | args.srcrev, args.branch, args.keep_temp, |
| 318 | tinfoil, rd) | 318 | tinfoil, rd) |
