1
0
mirror of https://git.yoctoproject.org/poky synced 2026-06-01 00:59:48 +00:00

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>
This commit is contained in:
Paul Eggleton
2016-09-01 11:38:46 +12:00
committed by Richard Purdie
parent 94aefd9a39
commit 39d3aa2828
2 changed files with 46 additions and 4 deletions
+10 -2
View File
@@ -400,8 +400,16 @@ def get_recipe_local_files(d, patches=False):
bb.utils.exec_flat_python_func('patch_path', uri, fetch, '')): bb.utils.exec_flat_python_func('patch_path', uri, fetch, '')):
continue continue
# Skip files that are referenced by absolute path # Skip files that are referenced by absolute path
if not os.path.isabs(fetch.ud[uri].basepath): fname = fetch.ud[uri].basepath
ret[fetch.ud[uri].basepath] = fetch.localpath(uri) if os.path.isabs(fname):
continue
# Handle subdir=
subdir = fetch.ud[uri].parm.get('subdir', '')
if subdir:
if os.path.isabs(subdir):
continue
fname = os.path.join(subdir, fname)
ret[fname] = fetch.localpath(uri)
return ret return ret
+36 -2
View File
@@ -307,6 +307,13 @@ def _move_file(src, dst):
bb.utils.mkdirhier(dst_d) bb.utils.mkdirhier(dst_d)
shutil.move(src, dst) shutil.move(src, dst)
def _copy_file(src, dst):
"""Copy a file. Creates all the directory components of destination path."""
dst_d = os.path.dirname(dst)
if dst_d:
bb.utils.mkdirhier(dst_d)
shutil.copy(src, dst)
def _git_ls_tree(repodir, treeish='HEAD', recursive=False): def _git_ls_tree(repodir, treeish='HEAD', recursive=False):
"""List contents of a git treeish""" """List contents of a git treeish"""
import bb import bb
@@ -1050,6 +1057,23 @@ def _export_local_files(srctree, rd, destdir):
elif fname != '.gitignore': elif fname != '.gitignore':
added[fname] = None added[fname] = None
workdir = rd.getVar('WORKDIR', True)
s = rd.getVar('S', True)
if not s.endswith(os.sep):
s += os.sep
if workdir != s:
# Handle files where subdir= was specified
for fname in list(existing_files.keys()):
# FIXME handle both subdir starting with BP and not?
fworkpath = os.path.join(workdir, fname)
if fworkpath.startswith(s):
fpath = os.path.join(srctree, os.path.relpath(fworkpath, s))
if os.path.exists(fpath):
origpath = existing_files.pop(fname)
if not filecmp.cmp(origpath, fpath):
updated[fpath] = origpath
removed = existing_files removed = existing_files
return (updated, added, removed) return (updated, added, removed)
@@ -1122,7 +1146,12 @@ def _update_recipe_srcrev(srctree, rd, appendlayerdir, wildcard_version, no_remo
files_dir = _determine_files_dir(rd) files_dir = _determine_files_dir(rd)
for basepath, path in upd_f.items(): for basepath, path in upd_f.items():
logger.info('Updating file %s' % basepath) logger.info('Updating file %s' % basepath)
_move_file(os.path.join(local_files_dir, basepath), path) if os.path.isabs(basepath):
# Original file (probably with subdir pointing inside source tree)
# so we do not want to move it, just copy
_copy_file(basepath, path)
else:
_move_file(os.path.join(local_files_dir, basepath), path)
update_srcuri= True update_srcuri= True
for basepath, path in new_f.items(): for basepath, path in new_f.items():
logger.info('Adding new file %s' % basepath) logger.info('Adding new file %s' % basepath)
@@ -1205,7 +1234,12 @@ def _update_recipe_patch(recipename, workspace, srctree, rd, appendlayerdir, wil
# Update existing files # Update existing files
for basepath, path in upd_f.items(): for basepath, path in upd_f.items():
logger.info('Updating file %s' % basepath) logger.info('Updating file %s' % basepath)
_move_file(os.path.join(local_files_dir, basepath), path) if os.path.isabs(basepath):
# Original file (probably with subdir pointing inside source tree)
# so we do not want to move it, just copy
_copy_file(basepath, path)
else:
_move_file(os.path.join(local_files_dir, basepath), path)
updatefiles = True updatefiles = True
for basepath, path in upd_p.items(): for basepath, path in upd_p.items():
patchfn = os.path.join(patches_dir, basepath) patchfn = os.path.join(patches_dir, basepath)