summaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
authorRichard Purdie <richard.purdie@linuxfoundation.org>2013-09-11 10:42:44 +0100
committerRichard Purdie <richard.purdie@linuxfoundation.org>2013-09-11 11:04:51 +0100
commit57d6bdcad55c119e9ab8089d23d462436a0e4440 (patch)
treed8ab2161b5cacfd21bc33ebe71767e90248301bb /scripts
parent9951e1da6a755f9a46d3a595aa4c2f975aee8f46 (diff)
downloadopenembedded-core-57d6bdcad55c119e9ab8089d23d462436a0e4440.tar.gz
openembedded-core-57d6bdcad55c119e9ab8089d23d462436a0e4440.tar.bz2
openembedded-core-57d6bdcad55c119e9ab8089d23d462436a0e4440.zip
image/populate_sdk: Ensure symlinks in target sysroot are relative
In the target sysroot of an SDK we can have target system absolute links which don't make sense. This adds a script which fixes them up to become relative paths instead. [YOCTO #5020] Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'scripts')
-rwxr-xr-xscripts/sysroot-relativelinks.py31
1 files changed, 31 insertions, 0 deletions
diff --git a/scripts/sysroot-relativelinks.py b/scripts/sysroot-relativelinks.py
new file mode 100755
index 0000000000..ac26367e77
--- /dev/null
+++ b/scripts/sysroot-relativelinks.py
@@ -0,0 +1,31 @@
+#!/usr/bin/env python
+import sys
+import os
+
+# Take a sysroot directory and turn all the abolute symlinks and turn them into
+# relative ones such that the sysroot is usable within another system.
+
+if len(sys.argv) != 2:
+ print("Usage is " + sys.argv[0] + "<directory>")
+ sys.exit(1)
+
+topdir = sys.argv[1]
+topdir = os.path.abspath(topdir)
+
+def handlelink(filep, subdir):
+ link = os.readlink(filep)
+ if link[0] != "/":
+ return
+ if link.startswith(topdir):
+ return
+ #print("Replacing %s with %s for %s" % (link, topdir+link, filep))
+ print("Replacing %s with %s for %s" % (link, os.path.relpath(topdir+link, subdir), filep))
+ os.unlink(filep)
+ os.symlink(os.path.relpath(topdir+link, subdir), filep)
+
+for subdir, dirs, files in os.walk(topdir):
+ for f in files:
+ filep = os.path.join(subdir, f)
+ if os.path.islink(filep):
+ #print("Considering %s" % filep)
+ handlelink(filep, subdir)