diff options
author | Anton Hansson <hansson@google.com> | 2020-03-31 09:52:24 +0100 |
---|---|---|
committer | Anton Hansson <hansson@google.com> | 2020-03-31 09:52:24 +0100 |
commit | 7268a76872e14a55729d80a9587817fbf77415af (patch) | |
tree | 35ef4700cb370366e31ed3c442f705516a0e7b25 /update_prebuilts | |
parent | 068d145c4e940e0de15b32c7ba2e99d2e03be542 (diff) | |
download | platform_prebuilts_sdk-7268a76872e14a55729d80a9587817fbf77415af.tar.gz platform_prebuilts_sdk-7268a76872e14a55729d80a9587817fbf77415af.tar.bz2 platform_prebuilts_sdk-7268a76872e14a55729d80a9587817fbf77415af.zip |
Make update_prebilts.py fail gracefully on bad sdk zip
Print some useful errors if there are unexpectededly missing,
or double entries in the fetched zip file.
New output when the sdk zip is missing an entry:
Running: /google/data/ro/projects/android/fetch_artifact --bid [..]
Expected 1 file named 'android.jar' in zip sdk-repo-linux-platforms-6302112.zip, found 0
Failed to update platform SDK, aborting
Bug: 151953032
Test: ./update_prebuilts.py -p 6302112
Test: ./update_prebuilts.py -p 6330106
Change-Id: I91d6c3d6a64cfbb993295cc07ab48c9aef5d71e0
Merged-In: I91d6c3d6a64cfbb993295cc07ab48c9aef5d71e0
Diffstat (limited to 'update_prebuilts')
-rwxr-xr-x | update_prebuilts/update_prebuilts.py | 16 |
1 files changed, 9 insertions, 7 deletions
diff --git a/update_prebuilts/update_prebuilts.py b/update_prebuilts/update_prebuilts.py index cce652ccb..cde5c27d6 100755 --- a/update_prebuilts/update_prebuilts.py +++ b/update_prebuilts/update_prebuilts.py @@ -645,12 +645,6 @@ def update_material(file): os.path.join(extras_dir, 'material-design-x'), extract_res=False) -def extract_to(zip_file, filename, parent_path): - zip_path = next(filter(lambda path: filename in path, zip_file.namelist())) - src_path = zip_file.extract(zip_path) - dst_path = path(parent_path, filename) - mv(src_path, dst_path) - def update_framework(build_id, sdk_dir): api_scope_list = ['public', 'system', 'test'] if sdk_dir == 'current': @@ -675,7 +669,15 @@ def update_framework(build_id, sdk_dir): with zipfile.ZipFile(artifact_path) as zipFile: for filename in ['android.jar', 'framework.aidl', 'uiautomator.jar']: - extract_to(zipFile, filename, target_dir) + matches = list(filter(lambda path: filename in path, zipFile.namelist())) + if len(matches) != 1: + print_e('Expected 1 file named \'%s\' in zip %s, found %d' % + (filename, zipFile.filename, len(matches))) + return False + zip_path = matches[0] + src_path = zipFile.extract(zip_path) + dst_path = path(target_dir, filename) + mv(src_path, dst_path) return True |