[oe-commits] [bitbake] branch master-next updated: bitbake: lib/bb/utils: fix movefile() copy to dir fallback

git at git.openembedded.org git at git.openembedded.org
Fri Sep 22 16:44:20 UTC 2017


This is an automated email from the git hooks/post-receive script.

rpurdie pushed a commit to branch master-next
in repository bitbake.

The following commit(s) were added to refs/heads/master-next by this push:
     new 14c1748  bitbake: lib/bb/utils: fix movefile() copy to dir fallback
14c1748 is described below

commit 14c17480827ced2e03c1b62dc839696421fc4de8
Author: Mardegan, Alberto <AMardegan at luxoft.com>
AuthorDate: Thu Sep 21 14:33:52 2017 +0000

    bitbake: lib/bb/utils: fix movefile() copy to dir fallback
    
    When the destination is a directory, building the the destination file
    path is always needed.  That's because even if the copy fallback is
    taken, it's always followed by a rename.
    
    Signed-off-by: Alberto Mardegan <amardegan at luxoft.com>
    Signed-off-by: Richard Purdie <richard.purdie at linuxfoundation.org>
---
 lib/bb/utils.py | 19 ++++++++++---------
 1 file changed, 10 insertions(+), 9 deletions(-)

diff --git a/lib/bb/utils.py b/lib/bb/utils.py
index 8550af3..c540b49 100644
--- a/lib/bb/utils.py
+++ b/lib/bb/utils.py
@@ -771,13 +771,14 @@ def movefile(src, dest, newmtime = None, sstat = None):
             return None
 
     renamefailed = 1
+    # os.rename needs to know the dest path ending with file name
+    # so append the file name to a path only if it's a dir specified
+    srcfname = os.path.basename(src)
+    destpath = os.path.join(dest, srcfname) if os.path.isdir(dest) \
+                else dest
+
     if sstat[stat.ST_DEV] == dstat[stat.ST_DEV]:
         try:
-            # os.rename needs to know the dest path ending with file name
-            # so append the file name to a path only if it's a dir specified
-            srcfname = os.path.basename(src)
-            destpath = os.path.join(dest, srcfname) if os.path.isdir(dest) \
-                        else dest
             os.rename(src, destpath)
             renamefailed = 0
         except Exception as e:
@@ -791,8 +792,8 @@ def movefile(src, dest, newmtime = None, sstat = None):
         didcopy = 0
         if stat.S_ISREG(sstat[stat.ST_MODE]):
             try: # For safety copy then move it over.
-                shutil.copyfile(src, dest + "#new")
-                os.rename(dest + "#new", dest)
+                shutil.copyfile(src, destpath + "#new")
+                os.rename(destpath + "#new", destpath)
                 didcopy = 1
             except Exception as e:
                 print('movefile: copy', src, '->', dest, 'failed.', e)
@@ -813,9 +814,9 @@ def movefile(src, dest, newmtime = None, sstat = None):
             return None
 
     if newmtime:
-        os.utime(dest, (newmtime, newmtime))
+        os.utime(destpath, (newmtime, newmtime))
     else:
-        os.utime(dest, (sstat[stat.ST_ATIME], sstat[stat.ST_MTIME]))
+        os.utime(destpath, (sstat[stat.ST_ATIME], sstat[stat.ST_MTIME]))
         newmtime = sstat[stat.ST_MTIME]
     return newmtime
 

-- 
To stop receiving notification emails like this one, please contact
the administrator of this repository.


More information about the Openembedded-commits mailing list