summaryrefslogtreecommitdiffstats
path: root/scripts/lib
diff options
context:
space:
mode:
Diffstat (limited to 'scripts/lib')
-rw-r--r--scripts/lib/devtool/standard.py32
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
1057def _remove_source_files(append, files, destpath): 1057def _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
1279def _update_recipe_srcrev(recipename, workspace, srctree, rd, appendlayerdir, wildcard_version, no_remove): 1280def _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
1363def _update_recipe_patch(recipename, workspace, srctree, rd, appendlayerdir, wildcard_version, no_remove, initial_rev): 1364def _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
1482def _guess_recipe_update_mode(srctree, rdata): 1483def _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
1504def _update_recipe(recipename, workspace, rd, mode, appendlayerdir, wildcard_version, no_remove, initial_rev): 1505def _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)