From a38cf3610db33dcd2a43f59b5fff8be81b821fe4 Mon Sep 17 00:00:00 2001 From: Avi Kivity <avi@cloudius-systems.com> Date: Mon, 6 May 2013 13:36:32 +0300 Subject: [PATCH] mkbootfs: hack around absolute symbolic links in source Absolute symbolic links refer to the host directory structure, while we want them to refer to the external/ tree. Since we have several trees, we can't just rebase them, so walk down the tree trying to find a match. Fragile and ugly, but seems to work. --- scripts/mkbootfs.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/scripts/mkbootfs.py b/scripts/mkbootfs.py index b1a67a848..00a540a8c 100755 --- a/scripts/mkbootfs.py +++ b/scripts/mkbootfs.py @@ -63,7 +63,22 @@ def expand(items): else: yield (name, hostname) +def unsymlink(f): + try: + link = os.readlink(f) + if link.startswith('/'): + # try to find a match + base = os.path.dirname(f) + while not os.path.exists(base + link): + base = os.path.dirname(base) + else: + base = os.path.dirname(f) + '/' + return unsymlink(base + link) + except Exception: + return f + files = list(expand(files.items())) +files = [(x, unsymlink(y)) for (x, y) in files] pos = (len(files) + 1) * metadata_size -- GitLab