diff options
author | Richard Purdie <richard.purdie@linuxfoundation.org> | 2021-10-25 22:15:49 +0800 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2021-10-25 20:54:25 +0100 |
commit | bb4a95c819a596d2e37c28fbc143103f3d3b2fec (patch) | |
tree | a21c4be355801c1862652bedc9d0056ceb175b7f /bitbake | |
parent | f5fd1c2fd3d50adcc0039b30694dd8e7e4070bd4 (diff) | |
download | poky-bb4a95c819a596d2e37c28fbc143103f3d3b2fec.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: 7be6d18cd74291371f5327dcab2412f508c70189)
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
(cherry picked from commit b3cccaa6a896c41d8c9be5eebc327f726542d16b)
Signed-off-by: Anuj Mittal <anuj.mittal@intel.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'bitbake')
-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 95cd971d56..00105183b7 100644 --- a/bitbake/lib/bb/fetch2/git.py +++ b/bitbake/lib/bb/fetch2/git.py | |||
@@ -418,14 +418,14 @@ class Git(FetchMethod): | |||
418 | 418 | ||
419 | # Create as a temp file and move atomically into position to avoid races | 419 | # Create as a temp file and move atomically into position to avoid races |
420 | @contextmanager | 420 | @contextmanager |
421 | def create_atomic(filename, d): | 421 | def create_atomic(filename): |
422 | fd, tfile = tempfile.mkstemp(dir=os.path.dirname(filename)) | 422 | fd, tfile = tempfile.mkstemp(dir=os.path.dirname(filename)) |
423 | try: | 423 | try: |
424 | yield tfile | 424 | yield tfile |
425 | umask = os.umask(0o666) | 425 | umask = os.umask(0o666) |
426 | os.umask(umask) | 426 | os.umask(umask) |
427 | os.chmod(tfile, (0o666 & ~umask)) | 427 | os.chmod(tfile, (0o666 & ~umask)) |
428 | runfetchcmd("mv %s %s" % (tfile, filename), d) | 428 | os.rename(tfile, filename) |
429 | finally: | 429 | finally: |
430 | os.close(fd) | 430 | os.close(fd) |
431 | 431 | ||
@@ -439,7 +439,7 @@ class Git(FetchMethod): | |||
439 | self.clone_shallow_local(ud, shallowclone, d) | 439 | self.clone_shallow_local(ud, shallowclone, d) |
440 | 440 | ||
441 | logger.info("Creating tarball of git repository") | 441 | logger.info("Creating tarball of git repository") |
442 | with create_atomic(ud.fullshallow, d) as tfile: | 442 | with create_atomic(ud.fullshallow) as tfile: |
443 | runfetchcmd("tar -czf %s ." % tfile, d, workdir=shallowclone) | 443 | runfetchcmd("tar -czf %s ." % tfile, d, workdir=shallowclone) |
444 | runfetchcmd("touch %s.done" % ud.fullshallow, d) | 444 | runfetchcmd("touch %s.done" % ud.fullshallow, d) |
445 | finally: | 445 | finally: |
@@ -449,7 +449,7 @@ class Git(FetchMethod): | |||
449 | os.unlink(ud.fullmirror) | 449 | os.unlink(ud.fullmirror) |
450 | 450 | ||
451 | logger.info("Creating tarball of git repository") | 451 | logger.info("Creating tarball of git repository") |
452 | with create_atomic(ud.fullmirror, d) as tfile: | 452 | with create_atomic(ud.fullmirror) as tfile: |
453 | runfetchcmd("tar -czf %s ." % tfile, d, workdir=ud.clonedir) | 453 | runfetchcmd("tar -czf %s ." % tfile, d, workdir=ud.clonedir) |
454 | runfetchcmd("touch %s.done" % ud.fullmirror, d) | 454 | runfetchcmd("touch %s.done" % ud.fullmirror, d) |
455 | 455 | ||