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>
This commit is contained in:
Paul Eggleton
2017-11-08 10:52:15 +13:00
committed by Richard Purdie
parent 541b7e2ce0
commit d906d7cea8

View File

@@ -1054,7 +1054,7 @@ def _replace_srcuri_entry(srcuri, filename, newentry):
srcuri.insert(i, newentry)
break
def _remove_source_files(append, files, destpath):
def _remove_source_files(append, files, destpath, no_report_remove=False):
"""Unlink existing patch files"""
for path in files:
if append:
@@ -1063,7 +1063,8 @@ def _remove_source_files(append, files, destpath):
path = os.path.join(destpath, os.path.basename(path))
if os.path.exists(path):
logger.info('Removing file %s' % path)
if not no_report_remove:
logger.info('Removing file %s' % path)
# FIXME "git rm" here would be nice if the file in question is
# tracked
# FIXME there's a chance that this file is referred to by
@@ -1276,7 +1277,7 @@ def _determine_files_dir(rd):
return os.path.join(recipedir, rd.getVar('BPN'))
def _update_recipe_srcrev(recipename, workspace, srctree, rd, appendlayerdir, wildcard_version, no_remove):
def _update_recipe_srcrev(recipename, workspace, srctree, rd, appendlayerdir, wildcard_version, no_remove, no_report_remove):
"""Implement the 'srcrev' mode of update-recipe"""
import bb
import oe.recipeutils
@@ -1357,10 +1358,10 @@ def _update_recipe_srcrev(recipename, workspace, srctree, rd, appendlayerdir, wi
'point to a git repository where you have pushed your '
'changes')
_remove_source_files(appendlayerdir, remove_files, destpath)
_remove_source_files(appendlayerdir, remove_files, destpath, no_report_remove)
return True
def _update_recipe_patch(recipename, workspace, srctree, rd, appendlayerdir, wildcard_version, no_remove, initial_rev):
def _update_recipe_patch(recipename, workspace, srctree, rd, appendlayerdir, wildcard_version, no_remove, no_report_remove, initial_rev):
"""Implement the 'patch' mode of update-recipe"""
import bb
import oe.recipeutils
@@ -1476,7 +1477,7 @@ def _update_recipe_patch(recipename, workspace, srctree, rd, appendlayerdir, wil
finally:
shutil.rmtree(tempdir)
_remove_source_files(appendlayerdir, remove_files, destpath)
_remove_source_files(appendlayerdir, remove_files, destpath, no_report_remove)
return True
def _guess_recipe_update_mode(srctree, rdata):
@@ -1501,15 +1502,15 @@ def _guess_recipe_update_mode(srctree, rdata):
return 'patch'
def _update_recipe(recipename, workspace, rd, mode, appendlayerdir, wildcard_version, no_remove, initial_rev):
def _update_recipe(recipename, workspace, rd, mode, appendlayerdir, wildcard_version, no_remove, initial_rev, no_report_remove=False):
srctree = workspace[recipename]['srctree']
if mode == 'auto':
mode = _guess_recipe_update_mode(srctree, rd)
if mode == 'srcrev':
updated = _update_recipe_srcrev(recipename, workspace, srctree, rd, appendlayerdir, wildcard_version, no_remove)
updated = _update_recipe_srcrev(recipename, workspace, srctree, rd, appendlayerdir, wildcard_version, no_remove, no_report_remove)
elif mode == 'patch':
updated = _update_recipe_patch(recipename, workspace, srctree, rd, appendlayerdir, wildcard_version, no_remove, initial_rev)
updated = _update_recipe_patch(recipename, workspace, srctree, rd, appendlayerdir, wildcard_version, no_remove, no_report_remove, initial_rev)
else:
raise DevtoolError('update_recipe: invalid mode %s' % mode)
return updated
@@ -1745,24 +1746,27 @@ def finish(args, config, basepath, workspace):
appendlayerdir = destlayerdir
destpath = None
# Actually update the recipe / bbappend
removing_original = (origpath and origfilelist and oe.recipeutils.find_layerdir(origpath) == destlayerbasedir)
_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)
# Remove any old files in the case of an upgrade
if origpath and origfilelist and oe.recipeutils.find_layerdir(origpath) == destlayerbasedir:
recipedir = os.path.dirname(rd.getVar('FILE'))
if removing_original:
for fn in origfilelist:
fnp = os.path.join(origpath, fn)
if not os.path.exists(os.path.join(recipedir, fn)):
logger.info('Removing file %s' % fnp)
try:
os.remove(fnp)
except FileNotFoundError:
pass
# Actually update the recipe / bbappend
_update_recipe(args.recipename, workspace, rd, args.mode, appendlayerdir, wildcard_version=True, no_remove=False, initial_rev=args.initial_rev)
if origlayerdir == config.workspace_path and destpath:
# Recipe file itself is in the workspace - need to move it and any
# associated files to the specified layer
no_clean = True
logger.info('Moving recipe file to %s' % destpath)
recipedir = os.path.dirname(rd.getVar('FILE'))
for root, _, files in os.walk(recipedir):
for fn in files:
srcpath = os.path.join(root, fn)