diff options
author | Richard Purdie <richard.purdie@linuxfoundation.org> | 2011-02-25 17:22:00 +0000 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2011-02-25 17:24:34 +0000 |
commit | 9166b9e32fd6f618f9597b07d88cef09a88916a1 (patch) | |
tree | 8fc6b42575c15bec9866e10a5ded7aa5bc368a8a /bitbake/lib | |
parent | b931aaa678920036f8959f6ec0cb710232f20def (diff) | |
download | poky-9166b9e32fd6f618f9597b07d88cef09a88916a1.tar.gz |
bitbake/utils.py: Only try and add read access to a file if we don't have it
A file we're copying might be on a readonly filesystem so if we can already read
it, don't try and add read permission.
Fixes BUGID #771 in Yocto.
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'bitbake/lib')
-rw-r--r-- | bitbake/lib/bb/utils.py | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/bitbake/lib/bb/utils.py b/bitbake/lib/bb/utils.py index 44419d8f2a..a6f1337114 100644 --- a/bitbake/lib/bb/utils.py +++ b/bitbake/lib/bb/utils.py | |||
@@ -773,16 +773,23 @@ def copyfile(src, dest, newmtime = None, sstat = None): | |||
773 | return False | 773 | return False |
774 | 774 | ||
775 | if stat.S_ISREG(sstat[stat.ST_MODE]): | 775 | if stat.S_ISREG(sstat[stat.ST_MODE]): |
776 | os.chmod(src, stat.S_IRUSR) # Make sure we can read it | 776 | try: |
777 | try: # For safety copy then move it over. | 777 | srcchown = False |
778 | if not os.access(src, os.R_OK): | ||
779 | # Make sure we can read it | ||
780 | srcchown = True | ||
781 | os.chmod(src, sstat[stat.ST_MODE] | stat.S_IRUSR) | ||
782 | |||
783 | # For safety copy then move it over. | ||
778 | shutil.copyfile(src, dest + "#new") | 784 | shutil.copyfile(src, dest + "#new") |
779 | os.rename(dest + "#new", dest) | 785 | os.rename(dest + "#new", dest) |
780 | except Exception as e: | 786 | except Exception as e: |
781 | print('copyfile: copy', src, '->', dest, 'failed.', e) | 787 | print('copyfile: copy', src, '->', dest, 'failed.', e) |
782 | return False | 788 | return False |
783 | finally: | 789 | finally: |
784 | os.chmod(src, sstat[stat.ST_MODE]) | 790 | if srcchown: |
785 | os.utime(src, (sstat[stat.ST_ATIME], sstat[stat.ST_MTIME])) | 791 | os.chmod(src, sstat[stat.ST_MODE]) |
792 | os.utime(src, (sstat[stat.ST_ATIME], sstat[stat.ST_MTIME])) | ||
786 | 793 | ||
787 | else: | 794 | else: |
788 | #we don't yet handle special, so we need to fall back to /bin/mv | 795 | #we don't yet handle special, so we need to fall back to /bin/mv |