diff options
author | Richard Purdie <richard.purdie@linuxfoundation.org> | 2021-09-19 11:27:16 +0100 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2021-09-21 23:44:08 +0100 |
commit | 435bce9bf96dfa18e2c8167420aa4032a02afb66 (patch) | |
tree | 314f102f855690475b93e90e961b7a10a937643a | |
parent | a0a9df0e8b5f62e69b65fa9f7129ac0954a45691 (diff) | |
download | poky-435bce9bf96dfa18e2c8167420aa4032a02afb66.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: b3cccaa6a896c41d8c9be5eebc327f726542d16b)
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 3643a491d7..e8ddf2c761 100644 --- a/bitbake/lib/bb/fetch2/git.py +++ b/bitbake/lib/bb/fetch2/git.py | |||
@@ -422,14 +422,14 @@ class Git(FetchMethod): | |||
422 | 422 | ||
423 | # Create as a temp file and move atomically into position to avoid races | 423 | # Create as a temp file and move atomically into position to avoid races |
424 | @contextmanager | 424 | @contextmanager |
425 | def create_atomic(filename, d): | 425 | def create_atomic(filename): |
426 | fd, tfile = tempfile.mkstemp(dir=os.path.dirname(filename)) | 426 | fd, tfile = tempfile.mkstemp(dir=os.path.dirname(filename)) |
427 | try: | 427 | try: |
428 | yield tfile | 428 | yield tfile |
429 | umask = os.umask(0o666) | 429 | umask = os.umask(0o666) |
430 | os.umask(umask) | 430 | os.umask(umask) |
431 | os.chmod(tfile, (0o666 & ~umask)) | 431 | os.chmod(tfile, (0o666 & ~umask)) |
432 | runfetchcmd("mv %s %s" % (tfile, filename), d) | 432 | os.rename(tfile, filename) |
433 | finally: | 433 | finally: |
434 | os.close(fd) | 434 | os.close(fd) |
435 | 435 | ||
@@ -443,7 +443,7 @@ class Git(FetchMethod): | |||
443 | self.clone_shallow_local(ud, shallowclone, d) | 443 | self.clone_shallow_local(ud, shallowclone, d) |
444 | 444 | ||
445 | logger.info("Creating tarball of git repository") | 445 | logger.info("Creating tarball of git repository") |
446 | with create_atomic(ud.fullshallow, d) as tfile: | 446 | with create_atomic(ud.fullshallow) as tfile: |
447 | runfetchcmd("tar -czf %s ." % tfile, d, workdir=shallowclone) | 447 | runfetchcmd("tar -czf %s ." % tfile, d, workdir=shallowclone) |
448 | runfetchcmd("touch %s.done" % ud.fullshallow, d) | 448 | runfetchcmd("touch %s.done" % ud.fullshallow, d) |
449 | finally: | 449 | finally: |
@@ -453,7 +453,7 @@ class Git(FetchMethod): | |||
453 | os.unlink(ud.fullmirror) | 453 | os.unlink(ud.fullmirror) |
454 | 454 | ||
455 | logger.info("Creating tarball of git repository") | 455 | logger.info("Creating tarball of git repository") |
456 | with create_atomic(ud.fullmirror, d) as tfile: | 456 | with create_atomic(ud.fullmirror) as tfile: |
457 | runfetchcmd("tar -czf %s ." % tfile, d, workdir=ud.clonedir) | 457 | runfetchcmd("tar -czf %s ." % tfile, d, workdir=ud.clonedir) |
458 | runfetchcmd("touch %s.done" % ud.fullmirror, d) | 458 | runfetchcmd("touch %s.done" % ud.fullmirror, d) |
459 | 459 | ||