diff options
author | Paul Eggleton <paul.eggleton@linux.intel.com> | 2017-11-08 10:52:15 +1300 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2017-11-11 12:14:27 +0000 |
commit | d906d7cea814de917baf70eb3ecb568862fbc363 (patch) | |
tree | 467e4045745e7ec6cb6a71e9bd67756be6c46173 /scripts/lib/devtool | |
parent | 541b7e2ce043524d2310fd642dbce4daa70f8457 (diff) | |
download | poky-d906d7cea814de917baf70eb3ecb568862fbc363.tar.gz |
devtool: finish: improve reporting for removed files
If a file is going to be effectively removed from the destination by
devtool finish, we should report that rather than just reporting that
we're removing files from the workspace. This is a little tricky because
the way we actually operate when finishing is to:
(1) remove all original files (as recorded by devtool upgrade, if that
was used)
(2) as part of updating the recipe file, remove the files from next to
the new recipe (i.e. in the workspace for an upgrade, real recipe
otherwise) corresponding to commits not in the git tree
(3) copy over remaining files from the workspace to the destination
To report the files removed with respect to what was originally there,
we need to swap steps 1 and 2 so we can see what no longer exists after
the deletion, and suppress the reporting currently done in step 2 -
however, we still want to report removal in step 2 for the non-upgrade
case, so the latter is conditional.
(From OE-Core rev: db1d663507509cac9d97d7c96ac8590478767ba2)
Signed-off-by: Paul Eggleton <paul.eggleton@linux.intel.com>
Signed-off-by: Ross Burton <ross.burton@intel.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'scripts/lib/devtool')
-rw-r--r-- | scripts/lib/devtool/standard.py | 32 |
1 files changed, 18 insertions, 14 deletions
diff --git a/scripts/lib/devtool/standard.py b/scripts/lib/devtool/standard.py index 1e7d707d68..9d9031c2b3 100644 --- a/scripts/lib/devtool/standard.py +++ b/scripts/lib/devtool/standard.py | |||
@@ -1054,7 +1054,7 @@ def _replace_srcuri_entry(srcuri, filename, newentry): | |||
1054 | srcuri.insert(i, newentry) | 1054 | srcuri.insert(i, newentry) |
1055 | break | 1055 | break |
1056 | 1056 | ||
1057 | def _remove_source_files(append, files, destpath): | 1057 | def _remove_source_files(append, files, destpath, no_report_remove=False): |
1058 | """Unlink existing patch files""" | 1058 | """Unlink existing patch files""" |
1059 | for path in files: | 1059 | for path in files: |
1060 | if append: | 1060 | if append: |
@@ -1063,7 +1063,8 @@ def _remove_source_files(append, files, destpath): | |||
1063 | path = os.path.join(destpath, os.path.basename(path)) | 1063 | path = os.path.join(destpath, os.path.basename(path)) |
1064 | 1064 | ||
1065 | if os.path.exists(path): | 1065 | if os.path.exists(path): |
1066 | logger.info('Removing file %s' % path) | 1066 | if not no_report_remove: |
1067 | logger.info('Removing file %s' % path) | ||
1067 | # FIXME "git rm" here would be nice if the file in question is | 1068 | # FIXME "git rm" here would be nice if the file in question is |
1068 | # tracked | 1069 | # tracked |
1069 | # FIXME there's a chance that this file is referred to by | 1070 | # FIXME there's a chance that this file is referred to by |
@@ -1276,7 +1277,7 @@ def _determine_files_dir(rd): | |||
1276 | return os.path.join(recipedir, rd.getVar('BPN')) | 1277 | return os.path.join(recipedir, rd.getVar('BPN')) |
1277 | 1278 | ||
1278 | 1279 | ||
1279 | def _update_recipe_srcrev(recipename, workspace, srctree, rd, appendlayerdir, wildcard_version, no_remove): | 1280 | def _update_recipe_srcrev(recipename, workspace, srctree, rd, appendlayerdir, wildcard_version, no_remove, no_report_remove): |
1280 | """Implement the 'srcrev' mode of update-recipe""" | 1281 | """Implement the 'srcrev' mode of update-recipe""" |
1281 | import bb | 1282 | import bb |
1282 | import oe.recipeutils | 1283 | import oe.recipeutils |
@@ -1357,10 +1358,10 @@ def _update_recipe_srcrev(recipename, workspace, srctree, rd, appendlayerdir, wi | |||
1357 | 'point to a git repository where you have pushed your ' | 1358 | 'point to a git repository where you have pushed your ' |
1358 | 'changes') | 1359 | 'changes') |
1359 | 1360 | ||
1360 | _remove_source_files(appendlayerdir, remove_files, destpath) | 1361 | _remove_source_files(appendlayerdir, remove_files, destpath, no_report_remove) |
1361 | return True | 1362 | return True |
1362 | 1363 | ||
1363 | def _update_recipe_patch(recipename, workspace, srctree, rd, appendlayerdir, wildcard_version, no_remove, initial_rev): | 1364 | def _update_recipe_patch(recipename, workspace, srctree, rd, appendlayerdir, wildcard_version, no_remove, no_report_remove, initial_rev): |
1364 | """Implement the 'patch' mode of update-recipe""" | 1365 | """Implement the 'patch' mode of update-recipe""" |
1365 | import bb | 1366 | import bb |
1366 | import oe.recipeutils | 1367 | import oe.recipeutils |
@@ -1476,7 +1477,7 @@ def _update_recipe_patch(recipename, workspace, srctree, rd, appendlayerdir, wil | |||
1476 | finally: | 1477 | finally: |
1477 | shutil.rmtree(tempdir) | 1478 | shutil.rmtree(tempdir) |
1478 | 1479 | ||
1479 | _remove_source_files(appendlayerdir, remove_files, destpath) | 1480 | _remove_source_files(appendlayerdir, remove_files, destpath, no_report_remove) |
1480 | return True | 1481 | return True |
1481 | 1482 | ||
1482 | def _guess_recipe_update_mode(srctree, rdata): | 1483 | def _guess_recipe_update_mode(srctree, rdata): |
@@ -1501,15 +1502,15 @@ def _guess_recipe_update_mode(srctree, rdata): | |||
1501 | 1502 | ||
1502 | return 'patch' | 1503 | return 'patch' |
1503 | 1504 | ||
1504 | def _update_recipe(recipename, workspace, rd, mode, appendlayerdir, wildcard_version, no_remove, initial_rev): | 1505 | def _update_recipe(recipename, workspace, rd, mode, appendlayerdir, wildcard_version, no_remove, initial_rev, no_report_remove=False): |
1505 | srctree = workspace[recipename]['srctree'] | 1506 | srctree = workspace[recipename]['srctree'] |
1506 | if mode == 'auto': | 1507 | if mode == 'auto': |
1507 | mode = _guess_recipe_update_mode(srctree, rd) | 1508 | mode = _guess_recipe_update_mode(srctree, rd) |
1508 | 1509 | ||
1509 | if mode == 'srcrev': | 1510 | if mode == 'srcrev': |
1510 | updated = _update_recipe_srcrev(recipename, workspace, srctree, rd, appendlayerdir, wildcard_version, no_remove) | 1511 | updated = _update_recipe_srcrev(recipename, workspace, srctree, rd, appendlayerdir, wildcard_version, no_remove, no_report_remove) |
1511 | elif mode == 'patch': | 1512 | elif mode == 'patch': |
1512 | updated = _update_recipe_patch(recipename, workspace, srctree, rd, appendlayerdir, wildcard_version, no_remove, initial_rev) | 1513 | updated = _update_recipe_patch(recipename, workspace, srctree, rd, appendlayerdir, wildcard_version, no_remove, no_report_remove, initial_rev) |
1513 | else: | 1514 | else: |
1514 | raise DevtoolError('update_recipe: invalid mode %s' % mode) | 1515 | raise DevtoolError('update_recipe: invalid mode %s' % mode) |
1515 | return updated | 1516 | return updated |
@@ -1745,24 +1746,27 @@ def finish(args, config, basepath, workspace): | |||
1745 | appendlayerdir = destlayerdir | 1746 | appendlayerdir = destlayerdir |
1746 | destpath = None | 1747 | destpath = None |
1747 | 1748 | ||
1749 | # Actually update the recipe / bbappend | ||
1750 | removing_original = (origpath and origfilelist and oe.recipeutils.find_layerdir(origpath) == destlayerbasedir) | ||
1751 | _update_recipe(args.recipename, workspace, rd, args.mode, appendlayerdir, wildcard_version=True, no_remove=False, initial_rev=args.initial_rev, no_report_remove=removing_original) | ||
1752 | |||
1748 | # Remove any old files in the case of an upgrade | 1753 | # Remove any old files in the case of an upgrade |
1749 | if origpath and origfilelist and oe.recipeutils.find_layerdir(origpath) == destlayerbasedir: | 1754 | recipedir = os.path.dirname(rd.getVar('FILE')) |
1755 | if removing_original: | ||
1750 | for fn in origfilelist: | 1756 | for fn in origfilelist: |
1751 | fnp = os.path.join(origpath, fn) | 1757 | fnp = os.path.join(origpath, fn) |
1758 | if not os.path.exists(os.path.join(recipedir, fn)): | ||
1759 | logger.info('Removing file %s' % fnp) | ||
1752 | try: | 1760 | try: |
1753 | os.remove(fnp) | 1761 | os.remove(fnp) |
1754 | except FileNotFoundError: | 1762 | except FileNotFoundError: |
1755 | pass | 1763 | pass |
1756 | 1764 | ||
1757 | # Actually update the recipe / bbappend | ||
1758 | _update_recipe(args.recipename, workspace, rd, args.mode, appendlayerdir, wildcard_version=True, no_remove=False, initial_rev=args.initial_rev) | ||
1759 | |||
1760 | if origlayerdir == config.workspace_path and destpath: | 1765 | if origlayerdir == config.workspace_path and destpath: |
1761 | # Recipe file itself is in the workspace - need to move it and any | 1766 | # Recipe file itself is in the workspace - need to move it and any |
1762 | # associated files to the specified layer | 1767 | # associated files to the specified layer |
1763 | no_clean = True | 1768 | no_clean = True |
1764 | logger.info('Moving recipe file to %s' % destpath) | 1769 | logger.info('Moving recipe file to %s' % destpath) |
1765 | recipedir = os.path.dirname(rd.getVar('FILE')) | ||
1766 | for root, _, files in os.walk(recipedir): | 1770 | for root, _, files in os.walk(recipedir): |
1767 | for fn in files: | 1771 | for fn in files: |
1768 | srcpath = os.path.join(root, fn) | 1772 | srcpath = os.path.join(root, fn) |