diff options
Diffstat (limited to 'bitbake/lib/bb/utils.py')
-rw-r--r-- | bitbake/lib/bb/utils.py | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/bitbake/lib/bb/utils.py b/bitbake/lib/bb/utils.py index b20cdabcf0..56894f130f 100644 --- a/bitbake/lib/bb/utils.py +++ b/bitbake/lib/bb/utils.py | |||
@@ -906,6 +906,23 @@ def copyfile(src, dest, newmtime = None, sstat = None): | |||
906 | newmtime = sstat[stat.ST_MTIME] | 906 | newmtime = sstat[stat.ST_MTIME] |
907 | return newmtime | 907 | return newmtime |
908 | 908 | ||
909 | def break_hardlinks(src, sstat = None): | ||
910 | """ | ||
911 | Ensures src is the only hardlink to this file. Other hardlinks, | ||
912 | if any, are not affected (other than in their st_nlink value, of | ||
913 | course). Returns true on success and false on failure. | ||
914 | |||
915 | """ | ||
916 | try: | ||
917 | if not sstat: | ||
918 | sstat = os.lstat(src) | ||
919 | except Exception as e: | ||
920 | logger.warning("break_hardlinks: stat of %s failed (%s)" % (src, e)) | ||
921 | return False | ||
922 | if sstat[stat.ST_NLINK] == 1: | ||
923 | return True | ||
924 | return copyfile(src, src, sstat=sstat) | ||
925 | |||
909 | def which(path, item, direction = 0, history = False, executable=False): | 926 | def which(path, item, direction = 0, history = False, executable=False): |
910 | """ | 927 | """ |
911 | Locate `item` in the list of paths `path` (colon separated string like $PATH). | 928 | Locate `item` in the list of paths `path` (colon separated string like $PATH). |