From b112a405a92a3f6b348f05369f22b019978599bb Mon Sep 17 00:00:00 2001 From: synergy Date: Fri, 5 Jul 2013 19:47:47 -0700 Subject: [PATCH] gettop: fix symlink detection Summary: We must use the -P flag for pwd to properly get $PWD from the environment *with* symlinks. Otherwise symlink detection is broken and anything we do using $(gettop) at the top of a symlinked path won't work properly. I noticed this issue while running on a system that has a SSD RAID symlinked to my android build home directory, which is ~/ssd_storage. The top in this instance is a symlink, which means that gettop() returns my home path, or the path above the symlink directory (but not the symlinked directory). This is a major issue in case developers choose to use $(gettop), $ANDROID_BUILD_TOP, or $T (doesn't really matter either way). Test Plan: Create a symlink and sync android source into the path. Open up the symlink, run envsetup.sh, and check $(gettop) output. While this isn't the best solution, it fixes an issue without creating new issues. Change-Id: I65bc345753805e6161098d2af6e0bee0b07d37b1 --- envsetup.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/envsetup.sh b/envsetup.sh index 70cb2de75..eaaf4a0f7 100644 --- a/envsetup.sh +++ b/envsetup.sh @@ -588,7 +588,7 @@ function gettop T= while [ \( ! \( -f $TOPFILE \) \) -a \( $PWD != "/" \) ]; do \cd .. - T=`PWD= /bin/pwd` + T=`PWD= /bin/pwd -P` done \cd $HERE if [ -f "$T/$TOPFILE" ]; then