]> git.ipfire.org Git - thirdparty/openembedded/openembedded-core-contrib.git/commitdiff
utils: Allow copyfile to copy files which aren't readable
authorRichard Purdie <rpurdie@linux.intel.com>
Fri, 20 Aug 2010 14:11:44 +0000 (15:11 +0100)
committerChris Larson <chris_larson@mentor.com>
Sat, 18 Dec 2010 00:19:03 +0000 (17:19 -0700)
Signed-off-by: Richard Purdie <rpurdie@linux.intel.com>
lib/bb/utils.py

index 92ec433334ab9d7233b1ae8d97de86ecdb3b7374..22793a9f654b84a817a93c75b201738f22f3450d 100644 (file)
@@ -731,11 +731,14 @@ 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.
             shutil.copyfile(src, dest + "#new")
             os.rename(dest + "#new", dest)
         except Exception as e:
             print('copyfile: copy', src, '->', dest, 'failed.', e)
+            os.chmod(src, stat.S_IMODE(sstat[stat.ST_MODE]))
+            os.utime(src, (sstat[stat.ST_ATIME], sstat[stat.ST_MTIME]))
             return False
         finally:
             os.chmod(src, sstat[stat.ST_MODE])