diff options
| author | Richard Purdie <richard.purdie@linuxfoundation.org> | 2021-10-22 03:59:15 -1000 |
|---|---|---|
| committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2021-10-23 17:47:38 +0100 |
| commit | 9c007cb1e35f4744682f9f00fe15ceb18fbf7ffc (patch) | |
| tree | cb39d84c32a974b0e0dc053d074aa5aff8b67c39 | |
| parent | 9827758ebe3c0b6b4f06dedc814b810629b184e3 (diff) | |
| download | poky-9c007cb1e35f4744682f9f00fe15ceb18fbf7ffc.tar.gz | |
bitbake: fetch2/git: Use os.rename instead of mv
os.rename will overwrite the destination file if present so we can use this
instead of the process call overhead.
(Bitbake rev: c5b8a2fce98c362ea77d74a8bc472d01b739a98a)
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
(cherry picked from commit b3cccaa6a896c41d8c9be5eebc327f726542d16b)
Signed-off-by: Steve Sakoman <steve@sakoman.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
| -rw-r--r-- | bitbake/lib/bb/fetch2/git.py | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/bitbake/lib/bb/fetch2/git.py b/bitbake/lib/bb/fetch2/git.py index 81335c117e..000aee190d 100644 --- a/bitbake/lib/bb/fetch2/git.py +++ b/bitbake/lib/bb/fetch2/git.py | |||
| @@ -412,14 +412,14 @@ class Git(FetchMethod): | |||
| 412 | 412 | ||
| 413 | # Create as a temp file and move atomically into position to avoid races | 413 | # Create as a temp file and move atomically into position to avoid races |
| 414 | @contextmanager | 414 | @contextmanager |
| 415 | def create_atomic(filename, d): | 415 | def create_atomic(filename): |
| 416 | fd, tfile = tempfile.mkstemp(dir=os.path.dirname(filename)) | 416 | fd, tfile = tempfile.mkstemp(dir=os.path.dirname(filename)) |
| 417 | try: | 417 | try: |
| 418 | yield tfile | 418 | yield tfile |
| 419 | umask = os.umask(0o666) | 419 | umask = os.umask(0o666) |
| 420 | os.umask(umask) | 420 | os.umask(umask) |
| 421 | os.chmod(tfile, (0o666 & ~umask)) | 421 | os.chmod(tfile, (0o666 & ~umask)) |
| 422 | runfetchcmd("mv %s %s" % (tfile, filename), d) | 422 | os.rename(tfile, filename) |
| 423 | finally: | 423 | finally: |
| 424 | os.close(fd) | 424 | os.close(fd) |
| 425 | 425 | ||
| @@ -433,7 +433,7 @@ class Git(FetchMethod): | |||
| 433 | self.clone_shallow_local(ud, shallowclone, d) | 433 | self.clone_shallow_local(ud, shallowclone, d) |
| 434 | 434 | ||
| 435 | logger.info("Creating tarball of git repository") | 435 | logger.info("Creating tarball of git repository") |
| 436 | with create_atomic(ud.fullshallow, d) as tfile: | 436 | with create_atomic(ud.fullshallow) as tfile: |
| 437 | runfetchcmd("tar -czf %s ." % tfile, d, workdir=shallowclone) | 437 | runfetchcmd("tar -czf %s ." % tfile, d, workdir=shallowclone) |
| 438 | runfetchcmd("touch %s.done" % ud.fullshallow, d) | 438 | runfetchcmd("touch %s.done" % ud.fullshallow, d) |
| 439 | finally: | 439 | finally: |
| @@ -443,7 +443,7 @@ class Git(FetchMethod): | |||
| 443 | os.unlink(ud.fullmirror) | 443 | os.unlink(ud.fullmirror) |
| 444 | 444 | ||
| 445 | logger.info("Creating tarball of git repository") | 445 | logger.info("Creating tarball of git repository") |
| 446 | with create_atomic(ud.fullmirror, d) as tfile: | 446 | with create_atomic(ud.fullmirror) as tfile: |
| 447 | runfetchcmd("tar -czf %s ." % tfile, d, workdir=ud.clonedir) | 447 | runfetchcmd("tar -czf %s ." % tfile, d, workdir=ud.clonedir) |
| 448 | runfetchcmd("touch %s.done" % ud.fullmirror, d) | 448 | runfetchcmd("touch %s.done" % ud.fullmirror, d) |
| 449 | 449 | ||
