diff options
author | Roland Hieber <rhi@pengutronix.de> | 2020-10-12 19:40:38 +0200 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2020-10-17 12:34:29 +0100 |
commit | a6c9ee99b3de4c5c6e9cc42220a27223d3f73fd7 (patch) | |
tree | a562e398ca4342434f2f936e6ae273ee28feb0d4 /scripts/lib | |
parent | 7e38f67127937c98e9001646f8b19881e1026341 (diff) | |
download | poky-a6c9ee99b3de4c5c6e9cc42220a27223d3f73fd7.tar.gz |
devtool: make sure .git/info exists before writing to .git/info/excludes
If nothing else is specified, 'git init' uses its default repository
template from the install location (e.g. /usr/share/git-core/templates),
which already includes an info/ subdirectory. However, when setting
init.templateDir to a different template path in ~/.gitconfig, this
isn't necessarily the case, and it can lead to setup_git_repo() failing
with stack traces like:
File: '.../scripts/lib/devtool/__init__.py', lineno: 234, function: setup_git_repo
0230: pass
0231: if 'singletask.lock\n' not in excludes:
0232: excludes.append('singletask.lock\n')
0233: bb.warn("try writing excludefile")
*** 0234: with open(excludefile, 'w') as f:
0235: for line in excludes:
0236: f.write(line)
0237:
0238: bb.process.run('git checkout -b %s' % devbranch, cwd=repodir)
Exception: FileNotFoundError: [Errno 2] No such file or directory: '.../devtooltmp-6m36b181/workdir/foobar-1.0.1/.git/info/exclude'
Fix this edge case by creating the .git/info/ directory first.
Fixes: 334ba846c795fc0d8c73 (2018-02-01, "devtool: set up git repos so that singletask.lock is ignored")
(From OE-Core rev: 148a23e4d5ceaf655ccacb52deca4ba501f12975)
Signed-off-by: Roland Hieber <rhi@pengutronix.de>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'scripts/lib')
-rw-r--r-- | scripts/lib/devtool/__init__.py | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/scripts/lib/devtool/__init__.py b/scripts/lib/devtool/__init__.py index 6ebe368a9e..702db669de 100644 --- a/scripts/lib/devtool/__init__.py +++ b/scripts/lib/devtool/__init__.py | |||
@@ -212,8 +212,13 @@ def setup_git_repo(repodir, version, devbranch, basetag='devtool-base', d=None): | |||
212 | bb.process.run(commit_cmd, cwd=repodir) | 212 | bb.process.run(commit_cmd, cwd=repodir) |
213 | 213 | ||
214 | # Ensure singletask.lock (as used by externalsrc.bbclass) is ignored by git | 214 | # Ensure singletask.lock (as used by externalsrc.bbclass) is ignored by git |
215 | gitinfodir = os.path.join(repodir, '.git', 'info') | ||
216 | try: | ||
217 | os.mkdir(gitinfodir) | ||
218 | except FileExistsError: | ||
219 | pass | ||
215 | excludes = [] | 220 | excludes = [] |
216 | excludefile = os.path.join(repodir, '.git', 'info', 'exclude') | 221 | excludefile = os.path.join(gitinfodir, 'exclude') |
217 | try: | 222 | try: |
218 | with open(excludefile, 'r') as f: | 223 | with open(excludefile, 'r') as f: |
219 | excludes = f.readlines() | 224 | excludes = f.readlines() |