envsetup: Fix remote functions to deal with symlinks

Change-Id: I6f35dc30dda22149b2c37e1c6c7d41ea7239d3bb
merge changes from CyanogenMod 10.2 into local branch