From d2ae0b061329d50a6004847fd5a5fcce11bbd4e2 Mon Sep 17 00:00:00 2001 From: Tao Bao Date: Tue, 21 Nov 2017 11:20:55 -0800 Subject: [PATCH] check_ota_package_signature.py: Set up PYTHONPATH. ... to include system/update_engine/scripts if ANDROID_BUILD_TOP is set (e.g. after lunching a target). Test: ./build/make/tools/releasetools/check_ota_package_signature.py works without manually setting PYTHONPATH. Change-Id: I0c5101fab2dd69cb6a598b909aa04bc4d5f45284 --- tools/releasetools/check_ota_package_signature.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/tools/releasetools/check_ota_package_signature.py b/tools/releasetools/check_ota_package_signature.py index 1f8b7bb41..8106d0610 100755 --- a/tools/releasetools/check_ota_package_signature.py +++ b/tools/releasetools/check_ota_package_signature.py @@ -22,7 +22,10 @@ from __future__ import print_function import argparse import common +import os +import os.path import re +import site import subprocess import sys import tempfile @@ -32,7 +35,12 @@ from hashlib import sha1 from hashlib import sha256 # 'update_payload' package is under 'system/update_engine/scripts/', which -# should to be included in PYTHONPATH. +# should be included in PYTHONPATH. Try to set it up automatically if +# if ANDROID_BUILD_TOP is available. +top = os.getenv('ANDROID_BUILD_TOP') +if top: + site.addsitedir(os.path.join(top, 'system', 'update_engine', 'scripts')) + from update_payload.payload import Payload from update_payload.update_metadata_pb2 import Signatures