diff options
-rw-r--r-- | meta/lib/oe/path.py | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/meta/lib/oe/path.py b/meta/lib/oe/path.py index d4685403c5..a2a50c5b39 100644 --- a/meta/lib/oe/path.py +++ b/meta/lib/oe/path.py | |||
@@ -50,6 +50,27 @@ def make_relative_symlink(path): | |||
50 | os.remove(path) | 50 | os.remove(path) |
51 | os.symlink(base, path) | 51 | os.symlink(base, path) |
52 | 52 | ||
53 | def replace_absolute_symlinks(basedir, d): | ||
54 | """ | ||
55 | Walk basedir looking for absolute symlinks and replacing them with relative ones. | ||
56 | The absolute links are assumed to be relative to basedir | ||
57 | (compared to make_relative_symlink above which tries to compute common ancestors | ||
58 | using pattern matching instead) | ||
59 | """ | ||
60 | for walkroot, dirs, files in os.walk(basedir): | ||
61 | for file in files + dirs: | ||
62 | path = os.path.join(walkroot, file) | ||
63 | if not os.path.islink(path): | ||
64 | continue | ||
65 | link = os.readlink(path) | ||
66 | if not os.path.isabs(link): | ||
67 | continue | ||
68 | walkdir = os.path.dirname(path.rpartition(basedir)[2]) | ||
69 | base = os.path.relpath(link, walkdir) | ||
70 | bb.debug(2, "Replacing absolute path %s with relative path %s" % (link, base)) | ||
71 | os.remove(path) | ||
72 | os.symlink(base, path) | ||
73 | |||
53 | def format_display(path, metadata): | 74 | def format_display(path, metadata): |
54 | """ Prepare a path for display to the user. """ | 75 | """ Prepare a path for display to the user. """ |
55 | rel = relative(metadata.getVar("TOPDIR"), path) | 76 | rel = relative(metadata.getVar("TOPDIR"), path) |