remember device-specific releasetools extensions in target-files

Store the location of the releasetools extensions in the target-files
zip, and make ota_from_target_files use that stored location by
default (though it can still be overridden with -s if desired).
diff --git a/tools/releasetools/common.py b/tools/releasetools/common.py
index e758deb..27264dd 100644
--- a/tools/releasetools/common.py
+++ b/tools/releasetools/common.py
@@ -440,7 +440,7 @@
 
     if self.module is None:
       path = OPTIONS.device_specific
-      if path is None: return
+      if not path: return
       try:
         if os.path.isdir(path):
           info = imp.find_module("releasetools", [path])
diff --git a/tools/releasetools/ota_from_target_files b/tools/releasetools/ota_from_target_files
index 299e60a..e719696 100755
--- a/tools/releasetools/ota_from_target_files
+++ b/tools/releasetools/ota_from_target_files
@@ -57,6 +57,7 @@
   sys.exit(1)
 
 import copy
+import errno
 import os
 import re
 import sha
@@ -855,6 +856,23 @@
   print "unzipping target target-files..."
   OPTIONS.input_tmp = common.UnzipTemp(args[0])
 
+  if OPTIONS.device_specific is None:
+    # look for the device-specific tools extension location in the input
+    try:
+      f = open(os.path.join(OPTIONS.input_tmp, "META", "tool-extensions.txt"))
+      ds = f.read().strip()
+      f.close()
+      if ds:
+        ds = os.path.normpath(ds)
+        print "using device-specific extensions in", ds
+        OPTIONS.device_specific = ds
+    except IOError, e:
+      if e.errno == errno.ENOENT:
+        # nothing specified in the file
+        pass
+      else:
+        raise
+
   common.LoadMaxSizes()
   if not OPTIONS.max_image_size:
     print