Index: src/scripts/common.sh |
diff --git a/src/scripts/common.sh b/src/scripts/common.sh |
index 1023d480c7c76bba78f725647f0d426271e9f938..acd310d3eb697844461cdab5c913d6153fd16598 100644 |
--- a/src/scripts/common.sh |
+++ b/src/scripts/common.sh |
@@ -369,6 +369,26 @@ function safe_umount { |
fi |
} |
+# Fixes symlinks that are incorrectly prefixed with the build root ${1} |
+# rather than the real running root '/'. |
+# TODO(sosa) - Merge setup - cleanup below with this method. |
+fix_broken_symlinks() { |
+ local build_root="${1}" |
+ local symlinks=$(find "${build_root}/usr/local" -lname "${build_root}/*") |
+ for symlink in ${symlinks}; do |
+ echo "Fixing ${symlink}" |
+ local target=$(ls -l "${symlink}" | cut -f 2 -d '>') |
+ # Trim spaces from target (bashism). |
+ target=${target/ /} |
+ # Make new target (removes rootfs prefix). |
+ new_target=$(echo ${target} | sed "s#${build_root}##") |
+ |
+ echo "Fixing symlink ${symlink}" |
+ sudo unlink "${symlink}" |
+ sudo ln -sf "${new_target}" "${symlink}" |
+ done |
+} |
+ |
# Sets up symlinks for the developer root. It is necessary to symlink |
# usr and local since the developer root is mounted at /usr/local and |
# applications expect to be installed under /usr/local/bin, etc. |