mirror of
https://git.yoctoproject.org/poky
synced 2026-06-02 01:19:52 +00:00
devtool: add support for git submodules
Adding the support of submodules required a lot of changes on the
internal data structures:
* initial_rev/startcommit used as a starting point for looking at new
/ updated commits was replaced by a dictionary where the keys are the
submodule name ("." for main repo) and the values are the
initial_rev/startcommit
* the extractPatches function now extracts patch for the main repo and
for all submodules and stores them in a hierarchical way describing the
submodule path
* store initial_rev/commit also for all submodules inside the recipe
bbappend file
* _export_patches now returns dictionaries that contains the 'patchdir'
parameter (if any). This parameter is used to add the correct
'patchdir=' parameter on the recipe
Also, recipe can extract a secondary git tree inside the workdir.
By default, at the end of the do_patch function, there is a hook in
devtool that commits everything that was modified to have a clean
repository. It uses the command: "git add .; git commit ..."
The issue here is that, it adds the secondary git tree as a submodule
but in a wrong way. Doing "git add <git dir>" declares a submodule but do
not adds a url associated to it, and all following "git submodule foreach"
commands will fail.
So detect that a git tree was extracted inside S and correctly add it
using "git submodule add <url> <path>", so that it will be considered as a
regular git submodule
(From OE-Core rev: 900129cbdf25297a42ab5dbd02d1adbea405c935)
Signed-off-by: Julien Stephan <jstephan@baylibre.com>
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
This commit is contained in:
committed by
Richard Purdie
parent
17427db136
commit
89f1662484
+32
-30
@@ -461,41 +461,43 @@ class GitApplyTree(PatchTree):
|
||||
return (tmpfile, cmd)
|
||||
|
||||
@staticmethod
|
||||
def extractPatches(tree, startcommit, outdir, paths=None):
|
||||
def extractPatches(tree, startcommits, outdir, paths=None):
|
||||
import tempfile
|
||||
import shutil
|
||||
tempdir = tempfile.mkdtemp(prefix='oepatch')
|
||||
try:
|
||||
shellcmd = ["git", "format-patch", "--no-signature", "--no-numbered", startcommit, "-o", tempdir]
|
||||
if paths:
|
||||
shellcmd.append('--')
|
||||
shellcmd.extend(paths)
|
||||
out = runcmd(["sh", "-c", " ".join(shellcmd)], tree)
|
||||
if out:
|
||||
for srcfile in out.split():
|
||||
for encoding in ['utf-8', 'latin-1']:
|
||||
patchlines = []
|
||||
outfile = None
|
||||
try:
|
||||
with open(srcfile, 'r', encoding=encoding) as f:
|
||||
for line in f:
|
||||
if line.startswith(GitApplyTree.patch_line_prefix):
|
||||
outfile = line.split()[-1].strip()
|
||||
continue
|
||||
if line.startswith(GitApplyTree.ignore_commit_prefix):
|
||||
continue
|
||||
patchlines.append(line)
|
||||
except UnicodeDecodeError:
|
||||
continue
|
||||
break
|
||||
else:
|
||||
raise PatchError('Unable to find a character encoding to decode %s' % srcfile)
|
||||
for name, rev in startcommits.items():
|
||||
shellcmd = ["git", "format-patch", "--no-signature", "--no-numbered", rev, "-o", tempdir]
|
||||
if paths:
|
||||
shellcmd.append('--')
|
||||
shellcmd.extend(paths)
|
||||
out = runcmd(["sh", "-c", " ".join(shellcmd)], os.path.join(tree, name))
|
||||
if out:
|
||||
for srcfile in out.split():
|
||||
for encoding in ['utf-8', 'latin-1']:
|
||||
patchlines = []
|
||||
outfile = None
|
||||
try:
|
||||
with open(srcfile, 'r', encoding=encoding) as f:
|
||||
for line in f:
|
||||
if line.startswith(GitApplyTree.patch_line_prefix):
|
||||
outfile = line.split()[-1].strip()
|
||||
continue
|
||||
if line.startswith(GitApplyTree.ignore_commit_prefix):
|
||||
continue
|
||||
patchlines.append(line)
|
||||
except UnicodeDecodeError:
|
||||
continue
|
||||
break
|
||||
else:
|
||||
raise PatchError('Unable to find a character encoding to decode %s' % srcfile)
|
||||
|
||||
if not outfile:
|
||||
outfile = os.path.basename(srcfile)
|
||||
with open(os.path.join(outdir, outfile), 'w') as of:
|
||||
for line in patchlines:
|
||||
of.write(line)
|
||||
if not outfile:
|
||||
outfile = os.path.basename(srcfile)
|
||||
bb.utils.mkdirhier(os.path.join(outdir, name))
|
||||
with open(os.path.join(outdir, name, outfile), 'w') as of:
|
||||
for line in patchlines:
|
||||
of.write(line)
|
||||
finally:
|
||||
shutil.rmtree(tempdir)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user