From 602a84e0bbf1807a9403cfa50184241f6fc035c4 Mon Sep 17 00:00:00 2001 From: Doug Zongker Date: Thu, 18 Jun 2009 08:35:12 -0700 Subject: [PATCH] fix releasetools for non-linux architectures The ota and img building scripts contained some hardcoded 'linux-x86' paths. Remove and replace with a slightly redefined -p option. Modify Makefile to pass correct -p when building. --- core/Makefile | 2 ++ tools/releasetools/common.py | 40 +++++++++++------------ tools/releasetools/sign_target_files_apks | 4 ++- 3 files changed, 24 insertions(+), 22 deletions(-) diff --git a/core/Makefile b/core/Makefile index b1420b5363..5e5c7358ac 100644 --- a/core/Makefile +++ b/core/Makefile @@ -880,6 +880,7 @@ $(INTERNAL_OTA_PACKAGE_TARGET): KEY_CERT_PAIR := $(DEFAULT_KEY_CERT_PAIR) $(INTERNAL_OTA_PACKAGE_TARGET): $(BUILT_TARGET_FILES_PACKAGE) otatools @echo "Package OTA: $@" $(hide) ./build/tools/releasetools/ota_from_target_files \ + -p $(HOST_OUT) \ -b $(TARGET_DEVICE_DIR)/BoardConfig.mk \ -k $(KEY_CERT_PAIR) \ $(BUILT_TARGET_FILES_PACKAGE) $@ @@ -1005,6 +1006,7 @@ INTERNAL_UPDATE_PACKAGE_TARGET := $(PRODUCT_OUT)/$(name).zip $(INTERNAL_UPDATE_PACKAGE_TARGET): $(BUILT_TARGET_FILES_PACKAGE) otatools @echo "Package: $@" $(hide) ./build/tools/releasetools/img_from_target_files \ + -p $(HOST_OUT) \ -b $(TARGET_DEVICE_DIR)/BoardConfig.mk \ $(BUILT_TARGET_FILES_PACKAGE) $@ diff --git a/tools/releasetools/common.py b/tools/releasetools/common.py index 033ba22ab3..afb61a353a 100644 --- a/tools/releasetools/common.py +++ b/tools/releasetools/common.py @@ -29,8 +29,7 @@ if not hasattr(os, "SEEK_SET"): class Options(object): pass OPTIONS = Options() -OPTIONS.signapk_jar = "out/host/linux-x86/framework/signapk.jar" -OPTIONS.dumpkey_jar = "out/host/linux-x86/framework/dumpkey.jar" +OPTIONS.search_path = "out/host/linux-x86" OPTIONS.max_image_size = {} OPTIONS.verbose = False OPTIONS.tempfiles = [] @@ -145,11 +144,11 @@ def GetKeyPasswords(keylist): no_passwords.append(k) continue - p = subprocess.Popen(["openssl", "pkcs8", "-in", k+".pk8", - "-inform", "DER", "-nocrypt"], - stdin=devnull.fileno(), - stdout=devnull.fileno(), - stderr=subprocess.STDOUT) + p = Run(["openssl", "pkcs8", "-in", k+".pk8", + "-inform", "DER", "-nocrypt"], + stdin=devnull.fileno(), + stdout=devnull.fileno(), + stderr=subprocess.STDOUT) p.communicate() if p.returncode == 0: no_passwords.append(k) @@ -179,12 +178,13 @@ def SignFile(input_name, output_name, key, password, align=None): else: sign_name = output_name - p = subprocess.Popen(["java", "-jar", OPTIONS.signapk_jar, - key + ".x509.pem", - key + ".pk8", - input_name, sign_name], - stdin=subprocess.PIPE, - stdout=subprocess.PIPE) + p = Run(["java", "-jar", + os.path.join(OPTIONS.search_path, "framework", "signapk.jar"), + key + ".x509.pem", + key + ".pk8", + input_name, sign_name], + stdin=subprocess.PIPE, + stdout=subprocess.PIPE) if password is not None: password += "\n" p.communicate(password) @@ -192,7 +192,7 @@ def SignFile(input_name, output_name, key, password, align=None): raise ExternalError("signapk.jar failed: return code %s" % (p.returncode,)) if align: - p = subprocess.Popen(["zipalign", "-f", str(align), sign_name, output_name]) + p = Run(["zipalign", "-f", str(align), sign_name, output_name]) p.communicate() if p.returncode != 0: raise ExternalError("zipalign failed: return code %s" % (p.returncode,)) @@ -221,8 +221,8 @@ def CheckSize(data, target): COMMON_DOCSTRING = """ -p (--path) - Prepend to the list of places to search for binaries run - by this script. + Prepend /bin to the list of places to search for binaries + run by this script, and expect to find jars in /framework. -v (--verbose) Show command lines being executed. @@ -264,15 +264,13 @@ def ParseOptions(argv, elif o in ("-v", "--verbose"): OPTIONS.verbose = True elif o in ("-p", "--path"): - os.environ["PATH"] = a + os.pathsep + os.environ["PATH"] - path_specified = True + OPTIONS.search_path = a else: if extra_option_handler is None or not extra_option_handler(o, a): assert False, "unknown option \"%s\"" % (o,) - if not path_specified: - os.environ["PATH"] = ("out/host/linux-x86/bin" + os.pathsep + - os.environ["PATH"]) + os.environ["PATH"] = (os.path.join(OPTIONS.search_path, "bin") + + os.pathsep + os.environ["PATH"]) return args diff --git a/tools/releasetools/sign_target_files_apks b/tools/releasetools/sign_target_files_apks index bc04956258..6dd8ede43c 100755 --- a/tools/releasetools/sign_target_files_apks +++ b/tools/releasetools/sign_target_files_apks @@ -278,7 +278,9 @@ def ReplaceOtaKeys(input_tf_zip, output_tf_zip): # recovery uses a version of the key that has been slightly # predigested (by DumpPublicKey.java) and put in res/keys. - p = common.Run(["java", "-jar", OPTIONS.dumpkey_jar] + mapped_keys, + p = common.Run(["java", "-jar", + os.path.join(OPTIONS.search_path, "framework", "dumpkey.jar")] + + mapped_keys, stdout=subprocess.PIPE) data, _ = p.communicate() if p.returncode != 0: