Mount bind external distfiles into the chroot.

Purpose of this is to allow us to avoid re-downloading everything
every time we rebuild the chroot.

This maintains two directories; host and target.  Future enhancement
involves collapsing this into one- this requires some host work however,
and has some potential gotchas in doing so.

Meanwhile, we now store distfiles in repo/distfiles/{host,target},
and mount bind repo/distfiles into /var/cache/distfiles.

An upgrade script in turn optimistically tries to move the content
into the new location; if it can't complete the move, it wipes the
content and the user has to redownload it (acceptable, if annoying).

BUG=chromium-os:13115
TEST=cbuildbot x86-generic-full

Change-Id: Iea96429df0e1fdc4ac0860fbce0daabc90c4c2a3
Reviewed-on: https://gerrit.chromium.org/gerrit/15189
Reviewed-by: Brian Harring <ferringb@chromium.org>
Tested-by: Brian Harring <ferringb@chromium.org>
Commit-Ready: Brian Harring <ferringb@chromium.org>
diff --git a/sdk_lib/make_chroot.sh b/sdk_lib/make_chroot.sh
index f26dbab..2ac5767 100755
--- a/sdk_lib/make_chroot.sh
+++ b/sdk_lib/make_chroot.sh
@@ -198,9 +198,15 @@
    sudo chmod 0644 "${FLAGS_chroot}"/etc/make.conf.user
 
    # Create directories referred to by our conf files.
-   sudo mkdir -p -m 775 "${FLAGS_chroot}/var/lib/portage/distfiles" \
-     "${FLAGS_chroot}/var/lib/portage/distfiles-target" \
-     "${FLAGS_chroot}/var/lib/portage/pkgs"
+   sudo mkdir -p -m 775 "${FLAGS_chroot}/var/lib/portage/pkgs"
+
+   # These are created for compatibility while transitioning
+   # make.conf and friends over to the new location.
+   # TODO(ferringb): remove this 03/12 or so.
+   sudo ln -s ../../cache/distfiles/host \
+     "${FLAGS_chroot}/var/lib/portage/distfiles"
+   sudo ln -s ../../cache/distfiles/target \
+     "${FLAGS_chroot}/var/lib/portage/distfiles-target"
 
    if [[ $FLAGS_jobs -ne -1 ]]; then
      EMERGE_JOBS="--jobs=$FLAGS_jobs"