diff options
author | Dan Albert <danalbert@google.com> | 2021-03-19 20:36:22 +0000 |
---|---|---|
committer | Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com> | 2021-03-19 20:36:22 +0000 |
commit | 9f000102f60eb39c355bcabd610f760ed92672d2 (patch) | |
tree | 0d23707885f7400945ee127fc1b42a93b848f033 | |
parent | 147cf8997fbaa4d9c270f9b4aa232377616bf77d (diff) | |
parent | 184ebb706bc3c940397665e022ba3517beadfe90 (diff) | |
download | ndk-9f000102f60eb39c355bcabd610f760ed92672d2.tar.gz |
Merge "Update the updater to account for package updates." am: 184ebb706b
Original change: https://android-review.googlesource.com/c/platform/prebuilts/ndk/+/1645877
Change-Id: I56389d881ec5b12affca1ff7a2b29ae8118d437e
-rwxr-xr-x | update.py | 43 |
1 files changed, 29 insertions, 14 deletions
@@ -20,6 +20,7 @@ import logging import os import shutil import subprocess +from tempfile import TemporaryDirectory import textwrap @@ -68,35 +69,50 @@ def remove_old_release(install_dir): shutil.rmtree(install_dir) +def unzip_single_directory(artifact, destination): + # Use cwd so that we can use rename without having to worry about crossing + # file systems. + with TemporaryDirectory(dir=os.getcwd()) as temp_dir: + cmd = [ + 'unzip', + artifact, + '-d', + temp_dir, + '*/sources/android/cpufeatures/*', + '*/sources/android/native_app_glue/*', + '*/sources/android/support/*', + '*/sources/cxx-stl/*', + '*/source.properties', + ] + check_call(cmd) + + dirs = os.listdir(temp_dir) + assert len(dirs) == 1 + ndk_dir = os.path.join(temp_dir, dirs[0]) + for child in os.listdir(ndk_dir): + os.rename(os.path.join(ndk_dir, child), + os.path.join(destination, child)) + + def install_new_release(branch, build, install_dir): os.makedirs(install_dir) - artifact_pattern = 'android-ndk-*.tar.bz2' + artifact_pattern = 'android-ndk-*.zip' logger().info('Fetching %s from %s (artifacts matching %s)', build, branch, artifact_pattern) fetch_artifact(branch, build, artifact_pattern) - artifacts = glob.glob('android-ndk-*.tar.bz2') + artifacts = glob.glob('android-ndk-*.zip') try: assert len(artifacts) == 1 artifact = artifacts[0] logger().info('Extracting release') - cmd = ['tar', 'xf', artifact, '-C', install_dir, '--wildcards', - '--strip-components=1', '*/platforms', '*/sources', - '*/source.properties'] - check_call(cmd) + unzip_single_directory(artifact, install_dir) finally: for artifact in artifacts: os.unlink(artifact) -def remove_unneeded_files(install_dir): - shutil.rmtree(os.path.join(install_dir, 'platforms')) - shutil.rmtree(os.path.join(install_dir, 'sources/third_party')) - shutil.rmtree(os.path.join(install_dir, 'sources/android/renderscript')) - shutil.rmtree(os.path.join(install_dir, 'sources/android/ndk_helper')) - - def commit(branch, build, install_dir): logger().info('Making commit') check_call(['git', 'add', install_dir]) @@ -144,7 +160,6 @@ def main(): start_branch(args.build) remove_old_release(install_dir) install_new_release(args.branch, args.build, install_dir) - remove_unneeded_files(install_dir) commit(args.branch, args.build, install_dir) |