summaryrefslogtreecommitdiffstats
path: root/lib/bb/utils.py
diff options
context:
space:
mode:
authorRichard Purdie <richard.purdie@linuxfoundation.org>2011-02-25 17:22:00 +0000
committerRichard Purdie <richard.purdie@linuxfoundation.org>2011-05-06 18:21:17 +0100
commite4acd09735d4366b49e050a515f088a80345f626 (patch)
tree6068b3d9540fe3b8b2d3acf31626e130603c1432 /lib/bb/utils.py
parentd98bded97c7e5423ce674205236025ce8d1914b3 (diff)
downloadbitbake-e4acd09735d4366b49e050a515f088a80345f626.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. (From Poky rev: 9166b9e32fd6f618f9597b07d88cef09a88916a1) Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'lib/bb/utils.py')
-rw-r--r--lib/bb/utils.py15
1 files changed, 11 insertions, 4 deletions
diff --git a/lib/bb/utils.py b/lib/bb/utils.py
index bc83e7c9a..ccafda19e 100644
--- a/lib/bb/utils.py
+++ b/lib/bb/utils.py
@@ -772,16 +772,23 @@ def copyfile(src, dest, newmtime = None, sstat = None):
return False
if stat.S_ISREG(sstat[stat.ST_MODE]):
- os.chmod(src, stat.S_IRUSR) # Make sure we can read it
- try: # For safety copy then move it over.
+ try:
+ srcchown = False
+ if not os.access(src, os.R_OK):
+ # Make sure we can read it
+ srcchown = True
+ os.chmod(src, sstat[stat.ST_MODE] | stat.S_IRUSR)
+
+ # For safety copy then move it over.
shutil.copyfile(src, dest + "#new")
os.rename(dest + "#new", dest)
except Exception as e:
print('copyfile: copy', src, '->', dest, 'failed.', e)
return False
finally:
- os.chmod(src, sstat[stat.ST_MODE])
- os.utime(src, (sstat[stat.ST_ATIME], sstat[stat.ST_MTIME]))
+ if srcchown:
+ os.chmod(src, sstat[stat.ST_MODE])
+ os.utime(src, (sstat[stat.ST_ATIME], sstat[stat.ST_MTIME]))
else:
#we don't yet handle special, so we need to fall back to /bin/mv