From 60f9d69e016b11c468c98ea75ba0a60c44afbbc4 Mon Sep 17 00:00:00 2001 From: Patrick Williams Date: Wed, 17 Aug 2016 14:31:25 -0500 Subject: yocto-poky: Move to import-layers subdir We are going to import additional layers, so create a subdir to hold all of the layers that we import with git-subtree. Change-Id: I6f732153a22be8ca663035c518837e3cc5ec0799 Signed-off-by: Patrick Williams --- .../yocto-poky/scripts/sysroot-relativelinks.py | 31 ++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100755 import-layers/yocto-poky/scripts/sysroot-relativelinks.py (limited to 'import-layers/yocto-poky/scripts/sysroot-relativelinks.py') diff --git a/import-layers/yocto-poky/scripts/sysroot-relativelinks.py b/import-layers/yocto-poky/scripts/sysroot-relativelinks.py new file mode 100755 index 000000000..ac26367e7 --- /dev/null +++ b/import-layers/yocto-poky/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] + "") + 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) -- cgit v1.2.1