diff options
author | Paul Eggleton <paul.eggleton@linux.intel.com> | 2016-09-01 11:38:46 +1200 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2016-09-08 00:36:48 +0100 |
commit | 39d3aa28283d763bbc4aadcbb040f038a506a6df (patch) | |
tree | 2592b3286248025984b9134ea5c2111ab14048f2 | |
parent | 94aefd9a39c688f34cfb0c9ef003de74d754f0e4 (diff) | |
download | poky-39d3aa28283d763bbc4aadcbb040f038a506a6df.tar.gz |
devtool: update-recipe: support files with subdir=
It's rare but there are recipes that have individual files (as opposed
to archives) in SRC_URI using subdir= to put them under the source tree,
the examples in OE-Core being bzip2 and openssl. This broke devtool
update-recipe (and devtool finish) because the file wasn't unpacked into
the oe-local-files directory and thus when it came time to update the
recipe, the file was assumed to have been deleted by the user and thus
the file was erroneously removed. Add logic to handle these properly so
that this doesn't happen.
(We still have another potential problem in that these files become part
of the initial commit from upstream, which could be confusing because
they didn't come from there - but that's a separate issue and not one
that is trivially solved.)
(From OE-Core rev: 9069fef5dad5a873c8a8f720f7bcbc7625556309)
Signed-off-by: Paul Eggleton <paul.eggleton@linux.intel.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
-rw-r--r-- | meta/lib/oe/recipeutils.py | 12 | ||||
-rw-r--r-- | scripts/lib/devtool/standard.py | 38 |
2 files changed, 46 insertions, 4 deletions
diff --git a/meta/lib/oe/recipeutils.py b/meta/lib/oe/recipeutils.py index e7dd8afb08..a0d78dde46 100644 --- a/meta/lib/oe/recipeutils.py +++ b/meta/lib/oe/recipeutils.py | |||
@@ -400,8 +400,16 @@ def get_recipe_local_files(d, patches=False): | |||
400 | bb.utils.exec_flat_python_func('patch_path', uri, fetch, '')): | 400 | bb.utils.exec_flat_python_func('patch_path', uri, fetch, '')): |
401 | continue | 401 | continue |
402 | # Skip files that are referenced by absolute path | 402 | # Skip files that are referenced by absolute path |
403 | if not os.path.isabs(fetch.ud[uri].basepath): | 403 | fname = fetch.ud[uri].basepath |
404 | ret[fetch.ud[uri].basepath] = fetch.localpath(uri) | 404 | if os.path.isabs(fname): |
405 | continue | ||
406 | # Handle subdir= | ||
407 | subdir = fetch.ud[uri].parm.get('subdir', '') | ||
408 | if subdir: | ||
409 | if os.path.isabs(subdir): | ||
410 | continue | ||
411 | fname = os.path.join(subdir, fname) | ||
412 | ret[fname] = fetch.localpath(uri) | ||
405 | return ret | 413 | return ret |
406 | 414 | ||
407 | 415 | ||
diff --git a/scripts/lib/devtool/standard.py b/scripts/lib/devtool/standard.py index 98451da441..baef23e467 100644 --- a/scripts/lib/devtool/standard.py +++ b/scripts/lib/devtool/standard.py | |||
@@ -307,6 +307,13 @@ def _move_file(src, dst): | |||
307 | bb.utils.mkdirhier(dst_d) | 307 | bb.utils.mkdirhier(dst_d) |
308 | shutil.move(src, dst) | 308 | shutil.move(src, dst) |
309 | 309 | ||
310 | def _copy_file(src, dst): | ||
311 | """Copy a file. Creates all the directory components of destination path.""" | ||
312 | dst_d = os.path.dirname(dst) | ||
313 | if dst_d: | ||
314 | bb.utils.mkdirhier(dst_d) | ||
315 | shutil.copy(src, dst) | ||
316 | |||
310 | def _git_ls_tree(repodir, treeish='HEAD', recursive=False): | 317 | def _git_ls_tree(repodir, treeish='HEAD', recursive=False): |
311 | """List contents of a git treeish""" | 318 | """List contents of a git treeish""" |
312 | import bb | 319 | import bb |
@@ -1050,6 +1057,23 @@ def _export_local_files(srctree, rd, destdir): | |||
1050 | elif fname != '.gitignore': | 1057 | elif fname != '.gitignore': |
1051 | added[fname] = None | 1058 | added[fname] = None |
1052 | 1059 | ||
1060 | workdir = rd.getVar('WORKDIR', True) | ||
1061 | s = rd.getVar('S', True) | ||
1062 | if not s.endswith(os.sep): | ||
1063 | s += os.sep | ||
1064 | |||
1065 | if workdir != s: | ||
1066 | # Handle files where subdir= was specified | ||
1067 | for fname in list(existing_files.keys()): | ||
1068 | # FIXME handle both subdir starting with BP and not? | ||
1069 | fworkpath = os.path.join(workdir, fname) | ||
1070 | if fworkpath.startswith(s): | ||
1071 | fpath = os.path.join(srctree, os.path.relpath(fworkpath, s)) | ||
1072 | if os.path.exists(fpath): | ||
1073 | origpath = existing_files.pop(fname) | ||
1074 | if not filecmp.cmp(origpath, fpath): | ||
1075 | updated[fpath] = origpath | ||
1076 | |||
1053 | removed = existing_files | 1077 | removed = existing_files |
1054 | return (updated, added, removed) | 1078 | return (updated, added, removed) |
1055 | 1079 | ||
@@ -1122,7 +1146,12 @@ def _update_recipe_srcrev(srctree, rd, appendlayerdir, wildcard_version, no_remo | |||
1122 | files_dir = _determine_files_dir(rd) | 1146 | files_dir = _determine_files_dir(rd) |
1123 | for basepath, path in upd_f.items(): | 1147 | for basepath, path in upd_f.items(): |
1124 | logger.info('Updating file %s' % basepath) | 1148 | logger.info('Updating file %s' % basepath) |
1125 | _move_file(os.path.join(local_files_dir, basepath), path) | 1149 | if os.path.isabs(basepath): |
1150 | # Original file (probably with subdir pointing inside source tree) | ||
1151 | # so we do not want to move it, just copy | ||
1152 | _copy_file(basepath, path) | ||
1153 | else: | ||
1154 | _move_file(os.path.join(local_files_dir, basepath), path) | ||
1126 | update_srcuri= True | 1155 | update_srcuri= True |
1127 | for basepath, path in new_f.items(): | 1156 | for basepath, path in new_f.items(): |
1128 | logger.info('Adding new file %s' % basepath) | 1157 | logger.info('Adding new file %s' % basepath) |
@@ -1205,7 +1234,12 @@ def _update_recipe_patch(recipename, workspace, srctree, rd, appendlayerdir, wil | |||
1205 | # Update existing files | 1234 | # Update existing files |
1206 | for basepath, path in upd_f.items(): | 1235 | for basepath, path in upd_f.items(): |
1207 | logger.info('Updating file %s' % basepath) | 1236 | logger.info('Updating file %s' % basepath) |
1208 | _move_file(os.path.join(local_files_dir, basepath), path) | 1237 | if os.path.isabs(basepath): |
1238 | # Original file (probably with subdir pointing inside source tree) | ||
1239 | # so we do not want to move it, just copy | ||
1240 | _copy_file(basepath, path) | ||
1241 | else: | ||
1242 | _move_file(os.path.join(local_files_dir, basepath), path) | ||
1209 | updatefiles = True | 1243 | updatefiles = True |
1210 | for basepath, path in upd_p.items(): | 1244 | for basepath, path in upd_p.items(): |
1211 | patchfn = os.path.join(patches_dir, basepath) | 1245 | patchfn = os.path.join(patches_dir, basepath) |