diff options
author | Dan Albert <danalbert@google.com> | 2021-03-18 16:49:39 -0700 |
---|---|---|
committer | Dan Albert <danalbert@google.com> | 2021-03-18 17:14:26 -0700 |
commit | 2e1bb712c61ec86708d137f5b82ae81c49cf4bee (patch) | |
tree | 0d23707885f7400945ee127fc1b42a93b848f033 | |
parent | 2bf3d4fd51423420945cee3ced95ec6096800256 (diff) | |
download | ndk-2e1bb712c61ec86708d137f5b82ae81c49cf4bee.tar.gz |
Update the updater to account for package updates.
Test: ./update.py --branch master-ndk --build 7219278 r23
Bug: None
Change-Id: Ieb6b00dd80e196c94c709f329d34b946964d0b86
-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) |