diff options
| -rw-r--r-- | bitbake/lib/bb/utils.py | 19 |
1 files changed, 10 insertions, 9 deletions
diff --git a/bitbake/lib/bb/utils.py b/bitbake/lib/bb/utils.py index 8550af34ae..c540b49cf6 100644 --- a/bitbake/lib/bb/utils.py +++ b/bitbake/lib/bb/utils.py | |||
| @@ -771,13 +771,14 @@ def movefile(src, dest, newmtime = None, sstat = None): | |||
| 771 | return None | 771 | return None |
| 772 | 772 | ||
| 773 | renamefailed = 1 | 773 | renamefailed = 1 |
| 774 | # os.rename needs to know the dest path ending with file name | ||
| 775 | # so append the file name to a path only if it's a dir specified | ||
| 776 | srcfname = os.path.basename(src) | ||
| 777 | destpath = os.path.join(dest, srcfname) if os.path.isdir(dest) \ | ||
| 778 | else dest | ||
| 779 | |||
| 774 | if sstat[stat.ST_DEV] == dstat[stat.ST_DEV]: | 780 | if sstat[stat.ST_DEV] == dstat[stat.ST_DEV]: |
| 775 | try: | 781 | try: |
| 776 | # os.rename needs to know the dest path ending with file name | ||
| 777 | # so append the file name to a path only if it's a dir specified | ||
| 778 | srcfname = os.path.basename(src) | ||
| 779 | destpath = os.path.join(dest, srcfname) if os.path.isdir(dest) \ | ||
| 780 | else dest | ||
| 781 | os.rename(src, destpath) | 782 | os.rename(src, destpath) |
| 782 | renamefailed = 0 | 783 | renamefailed = 0 |
| 783 | except Exception as e: | 784 | except Exception as e: |
| @@ -791,8 +792,8 @@ def movefile(src, dest, newmtime = None, sstat = None): | |||
| 791 | didcopy = 0 | 792 | didcopy = 0 |
| 792 | if stat.S_ISREG(sstat[stat.ST_MODE]): | 793 | if stat.S_ISREG(sstat[stat.ST_MODE]): |
| 793 | try: # For safety copy then move it over. | 794 | try: # For safety copy then move it over. |
| 794 | shutil.copyfile(src, dest + "#new") | 795 | shutil.copyfile(src, destpath + "#new") |
| 795 | os.rename(dest + "#new", dest) | 796 | os.rename(destpath + "#new", destpath) |
| 796 | didcopy = 1 | 797 | didcopy = 1 |
| 797 | except Exception as e: | 798 | except Exception as e: |
| 798 | print('movefile: copy', src, '->', dest, 'failed.', e) | 799 | print('movefile: copy', src, '->', dest, 'failed.', e) |
| @@ -813,9 +814,9 @@ def movefile(src, dest, newmtime = None, sstat = None): | |||
| 813 | return None | 814 | return None |
| 814 | 815 | ||
| 815 | if newmtime: | 816 | if newmtime: |
| 816 | os.utime(dest, (newmtime, newmtime)) | 817 | os.utime(destpath, (newmtime, newmtime)) |
| 817 | else: | 818 | else: |
| 818 | os.utime(dest, (sstat[stat.ST_ATIME], sstat[stat.ST_MTIME])) | 819 | os.utime(destpath, (sstat[stat.ST_ATIME], sstat[stat.ST_MTIME])) |
| 819 | newmtime = sstat[stat.ST_MTIME] | 820 | newmtime = sstat[stat.ST_MTIME] |
| 820 | return newmtime | 821 | return newmtime |
| 821 | 822 | ||
