From: Markus Lehtonen <markus.lehtonen@linux.intel.com>
To: openembedded-core@lists.openembedded.org
Cc: Paul Eggleton <paul.eggleton@linux.intel.com>
Subject: [PATCH 4/6] devtool: update-recipe: update local files directly
Date: Thu, 30 Apr 2015 12:16:10 +0300 [thread overview]
Message-ID: <1430385372-6975-5-git-send-email-markus.lehtonen@linux.intel.com> (raw)
In-Reply-To: <1430385372-6975-1-git-send-email-markus.lehtonen@linux.intel.com>
Source files that are directly referenced in the SRC_URI are imported
into srctree (with devtool extract) in the case S=WORKDIR. If these
files are local (i.e. they reside in the "recipe space" and not behind a
remote URL) we don't want create a patch against them, but, rather copy
our modified version over the original source.
NOTE: if new files are created, they are represented as patches, rather
than copied over the orignal source.
[YOCTO #7602]
Signed-off-by: Markus Lehtonen <markus.lehtonen@linux.intel.com>
---
scripts/lib/devtool/standard.py | 48 ++++++++++++++++++++++++++++++++++++++---
1 file changed, 45 insertions(+), 3 deletions(-)
diff --git a/scripts/lib/devtool/standard.py b/scripts/lib/devtool/standard.py
index 4b4a0a0..8a2783b 100644
--- a/scripts/lib/devtool/standard.py
+++ b/scripts/lib/devtool/standard.py
@@ -146,6 +146,16 @@ def _parse_recipe(config, tinfoil, pn, appends):
tinfoil.config_data)
+def _git_ls_tree(repodir, treeish='HEAD', recursive=False):
+ """List contents of a git treeish"""
+ import bb
+ cmd = ['git', 'ls-tree', '-z', 'HEAD']
+ if recursive:
+ cmd.append('-r')
+ out, _ = bb.process.run(cmd, cwd=repodir)
+ return [line.split(None, 4)[3] for line in out.split('\0') if line]
+
+
def _ls_tree(directory):
"""Recursive listing of files in a directory"""
ret = []
@@ -514,6 +524,35 @@ def update_recipe(args, config, basepath, workspace):
logger.error('Invalid hash returned by git: %s' % stdout)
return 1
+ # Find out local files (SRC_URI files that exist in the "recipe space").
+ # Local files that reside in srctree are not included in patch generation.
+ # Instead they are directly copied over the original source files (in
+ # recipe space).
+ #
+ # NOTE: "Filtering out" of local files in this way is not entirely reliable
+ # - we don't catch files that are deleted, for example. A more reliable way
+ # to implement this would be to use "negative pathspecs" which were
+ # introduced in Git v1.9.0. Revisit this when/if the required Git version
+ # becomes greater than that.
+ local_files = oe.recipeutils.get_recipe_local_files(rd)
+ tempdir = tempfile.mkdtemp(prefix='devtool')
+ try:
+ # Copy local files from srctree HEAD to "recipe space"
+ # Local files might be "all over the place", need recursive ls-tree
+ git_files = set(_git_ls_tree(srctree, recursive=True))
+ copy_files = git_files.intersection(set(local_files.keys()))
+ patch_include_paths = git_files.difference(set(local_files.keys()))
+ bb.process.run(['git', 'checkout', 'HEAD', '--'] + list(copy_files),
+ cwd=srctree,
+ env=dict(os.environ, GIT_WORK_TREE=tempdir))
+ for fname in _ls_tree(local_src_dir):
+ logger.info('Updating file %s' % fname)
+ shutil.copy2(os.path.join(local_src_dir, fname),
+ local_files[fname])
+ finally:
+ shutil.rmtree(tempdir)
+
+ # Update recipe and patches
if mode == 'srcrev':
logger.info('Updating SRCREV in recipe %s' % os.path.basename(recipefile))
patchfields = {}
@@ -526,7 +565,8 @@ def update_recipe(args, config, basepath, workspace):
tempdir = tempfile.mkdtemp(prefix='devtool')
removepatches = []
try:
- GitApplyTree.extractPatches(srctree, old_srcrev, tempdir)
+ GitApplyTree.extractPatches(srctree, old_srcrev, tempdir,
+ patch_include_paths)
newpatches = os.listdir(tempdir)
for patch in existing_patches:
patchfile = os.path.basename(patch)
@@ -581,7 +621,8 @@ def update_recipe(args, config, basepath, workspace):
# Get all patches from source tree and check if any should be removed
tempdir = tempfile.mkdtemp(prefix='devtool')
try:
- GitApplyTree.extractPatches(srctree, initial_rev, tempdir)
+ GitApplyTree.extractPatches(srctree, initial_rev, tempdir,
+ patch_include_paths)
newpatches = os.listdir(tempdir)
for patch in existing_patches:
patchfile = os.path.basename(patch)
@@ -593,7 +634,8 @@ def update_recipe(args, config, basepath, workspace):
# Get updated patches from source tree
tempdir = tempfile.mkdtemp(prefix='devtool')
try:
- GitApplyTree.extractPatches(srctree, update_rev, tempdir)
+ GitApplyTree.extractPatches(srctree, update_rev, tempdir,
+ patch_include_paths)
# Match up and replace existing patches with corresponding new patches
updatepatches = False
--
2.1.4
next prev parent reply other threads:[~2015-04-30 9:16 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-04-30 9:16 [PATCH 0/6] devtool: improve handling of local source files Markus Lehtonen
2015-04-30 9:16 ` [PATCH 1/6] devtool: extract: remove patches when S=WORKDIR Markus Lehtonen
2015-04-30 9:16 ` [PATCH 2/6] recipeutils: implement get_recipe_local_files() Markus Lehtonen
2015-04-30 9:16 ` [PATCH 3/6] oe.patch.GitApplyTree: add paths argument to extractPatches Markus Lehtonen
2015-04-30 9:16 ` Markus Lehtonen [this message]
2015-04-30 9:16 ` [PATCH 5/6] devtool: extract: always import local files to srctree Markus Lehtonen
2015-04-30 9:16 ` [PATCH 6/6] devtool: modify: make bitbake use local files from srctree Markus Lehtonen
2015-05-12 18:01 ` [PATCH 0/6] devtool: improve handling of local source files Paul Eggleton
2015-06-04 13:12 ` Markus Lehtonen
2015-06-04 13:49 ` Paul Eggleton
2015-06-11 12:53 ` Markus Lehtonen
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1430385372-6975-5-git-send-email-markus.lehtonen@linux.intel.com \
--to=markus.lehtonen@linux.intel.com \
--cc=openembedded-core@lists.openembedded.org \
--cc=paul.eggleton@linux.intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox