diff options
Diffstat (limited to 'scripts')
-rw-r--r-- | scripts/lib/devtool/upgrade.py | 28 |
1 files changed, 18 insertions, 10 deletions
diff --git a/scripts/lib/devtool/upgrade.py b/scripts/lib/devtool/upgrade.py index 62ec2f94cb..706f91c935 100644 --- a/scripts/lib/devtool/upgrade.py +++ b/scripts/lib/devtool/upgrade.py | |||
@@ -122,18 +122,22 @@ def _cleanup_on_error(rf, srctree): | |||
122 | rfp = os.path.split(rf)[0] # recipe folder | 122 | rfp = os.path.split(rf)[0] # recipe folder |
123 | rfpp = os.path.split(rfp)[0] # recipes folder | 123 | rfpp = os.path.split(rfp)[0] # recipes folder |
124 | if os.path.exists(rfp): | 124 | if os.path.exists(rfp): |
125 | shutil.rmtree(b) | 125 | shutil.rmtree(rfp) |
126 | if not len(os.listdir(rfpp)): | 126 | if not len(os.listdir(rfpp)): |
127 | os.rmdir(rfpp) | 127 | os.rmdir(rfpp) |
128 | srctree = os.path.abspath(srctree) | 128 | srctree = os.path.abspath(srctree) |
129 | if os.path.exists(srctree): | 129 | if os.path.exists(srctree): |
130 | shutil.rmtree(srctree) | 130 | shutil.rmtree(srctree) |
131 | 131 | ||
132 | def _upgrade_error(e, rf, srctree): | 132 | def _upgrade_error(e, rf, srctree, keep_failure=False, extramsg=None): |
133 | if rf: | 133 | if rf and not keep_failure: |
134 | cleanup_on_error(rf, srctree) | 134 | _cleanup_on_error(rf, srctree) |
135 | logger.error(e) | 135 | logger.error(e) |
136 | raise DevtoolError(e) | 136 | if extramsg: |
137 | logger.error(extramsg) | ||
138 | if keep_failure: | ||
139 | logger.info('Preserving failed upgrade files (--keep-failure)') | ||
140 | sys.exit(1) | ||
137 | 141 | ||
138 | def _get_uri(rd): | 142 | def _get_uri(rd): |
139 | srcuris = rd.getVar('SRC_URI').split() | 143 | srcuris = rd.getVar('SRC_URI').split() |
@@ -299,7 +303,7 @@ def _add_license_diff_to_recipe(path, diff): | |||
299 | f.write("\n#\n\n".encode()) | 303 | f.write("\n#\n\n".encode()) |
300 | f.write(orig_content) | 304 | f.write(orig_content) |
301 | 305 | ||
302 | def _create_new_recipe(newpv, md5, sha256, srcrev, srcbranch, srcsubdir_old, srcsubdir_new, workspace, tinfoil, rd, license_diff, new_licenses): | 306 | def _create_new_recipe(newpv, md5, sha256, srcrev, srcbranch, srcsubdir_old, srcsubdir_new, workspace, tinfoil, rd, license_diff, new_licenses, srctree, keep_failure): |
303 | """Creates the new recipe under workspace""" | 307 | """Creates the new recipe under workspace""" |
304 | 308 | ||
305 | bpn = rd.getVar('BPN') | 309 | bpn = rd.getVar('BPN') |
@@ -416,7 +420,10 @@ def _create_new_recipe(newpv, md5, sha256, srcrev, srcbranch, srcsubdir_old, src | |||
416 | newvalues["LIC_FILES_CHKSUM"] = newlicchksum | 420 | newvalues["LIC_FILES_CHKSUM"] = newlicchksum |
417 | _add_license_diff_to_recipe(fullpath, license_diff) | 421 | _add_license_diff_to_recipe(fullpath, license_diff) |
418 | 422 | ||
419 | rd = tinfoil.parse_recipe_file(fullpath, False) | 423 | try: |
424 | rd = tinfoil.parse_recipe_file(fullpath, False) | ||
425 | except bb.tinfoil.TinfoilCommandFailed as e: | ||
426 | _upgrade_error(e, fullpath, srctree, keep_failure, 'Parsing of upgraded recipe failed') | ||
420 | oe.recipeutils.patch_recipe(rd, fullpath, newvalues) | 427 | oe.recipeutils.patch_recipe(rd, fullpath, newvalues) |
421 | 428 | ||
422 | return fullpath, copied | 429 | return fullpath, copied |
@@ -548,11 +555,11 @@ def upgrade(args, config, basepath, workspace): | |||
548 | tinfoil, rd) | 555 | tinfoil, rd) |
549 | new_licenses = _extract_licenses(srctree, rd.getVar('LIC_FILES_CHKSUM')) | 556 | new_licenses = _extract_licenses(srctree, rd.getVar('LIC_FILES_CHKSUM')) |
550 | license_diff = _generate_license_diff(old_licenses, new_licenses) | 557 | license_diff = _generate_license_diff(old_licenses, new_licenses) |
551 | rf, copied = _create_new_recipe(args.version, md5, sha256, args.srcrev, srcbranch, srcsubdir1, srcsubdir2, config.workspace_path, tinfoil, rd, license_diff, new_licenses) | 558 | rf, copied = _create_new_recipe(args.version, md5, sha256, args.srcrev, srcbranch, srcsubdir1, srcsubdir2, config.workspace_path, tinfoil, rd, license_diff, new_licenses, srctree, args.keep_failure) |
552 | except bb.process.CmdError as e: | 559 | except bb.process.CmdError as e: |
553 | _upgrade_error(e, rf, srctree) | 560 | _upgrade_error(e, rf, srctree, args.keep_failure) |
554 | except DevtoolError as e: | 561 | except DevtoolError as e: |
555 | _upgrade_error(e, rf, srctree) | 562 | _upgrade_error(e, rf, srctree, args.keep_failure) |
556 | standard._add_md5(config, pn, os.path.dirname(rf)) | 563 | standard._add_md5(config, pn, os.path.dirname(rf)) |
557 | 564 | ||
558 | af = _write_append(rf, srctree, args.same_dir, args.no_same_dir, rev2, | 565 | af = _write_append(rf, srctree, args.same_dir, args.no_same_dir, rev2, |
@@ -623,6 +630,7 @@ def register_commands(subparsers, context): | |||
623 | group.add_argument('--same-dir', '-s', help='Build in same directory as source', action="store_true") | 630 | group.add_argument('--same-dir', '-s', help='Build in same directory as source', action="store_true") |
624 | group.add_argument('--no-same-dir', help='Force build in a separate build directory', action="store_true") | 631 | group.add_argument('--no-same-dir', help='Force build in a separate build directory', action="store_true") |
625 | parser_upgrade.add_argument('--keep-temp', action="store_true", help='Keep temporary directory (for debugging)') | 632 | parser_upgrade.add_argument('--keep-temp', action="store_true", help='Keep temporary directory (for debugging)') |
633 | parser_upgrade.add_argument('--keep-failure', action="store_true", help='Keep failed upgrade recipe and associated files (for debugging)') | ||
626 | parser_upgrade.set_defaults(func=upgrade, fixed_setup=context.fixed_setup) | 634 | parser_upgrade.set_defaults(func=upgrade, fixed_setup=context.fixed_setup) |
627 | 635 | ||
628 | parser_latest_version = subparsers.add_parser('latest-version', help='Report the latest version of an existing recipe', | 636 | parser_latest_version = subparsers.add_parser('latest-version', help='Report the latest version of an existing recipe', |