]>
git.ipfire.org Git - thirdparty/openembedded/openembedded-core.git/blob - scripts/sysroot-relativelinks.py
3 # SPDX-License-Identifier: GPL-2.0-only
9 # Take a sysroot directory and turn all the abolute symlinks and turn them into
10 # relative ones such that the sysroot is usable within another system.
12 if len(sys
.argv
) != 2:
13 print("Usage is " + sys
.argv
[0] + "<directory>")
17 topdir
= os
.path
.abspath(topdir
)
19 def handlelink(filep
, subdir
):
20 link
= os
.readlink(filep
)
23 if link
.startswith(topdir
):
25 #print("Replacing %s with %s for %s" % (link, topdir+link, filep))
26 print("Replacing %s with %s for %s" % (link
, os
.path
.relpath(topdir
+link
, subdir
), filep
))
28 os
.symlink(os
.path
.relpath(topdir
+link
, subdir
), filep
)
30 for subdir
, dirs
, files
in os
.walk(topdir
):
31 for f
in dirs
+ files
:
32 filep
= os
.path
.join(subdir
, f
)
33 if os
.path
.islink(filep
):
34 #print("Considering %s" % filep)
35 handlelink(filep
, subdir
)