enter_chroot: Link subversion configuration upon entry

The process of bootstrapping the chroot from sources was
failing for several reasons when run from behind a firewall
with proxies.  The llvm build was failing due to inability
to checkout sources through subversion using the
subversion.eclass wrapper (the "normal" way to do this in
the ebuild environment).  This was because the user's
subversion configuration (including proxy settings) was not
inherited from $HOME/.subversion into the in-chroot sandbox
used by subversion.eclass.

This change creates symbolic links in the subversion.eclass
sandboxes for host and target builds in the chroot to fix
any build that uses the normal subversion.eclass for
checkouts.  The operation is done at enter_chroot time so
that it applies to both ordinary builds and chroot creation
(via early_enter_chroot).

BUG=none
TEST='cros_sdk --replace --enter' behind proxied firewall

Change-Id: I0af2128866bb95799dc07c728c75cf3f2a0af7a3
Reviewed-on: https://gerrit.chromium.org/gerrit/34291
Reviewed-by: Mike Frysinger <vapier@chromium.org>
Commit-Ready: paul drews <paul.drews@intel.com>
Tested-by: paul drews <paul.drews@intel.com>
diff --git a/sdk_lib/enter_chroot.sh b/sdk_lib/enter_chroot.sh
index ee57fff..76b387a 100755
--- a/sdk_lib/enter_chroot.sh
+++ b/sdk_lib/enter_chroot.sh
@@ -399,6 +399,22 @@
       TARGET="/home/${USER}/.subversion"
       mkdir -p "${FLAGS_chroot}${TARGET}"
       queue_mount "${HOME}/.subversion" "--bind" "${TARGET}"
+      # Symbolic-link the .subversion directory so sandboxed subversion.class
+      # clients can use it.
+      local cmds=()
+      for d in \
+        "${FLAGS_cache_dir}"/distfiles/{host,target}/svn-src/"${USER}"; do
+        if [[ ! -L "${d}/.subversion" ]]; then
+          cmds+=(
+            "mkdir -p '${d}'"
+            "ln -sf /home/${USER}/.subversion '${d}/.subversion'"
+            "chown -R ${USER}:250 '${d%/*}'"
+          )
+        fi
+      done
+      if [[ ${#cmds[@]} -gt 0 ]]; then
+        sudo_multi "${cmds[@]}"
+      fi
     fi
 
     if DEPOT_TOOLS=$(type -P gclient) ; then