diff options
author | Paul Eggleton <paul.eggleton@linux.intel.com> | 2016-07-14 09:04:23 +1200 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2016-07-20 10:28:49 +0100 |
commit | 7af3295b0b2eb65e8f541f358c3091918db65ab9 (patch) | |
tree | 1f21208aaad3fd61ae94a6275b7f3138959c72c1 /scripts/lib/devtool | |
parent | 5d78525a2d4f15fcfa60f42027cb869b00dc83c9 (diff) | |
download | poky-7af3295b0b2eb65e8f541f358c3091918db65ab9.tar.gz |
devtool: update-recipe: refactor to allow calling separately
This will be called by "devtool finish" to allow it to update the recipe
or create the bbappend depending on the destination.
(From OE-Core rev: 5067cdc73483b53d46d9bf584723e41957c7ec54)
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 | 56 |
1 files changed, 29 insertions, 27 deletions
diff --git a/scripts/lib/devtool/standard.py b/scripts/lib/devtool/standard.py index 769c3ce592..5a5995f664 100644 --- a/scripts/lib/devtool/standard.py +++ b/scripts/lib/devtool/standard.py | |||
@@ -876,10 +876,10 @@ def _remove_file_entries(srcuri, filelist): | |||
876 | break | 876 | break |
877 | return entries, remaining | 877 | return entries, remaining |
878 | 878 | ||
879 | def _remove_source_files(args, files, destpath): | 879 | def _remove_source_files(append, files, destpath): |
880 | """Unlink existing patch files""" | 880 | """Unlink existing patch files""" |
881 | for path in files: | 881 | for path in files: |
882 | if args.append: | 882 | if append: |
883 | if not destpath: | 883 | if not destpath: |
884 | raise Exception('destpath should be set here') | 884 | raise Exception('destpath should be set here') |
885 | path = os.path.join(destpath, os.path.basename(path)) | 885 | path = os.path.join(destpath, os.path.basename(path)) |
@@ -1055,7 +1055,7 @@ def _determine_files_dir(rd): | |||
1055 | return os.path.join(recipedir, rd.getVar('BPN', True)) | 1055 | return os.path.join(recipedir, rd.getVar('BPN', True)) |
1056 | 1056 | ||
1057 | 1057 | ||
1058 | def _update_recipe_srcrev(args, srctree, rd, config_data): | 1058 | def _update_recipe_srcrev(srctree, rd, appendlayerdir, wildcard_version, no_remove): |
1059 | """Implement the 'srcrev' mode of update-recipe""" | 1059 | """Implement the 'srcrev' mode of update-recipe""" |
1060 | import bb | 1060 | import bb |
1061 | import oe.recipeutils | 1061 | import oe.recipeutils |
@@ -1084,7 +1084,7 @@ def _update_recipe_srcrev(args, srctree, rd, config_data): | |||
1084 | try: | 1084 | try: |
1085 | local_files_dir = tempfile.mkdtemp(dir=tempdir) | 1085 | local_files_dir = tempfile.mkdtemp(dir=tempdir) |
1086 | upd_f, new_f, del_f = _export_local_files(srctree, rd, local_files_dir) | 1086 | upd_f, new_f, del_f = _export_local_files(srctree, rd, local_files_dir) |
1087 | if not args.no_remove: | 1087 | if not no_remove: |
1088 | # Find list of existing patches in recipe file | 1088 | # Find list of existing patches in recipe file |
1089 | patches_dir = tempfile.mkdtemp(dir=tempdir) | 1089 | patches_dir = tempfile.mkdtemp(dir=tempdir) |
1090 | old_srcrev = (rd.getVar('SRCREV', False) or '') | 1090 | old_srcrev = (rd.getVar('SRCREV', False) or '') |
@@ -1097,7 +1097,7 @@ def _update_recipe_srcrev(args, srctree, rd, config_data): | |||
1097 | removedentries = _remove_file_entries(srcuri, remove_files)[0] | 1097 | removedentries = _remove_file_entries(srcuri, remove_files)[0] |
1098 | update_srcuri = True | 1098 | update_srcuri = True |
1099 | 1099 | ||
1100 | if args.append: | 1100 | if appendlayerdir: |
1101 | files = dict((os.path.join(local_files_dir, key), val) for | 1101 | files = dict((os.path.join(local_files_dir, key), val) for |
1102 | key, val in list(upd_f.items()) + list(new_f.items())) | 1102 | key, val in list(upd_f.items()) + list(new_f.items())) |
1103 | removevalues = {} | 1103 | removevalues = {} |
@@ -1105,7 +1105,7 @@ def _update_recipe_srcrev(args, srctree, rd, config_data): | |||
1105 | removevalues = {'SRC_URI': removedentries} | 1105 | removevalues = {'SRC_URI': removedentries} |
1106 | patchfields['SRC_URI'] = '\\\n '.join(srcuri) | 1106 | patchfields['SRC_URI'] = '\\\n '.join(srcuri) |
1107 | _, destpath = oe.recipeutils.bbappend_recipe( | 1107 | _, destpath = oe.recipeutils.bbappend_recipe( |
1108 | rd, args.append, files, wildcardver=args.wildcard_version, | 1108 | rd, appendlayerdir, files, wildcardver=wildcard_version, |
1109 | extralines=patchfields, removevalues=removevalues) | 1109 | extralines=patchfields, removevalues=removevalues) |
1110 | else: | 1110 | else: |
1111 | files_dir = _determine_files_dir(rd) | 1111 | files_dir = _determine_files_dir(rd) |
@@ -1129,21 +1129,21 @@ def _update_recipe_srcrev(args, srctree, rd, config_data): | |||
1129 | 'point to a git repository where you have pushed your ' | 1129 | 'point to a git repository where you have pushed your ' |
1130 | 'changes') | 1130 | 'changes') |
1131 | 1131 | ||
1132 | _remove_source_files(args, remove_files, destpath) | 1132 | _remove_source_files(appendlayerdir, remove_files, destpath) |
1133 | return True | 1133 | return True |
1134 | 1134 | ||
1135 | def _update_recipe_patch(args, config, workspace, srctree, rd, config_data): | 1135 | def _update_recipe_patch(recipename, workspace, srctree, rd, appendlayerdir, wildcard_version, no_remove, initial_rev): |
1136 | """Implement the 'patch' mode of update-recipe""" | 1136 | """Implement the 'patch' mode of update-recipe""" |
1137 | import bb | 1137 | import bb |
1138 | import oe.recipeutils | 1138 | import oe.recipeutils |
1139 | 1139 | ||
1140 | recipefile = rd.getVar('FILE', True) | 1140 | recipefile = rd.getVar('FILE', True) |
1141 | append = workspace[args.recipename]['bbappend'] | 1141 | append = workspace[recipename]['bbappend'] |
1142 | if not os.path.exists(append): | 1142 | if not os.path.exists(append): |
1143 | raise DevtoolError('unable to find workspace bbappend for recipe %s' % | 1143 | raise DevtoolError('unable to find workspace bbappend for recipe %s' % |
1144 | args.recipename) | 1144 | recipename) |
1145 | 1145 | ||
1146 | initial_rev, update_rev, changed_revs = _get_patchset_revs(srctree, append, args.initial_rev) | 1146 | initial_rev, update_rev, changed_revs = _get_patchset_revs(srctree, append, initial_rev) |
1147 | if not initial_rev: | 1147 | if not initial_rev: |
1148 | raise DevtoolError('Unable to find initial revision - please specify ' | 1148 | raise DevtoolError('Unable to find initial revision - please specify ' |
1149 | 'it with --initial-rev') | 1149 | 'it with --initial-rev') |
@@ -1154,7 +1154,7 @@ def _update_recipe_patch(args, config, workspace, srctree, rd, config_data): | |||
1154 | upd_f, new_f, del_f = _export_local_files(srctree, rd, local_files_dir) | 1154 | upd_f, new_f, del_f = _export_local_files(srctree, rd, local_files_dir) |
1155 | 1155 | ||
1156 | remove_files = [] | 1156 | remove_files = [] |
1157 | if not args.no_remove: | 1157 | if not no_remove: |
1158 | # Get all patches from source tree and check if any should be removed | 1158 | # Get all patches from source tree and check if any should be removed |
1159 | all_patches_dir = tempfile.mkdtemp(dir=tempdir) | 1159 | all_patches_dir = tempfile.mkdtemp(dir=tempdir) |
1160 | upd_p, new_p, del_p = _export_patches(srctree, rd, initial_rev, | 1160 | upd_p, new_p, del_p = _export_patches(srctree, rd, initial_rev, |
@@ -1170,7 +1170,7 @@ def _update_recipe_patch(args, config, workspace, srctree, rd, config_data): | |||
1170 | updaterecipe = False | 1170 | updaterecipe = False |
1171 | destpath = None | 1171 | destpath = None |
1172 | srcuri = (rd.getVar('SRC_URI', False) or '').split() | 1172 | srcuri = (rd.getVar('SRC_URI', False) or '').split() |
1173 | if args.append: | 1173 | if appendlayerdir: |
1174 | files = dict((os.path.join(local_files_dir, key), val) for | 1174 | files = dict((os.path.join(local_files_dir, key), val) for |
1175 | key, val in list(upd_f.items()) + list(new_f.items())) | 1175 | key, val in list(upd_f.items()) + list(new_f.items())) |
1176 | files.update(dict((os.path.join(patches_dir, key), val) for | 1176 | files.update(dict((os.path.join(patches_dir, key), val) for |
@@ -1185,7 +1185,7 @@ def _update_recipe_patch(args, config, workspace, srctree, rd, config_data): | |||
1185 | item in remaining] | 1185 | item in remaining] |
1186 | removevalues = {'SRC_URI': removedentries + remaining} | 1186 | removevalues = {'SRC_URI': removedentries + remaining} |
1187 | _, destpath = oe.recipeutils.bbappend_recipe( | 1187 | _, destpath = oe.recipeutils.bbappend_recipe( |
1188 | rd, args.append, files, | 1188 | rd, appendlayerdir, files, |
1189 | removevalues=removevalues) | 1189 | removevalues=removevalues) |
1190 | else: | 1190 | else: |
1191 | logger.info('No patches or local source files needed updating') | 1191 | logger.info('No patches or local source files needed updating') |
@@ -1235,7 +1235,7 @@ def _update_recipe_patch(args, config, workspace, srctree, rd, config_data): | |||
1235 | finally: | 1235 | finally: |
1236 | shutil.rmtree(tempdir) | 1236 | shutil.rmtree(tempdir) |
1237 | 1237 | ||
1238 | _remove_source_files(args, remove_files, destpath) | 1238 | _remove_source_files(appendlayerdir, remove_files, destpath) |
1239 | return True | 1239 | return True |
1240 | 1240 | ||
1241 | def _guess_recipe_update_mode(srctree, rdata): | 1241 | def _guess_recipe_update_mode(srctree, rdata): |
@@ -1260,6 +1260,19 @@ def _guess_recipe_update_mode(srctree, rdata): | |||
1260 | 1260 | ||
1261 | return 'patch' | 1261 | return 'patch' |
1262 | 1262 | ||
1263 | def _update_recipe(recipename, workspace, rd, mode, appendlayerdir, wildcard_version, no_remove, initial_rev): | ||
1264 | srctree = workspace[recipename]['srctree'] | ||
1265 | if mode == 'auto': | ||
1266 | mode = _guess_recipe_update_mode(srctree, rd) | ||
1267 | |||
1268 | if mode == 'srcrev': | ||
1269 | updated = _update_recipe_srcrev(srctree, rd, appendlayerdir, wildcard_version, no_remove) | ||
1270 | elif mode == 'patch': | ||
1271 | updated = _update_recipe_patch(recipename, workspace, srctree, rd, appendlayerdir, wildcard_version, no_remove, initial_rev) | ||
1272 | else: | ||
1273 | raise DevtoolError('update_recipe: invalid mode %s' % mode) | ||
1274 | return updated | ||
1275 | |||
1263 | def update_recipe(args, config, basepath, workspace): | 1276 | def update_recipe(args, config, basepath, workspace): |
1264 | """Entry point for the devtool 'update-recipe' subcommand""" | 1277 | """Entry point for the devtool 'update-recipe' subcommand""" |
1265 | check_workspace_recipe(workspace, args.recipename) | 1278 | check_workspace_recipe(workspace, args.recipename) |
@@ -1278,18 +1291,7 @@ def update_recipe(args, config, basepath, workspace): | |||
1278 | if not rd: | 1291 | if not rd: |
1279 | return 1 | 1292 | return 1 |
1280 | 1293 | ||
1281 | srctree = workspace[args.recipename]['srctree'] | 1294 | updated = _update_recipe(args.recipename, workspace, rd, args.mode, args.append, args.wildcard_version, args.no_remove, args.initial_rev) |
1282 | if args.mode == 'auto': | ||
1283 | mode = _guess_recipe_update_mode(srctree, rd) | ||
1284 | else: | ||
1285 | mode = args.mode | ||
1286 | |||
1287 | if mode == 'srcrev': | ||
1288 | updated = _update_recipe_srcrev(args, srctree, rd, tinfoil.config_data) | ||
1289 | elif mode == 'patch': | ||
1290 | updated = _update_recipe_patch(args, config, workspace, srctree, rd, tinfoil.config_data) | ||
1291 | else: | ||
1292 | raise DevtoolError('update_recipe: invalid mode %s' % mode) | ||
1293 | 1295 | ||
1294 | if updated: | 1296 | if updated: |
1295 | rf = rd.getVar('FILE', True) | 1297 | rf = rd.getVar('FILE', True) |