summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--meta/classes/patch.bbclass18
-rw-r--r--meta/lib/oe/patch.py43
2 files changed, 42 insertions, 19 deletions
diff --git a/meta/classes/patch.bbclass b/meta/classes/patch.bbclass
index 25ec089ae12..d4588d75e1b 100644
--- a/meta/classes/patch.bbclass
+++ b/meta/classes/patch.bbclass
@@ -61,10 +61,14 @@ python patch_task_patch_prefunc() {
python patch_task_postfunc() {
# Prefunc for task functions between do_unpack and do_patch
import oe.patch
+ import oe.gitutils
import shutil
func = d.getVar('BB_RUNTASK')
srcsubdir = d.getVar('S')
-
+
+ repos = oe.gitutils.find_git_repos(srcsubdir, toplevel=False)
+ repos.insert(0, srcsubdir) # may actually not be a repo, but somewhere above there must be one
+
if os.path.exists(srcsubdir):
if func == 'do_patch':
haspatches = (d.getVar('PATCH_HAS_PATCHES_DIR') == '1')
@@ -75,11 +79,13 @@ python patch_task_postfunc() {
stdout, _ = bb.process.run('git status --porcelain patches', cwd=srcsubdir)
if stdout:
bb.process.run('git checkout patches', cwd=srcsubdir)
- stdout, _ = bb.process.run('git status --porcelain .', cwd=srcsubdir)
- if stdout:
- useroptions = []
- oe.patch.GitApplyTree.gitCommandUserOptions(useroptions, d=d)
- bb.process.run('git add .; git %s commit -a -m "Committing changes from %s\n\n%s"' % (' '.join(useroptions), func, oe.patch.GitApplyTree.ignore_commit_prefix + ' - from %s' % func), cwd=srcsubdir)
+ for repopath in repos:
+ status = oe.gitutils.get_repo_status(repopath)
+ bb.warn('%s status:\n%s' % (repopath, status))
+ if status:
+ useroptions = []
+ oe.patch.GitApplyTree.gitCommandUserOptions(useroptions, d=d)
+ bb.process.run('git add .; git %s commit -a -m "Committing changes from %s\n\n%s"' % (' '.join(useroptions), func, oe.patch.GitApplyTree.ignore_commit_prefix + ' - from %s' % func), cwd=repopath)
}
def src_patches(d, all=False, expand=True):
diff --git a/meta/lib/oe/patch.py b/meta/lib/oe/patch.py
index 40755fbb033..e9db175b8de 100644
--- a/meta/lib/oe/patch.py
+++ b/meta/lib/oe/patch.py
@@ -476,8 +476,12 @@ class GitApplyTree(PatchTree):
def _applypatch(self, patch, force = False, reverse = False, run = True):
import shutil
+ import oe.utils
+ import oe.gitutils
def _applypatchhelper(shellcmd, patch, force = False, reverse = False, run = True):
+ #bb.warn('_applypatchhelper "%s" %s' % (shellcmd, patch))
+ #bb.warn('repo status:\n%s' % (runcmd(['git', 'status', '--porcelain'], self.dir), ))
if reverse:
shellcmd.append('-R')
@@ -535,19 +539,32 @@ class GitApplyTree(PatchTree):
except CmdError:
# Fall back to patch
output = PatchTree._applypatch(self, patch, force, reverse, run)
- # Add all files
- shellcmd = ["git", "add", "-f", "-A", "."]
- output += runcmd(["sh", "-c", " ".join(shellcmd)], self.dir)
- # Exclude the patches directory
- shellcmd = ["git", "reset", "HEAD", self.patchdir]
- output += runcmd(["sh", "-c", " ".join(shellcmd)], self.dir)
- # Commit the result
- (tmpfile, shellcmd) = self.prepareCommit(patch['file'], self.commituser, self.commitemail)
- try:
- shellcmd.insert(0, patchfilevar)
- output += runcmd(["sh", "-c", " ".join(shellcmd)], self.dir)
- finally:
- os.remove(tmpfile)
+ bb.warn('repo status post-apply:\n%s' % (runcmd(['git', 'status', '--porcelain'], self.dir), ))
+ repos = [self.dir] + oe.gitutils.find_git_repos(self.dir)
+ for repodir in sorted(repos, key=len, reverse=True):
+ # Add all files
+ shellcmd = ["git", "add", "-f", "-A", "."]
+ output += runcmd(["sh", "-c", " ".join(shellcmd)], repodir)
+ excludepaths = [r for r in repos if r != repodir and oe.utils.is_path_under(r, repodir)]
+ if oe.utils.is_path_under(self.patchdir, repodir):
+ # Exclude the patches directory
+ excludepaths += [self.patchdir]
+ if excludepaths:
+ shellcmd = ["git", "reset", "HEAD"] + excludepaths
+ output += runcmd(["sh", "-c", " ".join(shellcmd)], repodir)
+ # Check if anything to commit
+ shellcmd = ["git", "diff", "--cached", "--name-only"]
+ changes = runcmd(["sh", "-c", " ".join(shellcmd)], repodir)
+ if changes:
+ # Commit the result
+ (tmpfile, shellcmd) = self.prepareCommit(patch['file'], self.commituser, self.commitemail)
+ try:
+ shellcmd.insert(0, patchfilevar)
+ bb.warn('Committing in %s: %s' % (repodir, shellcmd))
+ output += runcmd(["sh", "-c", " ".join(shellcmd)], repodir)
+ finally:
+ os.remove(tmpfile)
+ bb.warn('repo status at end:\n%s' % (runcmd(['git', 'status', '--porcelain'], self.dir), ))
return output
finally:
shutil.rmtree(hooks_dir)