Converted tc-enter-chroot.sh into tc_enter_chroot.py.
 Python scripts are more readable and maintainable.
 Also added a USE="mounted_sources" flag to be passed to the ebuild.
 The ebuild changes will come in later in the chromium codereview server.
 In a few days once we've ported all our scripts to use tc_enter_toolchain.py,
 I will remove it from the repo.
 Testing:
 Did a full/incremental build of the toolchain using mounted sources and
 it worked.

PRESUBMIT=passed
R=raymes,bjanakiraman
DELTA=138  (124 added, 5 deleted, 9 changed)
OCL=45248-p2
RCL=45275-p2
RDATE=2010/11/17 10:33:39


P4 change: 42606260
diff --git a/v14/build_tc.py b/v14/build_tc.py
index 352abe5..ea05156 100755
--- a/v14/build_tc.py
+++ b/v14/build_tc.py
@@ -12,6 +12,7 @@
 import getpass
 import optparse
 import sys
+import tc_enter_chroot
 from utils import utils
 
 # Common initializations
@@ -65,11 +66,12 @@
   env = CreateEnvVarString(" FEATURES", features)
   env += CreateEnvVarString(" PORTAGE_USERNAME", getpass.getuser())
   version_number = utils.GetRoot(rootdir)[1]
-  version_dir = "/home/${USER}/toolchain_root/" + version_number
+  version_dir = "/usr/local/toolchain_root/" + version_number
   env += CreateEnvVarString(" PORT_LOGDIR", version_dir + "/logs")
   env += CreateEnvVarString(" PKGDIR", version_dir + "/pkgs")
   env += CreateEnvVarString(" PORTAGE_BINHOST", version_dir + "/pkgs")
   env += CreateEnvVarString(" PORTAGE_TMPDIR", version_dir + "/objects")
+  env += CreateEnvVarString(" USE", "mounted_sources")
 
   retval = 0
   if options.force == True:
@@ -125,6 +127,9 @@
   libc_version = "2.10.1-r1"
   kernel_version = "2.6.30-r1"
 
+  sys.argv = ["--chromeos_root=" + chromeos_root,
+              "--toolchain_root=" + toolchain_root]
+
   env += " "
 
   if uninstall == True:
@@ -132,17 +137,12 @@
   else:
     tflag = " -t "
 
-  command = (rootdir + "/tc-enter-chroot.sh")
-  if chromeos_root is not None:
-    command += " --chromeos_root=" + chromeos_root
-  if toolchain_root is not None:
-    command += " --toolchain_root=" + toolchain_root
-  command += " -- \"sudo " + env
+  command = "sudo " + env
 
   if uninstall == True:
     command += " crossdev " + tflag + target
-    command += "\""
-    retval = utils.RunCommand(command)
+    sys.argv.append(command)
+    retval = tc_enter_chroot.Main()
     return retval
 
   if incremental_component == "binutils":
@@ -163,8 +163,8 @@
                 " --kernel " + kernel_version +
                 crossdev_flags)
 
-  command += "\""
-  retval = utils.RunCommand(command)
+  sys.argv.append(command)
+  retval = tc_enter_chroot.Main()
   return retval
 
 if __name__ == "__main__":