summaryrefslogtreecommitdiffstats
path: root/scripts/sysroot-relativelinks.py
diff options
context:
space:
mode:
authorTudor Florea <tudor.florea@enea.com>2014-10-16 03:05:19 +0200
committerTudor Florea <tudor.florea@enea.com>2014-10-16 03:05:19 +0200
commitc527fd1f14c27855a37f2e8ac5346ce8d940ced2 (patch)
treebb002c1fdf011c41dbd2f0927bed23ecb5f83c97 /scripts/sysroot-relativelinks.py
downloadpoky-daisy-140929.tar.gz
initial commit for Enea Linux 4.0-140929daisy-140929
Migrated from the internal git server on the daisy-enea-point-release branch Signed-off-by: Tudor Florea <tudor.florea@enea.com>
Diffstat (limited to 'scripts/sysroot-relativelinks.py')
-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 @@
1#!/usr/bin/env python
2import sys
3import os
4
5# Take a sysroot directory and turn all the abolute symlinks and turn them into
6# relative ones such that the sysroot is usable within another system.
7
8if len(sys.argv) != 2:
9 print("Usage is " + sys.argv[0] + "<directory>")
10 sys.exit(1)
11
12topdir = sys.argv[1]
13topdir = os.path.abspath(topdir)
14
15def handlelink(filep, subdir):
16 link = os.readlink(filep)
17 if link[0] != "/":
18 return
19 if link.startswith(topdir):
20 return
21 #print("Replacing %s with %s for %s" % (link, topdir+link, filep))
22 print("Replacing %s with %s for %s" % (link, os.path.relpath(topdir+link, subdir), filep))
23 os.unlink(filep)
24 os.symlink(os.path.relpath(topdir+link, subdir), filep)
25
26for subdir, dirs, files in os.walk(topdir):
27 for f in files:
28 filep = os.path.join(subdir, f)
29 if os.path.islink(filep):
30 #print("Considering %s" % filep)
31 handlelink(filep, subdir)