summaryrefslogtreecommitdiffstats
path: root/scripts/lib/devtool/__init__.py
diff options
context:
space:
mode:
authorJulien Stephan <jstephan@baylibre.com>2023-11-22 12:08:16 +0100
committerRichard Purdie <richard.purdie@linuxfoundation.org>2023-12-01 11:48:25 +0000
commit89f16624842a91e063dc9e6b98787d44c55e4900 (patch)
treec22ebb7b7f5ff89d3ed8431e8dcace59678b9ed3 /scripts/lib/devtool/__init__.py
parent17427db136491f13b0c9f187906ce9e3f6c85b29 (diff)
downloadpoky-89f16624842a91e063dc9e6b98787d44c55e4900.tar.gz
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>
Diffstat (limited to 'scripts/lib/devtool/__init__.py')
-rw-r--r--scripts/lib/devtool/__init__.py21
1 files changed, 21 insertions, 0 deletions
diff --git a/scripts/lib/devtool/__init__.py b/scripts/lib/devtool/__init__.py
index e9e88a5533..b4f998a5bc 100644
--- a/scripts/lib/devtool/__init__.py
+++ b/scripts/lib/devtool/__init__.py
@@ -233,6 +233,27 @@ def setup_git_repo(repodir, version, devbranch, basetag='devtool-base', d=None):
233 bb.process.run('git checkout -b %s' % devbranch, cwd=repodir) 233 bb.process.run('git checkout -b %s' % devbranch, cwd=repodir)
234 bb.process.run('git tag -f %s' % basetag, cwd=repodir) 234 bb.process.run('git tag -f %s' % basetag, cwd=repodir)
235 235
236 # if recipe unpacks another git repo inside S, we need to declare it as a regular git submodule now,
237 # so we will be able to tag branches on it and extract patches when doing finish/update on the recipe
238 stdout, _ = bb.process.run("git status --porcelain", cwd=repodir)
239 found = False
240 for line in stdout.splitlines():
241 if line.endswith("/"):
242 new_dir = line.split()[1]
243 for root, dirs, files in os.walk(os.path.join(repodir, new_dir)):
244 if ".git" in dirs + files:
245 (stdout, _) = bb.process.run('git remote', cwd=root)
246 remote = stdout.splitlines()[0]
247 (stdout, _) = bb.process.run('git remote get-url %s' % remote, cwd=root)
248 remote_url = stdout.splitlines()[0]
249 logger.error(os.path.relpath(os.path.join(root, ".."), root))
250 bb.process.run('git submodule add %s %s' % (remote_url, os.path.relpath(root, os.path.join(root, ".."))), cwd=os.path.join(root, ".."))
251 found = True
252 if found:
253 useroptions = []
254 oe.patch.GitApplyTree.gitCommandUserOptions(useroptions, d=d)
255 bb.process.run('git %s commit -m "Adding additionnal submodule from SRC_URI\n\n%s"' % (' '.join(useroptions), oe.patch.GitApplyTree.ignore_commit_prefix), cwd=os.path.join(root, ".."))
256 found = False
236 if os.path.exists(os.path.join(repodir, '.gitmodules')): 257 if os.path.exists(os.path.join(repodir, '.gitmodules')):
237 bb.process.run('git submodule foreach --recursive "git tag -f %s"' % basetag, cwd=repodir) 258 bb.process.run('git submodule foreach --recursive "git tag -f %s"' % basetag, cwd=repodir)
238 259