Jae Shin | ca625dd | 2017-11-30 15:58:00 +0900 | [diff] [blame] | 1 | #!/usr/bin/env python |
| 2 | # |
| 3 | # Copyright (C) 2017 The Android Open Source Project |
| 4 | # |
| 5 | # Licensed under the Apache License, Version 2.0 (the "License"); |
| 6 | # you may not use this file except in compliance with the License. |
| 7 | # You may obtain a copy of the License at |
| 8 | # |
| 9 | # http://www.apache.org/licenses/LICENSE-2.0 |
| 10 | # |
| 11 | # Unless required by applicable law or agreed to in writing, software |
| 12 | # distributed under the License is distributed on an "AS IS" BASIS, |
| 13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 14 | # See the License for the specific language governing permissions and |
| 15 | # limitations under the License. |
| 16 | # |
| 17 | """Installs VNDK snapshot under prebuilts/vndk/v{version}.""" |
| 18 | |
| 19 | import argparse |
| 20 | import glob |
| 21 | import logging |
| 22 | import os |
Jae Shin | 6e1a796 | 2017-12-26 13:12:38 +0900 | [diff] [blame] | 23 | import re |
Jae Shin | ca625dd | 2017-11-30 15:58:00 +0900 | [diff] [blame] | 24 | import shutil |
| 25 | import subprocess |
| 26 | import sys |
| 27 | import tempfile |
| 28 | import textwrap |
| 29 | |
Jae Shin | 5233fe1 | 2017-12-18 22:29:48 +0900 | [diff] [blame] | 30 | import utils |
| 31 | |
| 32 | from check_gpl_license import GPLChecker |
Jae Shin | ca625dd | 2017-11-30 15:58:00 +0900 | [diff] [blame] | 33 | from gen_buildfiles import GenBuildFile |
| 34 | |
Jae Shin | 5233fe1 | 2017-12-18 22:29:48 +0900 | [diff] [blame] | 35 | ANDROID_BUILD_TOP = utils.get_android_build_top() |
Jae Shin | 5233fe1 | 2017-12-18 22:29:48 +0900 | [diff] [blame] | 36 | PREBUILTS_VNDK_DIR = utils.join_realpath(ANDROID_BUILD_TOP, 'prebuilts/vndk') |
Jae Shin | ca625dd | 2017-11-30 15:58:00 +0900 | [diff] [blame] | 37 | |
Jae Shin | ca625dd | 2017-11-30 15:58:00 +0900 | [diff] [blame] | 38 | |
Jae Shin | ca625dd | 2017-11-30 15:58:00 +0900 | [diff] [blame] | 39 | def start_branch(build): |
| 40 | branch_name = 'update-' + (build or 'local') |
Jae Shin | bd82ebb | 2018-06-21 14:13:46 +0900 | [diff] [blame] | 41 | logging.info('Creating branch {branch} in {dir}'.format( |
Jae Shin | ca625dd | 2017-11-30 15:58:00 +0900 | [diff] [blame] | 42 | branch=branch_name, dir=os.getcwd())) |
Jae Shin | bd82ebb | 2018-06-21 14:13:46 +0900 | [diff] [blame] | 43 | utils.check_call(['repo', 'start', branch_name, '.']) |
Jae Shin | ca625dd | 2017-11-30 15:58:00 +0900 | [diff] [blame] | 44 | |
| 45 | |
| 46 | def remove_old_snapshot(install_dir): |
Jae Shin | bd82ebb | 2018-06-21 14:13:46 +0900 | [diff] [blame] | 47 | logging.info('Removing any old files in {}'.format(install_dir)) |
Jae Shin | ca625dd | 2017-11-30 15:58:00 +0900 | [diff] [blame] | 48 | for file in glob.glob('{}/*'.format(install_dir)): |
| 49 | try: |
| 50 | if os.path.isfile(file): |
| 51 | os.unlink(file) |
| 52 | elif os.path.isdir(file): |
| 53 | shutil.rmtree(file) |
| 54 | except Exception as error: |
Jae Shin | bd82ebb | 2018-06-21 14:13:46 +0900 | [diff] [blame] | 55 | logging.error('Error: {}'.format(error)) |
Jae Shin | ca625dd | 2017-11-30 15:58:00 +0900 | [diff] [blame] | 56 | sys.exit(1) |
| 57 | |
| 58 | |
Jae Shin | 01268ff | 2018-06-18 15:29:09 +0900 | [diff] [blame] | 59 | def install_snapshot(branch, build, local_dir, install_dir, temp_artifact_dir): |
Jae Shin | ba7456d | 2017-12-15 20:03:20 +0900 | [diff] [blame] | 60 | """Installs VNDK snapshot build artifacts to prebuilts/vndk/v{version}. |
| 61 | |
Jae Shin | 01268ff | 2018-06-18 15:29:09 +0900 | [diff] [blame] | 62 | 1) Fetch build artifacts from Android Build server or from local_dir |
Jae Shin | ba7456d | 2017-12-15 20:03:20 +0900 | [diff] [blame] | 63 | 2) Unzip build artifacts |
| 64 | |
| 65 | Args: |
| 66 | branch: string or None, branch name of build artifacts |
| 67 | build: string or None, build number of build artifacts |
Jae Shin | 01268ff | 2018-06-18 15:29:09 +0900 | [diff] [blame] | 68 | local_dir: string or None, local dir to pull artifacts from |
Jae Shin | ba7456d | 2017-12-15 20:03:20 +0900 | [diff] [blame] | 69 | install_dir: string, directory to install VNDK snapshot |
Jae Shin | 25d3abf | 2018-04-18 18:00:26 +0900 | [diff] [blame] | 70 | temp_artifact_dir: string, temp directory to hold build artifacts fetched |
| 71 | from Android Build server. For 'local' option, is set to None. |
Jae Shin | ba7456d | 2017-12-15 20:03:20 +0900 | [diff] [blame] | 72 | """ |
Jae Shin | ca625dd | 2017-11-30 15:58:00 +0900 | [diff] [blame] | 73 | artifact_pattern = 'android-vndk-*.zip' |
| 74 | |
Jae Shin | 25d3abf | 2018-04-18 18:00:26 +0900 | [diff] [blame] | 75 | if branch and build: |
| 76 | artifact_dir = temp_artifact_dir |
| 77 | os.chdir(temp_artifact_dir) |
Jae Shin | bd82ebb | 2018-06-21 14:13:46 +0900 | [diff] [blame] | 78 | logging.info('Fetching {pattern} from {branch} (bid: {build})'.format( |
Jae Shin | 25d3abf | 2018-04-18 18:00:26 +0900 | [diff] [blame] | 79 | pattern=artifact_pattern, branch=branch, build=build)) |
| 80 | utils.fetch_artifact(branch, build, artifact_pattern) |
Jae Shin | ca625dd | 2017-11-30 15:58:00 +0900 | [diff] [blame] | 81 | |
Jae Shin | 25d3abf | 2018-04-18 18:00:26 +0900 | [diff] [blame] | 82 | manifest_pattern = 'manifest_{}.xml'.format(build) |
Jae Shin | bd82ebb | 2018-06-21 14:13:46 +0900 | [diff] [blame] | 83 | logging.info('Fetching {file} from {branch} (bid: {build})'.format( |
Jae Shin | 25d3abf | 2018-04-18 18:00:26 +0900 | [diff] [blame] | 84 | file=manifest_pattern, branch=branch, build=build)) |
| 85 | utils.fetch_artifact(branch, build, manifest_pattern, |
| 86 | utils.MANIFEST_FILE_NAME) |
Jae Shin | ca625dd | 2017-11-30 15:58:00 +0900 | [diff] [blame] | 87 | |
Jae Shin | 25d3abf | 2018-04-18 18:00:26 +0900 | [diff] [blame] | 88 | os.chdir(install_dir) |
Jae Shin | 01268ff | 2018-06-18 15:29:09 +0900 | [diff] [blame] | 89 | elif local_dir: |
Jae Shin | bd82ebb | 2018-06-21 14:13:46 +0900 | [diff] [blame] | 90 | logging.info('Fetching local VNDK snapshot from {}'.format(local_dir)) |
Jae Shin | 01268ff | 2018-06-18 15:29:09 +0900 | [diff] [blame] | 91 | artifact_dir = local_dir |
Jae Shin | ca625dd | 2017-11-30 15:58:00 +0900 | [diff] [blame] | 92 | |
Jae Shin | 25d3abf | 2018-04-18 18:00:26 +0900 | [diff] [blame] | 93 | artifacts = glob.glob(os.path.join(artifact_dir, artifact_pattern)) |
Jae Shin | 25d3abf | 2018-04-18 18:00:26 +0900 | [diff] [blame] | 94 | for artifact in artifacts: |
Jae Shin | bd82ebb | 2018-06-21 14:13:46 +0900 | [diff] [blame] | 95 | logging.info('Unzipping VNDK snapshot: {}'.format(artifact)) |
| 96 | utils.check_call(['unzip', '-qn', artifact, '-d', install_dir]) |
Jae Shin | ca625dd | 2017-11-30 15:58:00 +0900 | [diff] [blame] | 97 | |
| 98 | |
Jae Shin | 4db81a5 | 2017-12-29 13:24:54 +0900 | [diff] [blame] | 99 | def gather_notice_files(install_dir): |
| 100 | """Gathers all NOTICE files to a common NOTICE_FILES directory.""" |
Jae Shin | ba7456d | 2017-12-15 20:03:20 +0900 | [diff] [blame] | 101 | |
Jae Shin | 4db81a5 | 2017-12-29 13:24:54 +0900 | [diff] [blame] | 102 | common_notices_dir = utils.NOTICE_FILES_DIR_PATH |
Jae Shin | bd82ebb | 2018-06-21 14:13:46 +0900 | [diff] [blame] | 103 | logging.info('Creating {} directory to gather all NOTICE files...'.format( |
Jae Shin | 9407521 | 2018-06-14 14:54:34 +0900 | [diff] [blame] | 104 | common_notices_dir)) |
Jae Shin | 4db81a5 | 2017-12-29 13:24:54 +0900 | [diff] [blame] | 105 | os.makedirs(common_notices_dir) |
Jae Shin | af0c003 | 2018-06-21 11:54:05 +0900 | [diff] [blame] | 106 | for arch in utils.get_snapshot_archs(install_dir): |
| 107 | notices_dir_per_arch = os.path.join(arch, utils.NOTICE_FILES_DIR_NAME) |
| 108 | if os.path.isdir(notices_dir_per_arch): |
Jae Shin | ba7456d | 2017-12-15 20:03:20 +0900 | [diff] [blame] | 109 | for notice_file in glob.glob( |
Jae Shin | af0c003 | 2018-06-21 11:54:05 +0900 | [diff] [blame] | 110 | '{}/*.txt'.format(notices_dir_per_arch)): |
Jae Shin | 5233fe1 | 2017-12-18 22:29:48 +0900 | [diff] [blame] | 111 | if not os.path.isfile( |
Jae Shin | 4db81a5 | 2017-12-29 13:24:54 +0900 | [diff] [blame] | 112 | os.path.join(common_notices_dir, |
Jae Shin | 5233fe1 | 2017-12-18 22:29:48 +0900 | [diff] [blame] | 113 | os.path.basename(notice_file))): |
Jae Shin | 4db81a5 | 2017-12-29 13:24:54 +0900 | [diff] [blame] | 114 | shutil.copy(notice_file, common_notices_dir) |
Jae Shin | af0c003 | 2018-06-21 11:54:05 +0900 | [diff] [blame] | 115 | shutil.rmtree(notices_dir_per_arch) |
Jae Shin | ba7456d | 2017-12-15 20:03:20 +0900 | [diff] [blame] | 116 | |
| 117 | |
Justin Yun | b59da8f | 2019-01-23 19:25:05 +0900 | [diff] [blame] | 118 | def post_processe_files_if_needed(vndk_version): |
Jae Shin | 89e386f | 2018-01-16 20:28:33 +0900 | [diff] [blame] | 119 | """For O-MR1, replaces unversioned VNDK directories with versioned ones. |
Justin Yun | b59da8f | 2019-01-23 19:25:05 +0900 | [diff] [blame] | 120 | Also, renames ld.config.txt, llndk.libraries.txt and vndksp.libraries.txt |
| 121 | files to have version suffix. |
Jae Shin | 6e1a796 | 2017-12-26 13:12:38 +0900 | [diff] [blame] | 122 | |
| 123 | Unversioned VNDK directories: /system/${LIB}/vndk[-sp] |
Jae Shin | 89e386f | 2018-01-16 20:28:33 +0900 | [diff] [blame] | 124 | Versioned VNDK directories: /system/${LIB}/vndk[-sp]-27 |
| 125 | |
| 126 | Args: |
Jae Shin | af0c003 | 2018-06-21 11:54:05 +0900 | [diff] [blame] | 127 | vndk_version: int, version of VNDK snapshot |
Jae Shin | 6e1a796 | 2017-12-26 13:12:38 +0900 | [diff] [blame] | 128 | """ |
Justin Yun | b59da8f | 2019-01-23 19:25:05 +0900 | [diff] [blame] | 129 | def add_version_suffix(file_name): |
| 130 | logging.info('Rename {} to have version suffix'.format(vndk_version)) |
| 131 | target_files = glob.glob( |
| 132 | os.path.join(utils.CONFIG_DIR_PATH_PATTERN, file_name)) |
| 133 | for target_file in target_files: |
| 134 | name, ext = os.path.splitext(target_file) |
| 135 | os.rename(target_file, name + '.' + str(vndk_version) + ext) |
Jae Shin | af0c003 | 2018-06-21 11:54:05 +0900 | [diff] [blame] | 136 | if vndk_version == 27: |
| 137 | logging.info('Revising ld.config.txt for O-MR1...') |
Jae Shin | 89e386f | 2018-01-16 20:28:33 +0900 | [diff] [blame] | 138 | re_pattern = '(system\/\${LIB}\/vndk(?:-sp)?)([:/]|$)' |
| 139 | VNDK_INSTALL_DIR_RE = re.compile(re_pattern, flags=re.MULTILINE) |
| 140 | ld_config_txt_paths = glob.glob( |
| 141 | os.path.join(utils.CONFIG_DIR_PATH_PATTERN, 'ld.config*')) |
| 142 | for ld_config_file in ld_config_txt_paths: |
| 143 | with open(ld_config_file, 'r') as file: |
| 144 | revised = VNDK_INSTALL_DIR_RE.sub(r'\1-27\2', file.read()) |
| 145 | with open(ld_config_file, 'w') as file: |
| 146 | file.write(revised) |
Jae Shin | 6e1a796 | 2017-12-26 13:12:38 +0900 | [diff] [blame] | 147 | |
Justin Yun | b59da8f | 2019-01-23 19:25:05 +0900 | [diff] [blame] | 148 | files_to_add_version_suffix = ('ld.config.txt', |
| 149 | 'llndk.libraries.txt', |
| 150 | 'vndksp.libraries.txt') |
| 151 | for file_to_rename in files_to_add_version_suffix: |
| 152 | add_version_suffix(file_to_rename) |
| 153 | |
Kiyoung Kim | b04fe60 | 2019-10-07 13:42:57 +0900 | [diff] [blame] | 154 | files_to_enforce_version_suffix = ('vndkcore.libraries.txt', |
| 155 | 'vndkprivate.libraries.txt') |
| 156 | for file_to_rename in files_to_enforce_version_suffix: |
| 157 | add_version_suffix(file_to_rename) |
| 158 | |
Jae Shin | 6e1a796 | 2017-12-26 13:12:38 +0900 | [diff] [blame] | 159 | |
Jae Shin | ca625dd | 2017-11-30 15:58:00 +0900 | [diff] [blame] | 160 | def update_buildfiles(buildfile_generator): |
Jaewoong Jung | 6a5aaca | 2019-01-17 15:41:06 -0800 | [diff] [blame] | 161 | logging.info('Generating root Android.bp file...') |
| 162 | buildfile_generator.generate_root_android_bp() |
Jae Shin | ca625dd | 2017-11-30 15:58:00 +0900 | [diff] [blame] | 163 | |
Jaewoong Jung | 6fbb9d2 | 2018-11-28 09:25:22 -0800 | [diff] [blame] | 164 | logging.info('Generating common/Android.bp file...') |
| 165 | buildfile_generator.generate_common_android_bp() |
| 166 | |
Jae Shin | bd82ebb | 2018-06-21 14:13:46 +0900 | [diff] [blame] | 167 | logging.info('Generating Android.bp files...') |
Jae Shin | ca625dd | 2017-11-30 15:58:00 +0900 | [diff] [blame] | 168 | buildfile_generator.generate_android_bp() |
| 169 | |
| 170 | |
Jae Shin | 5233fe1 | 2017-12-18 22:29:48 +0900 | [diff] [blame] | 171 | def check_gpl_license(license_checker): |
| 172 | try: |
| 173 | license_checker.check_gpl_projects() |
| 174 | except ValueError as error: |
Jae Shin | bd82ebb | 2018-06-21 14:13:46 +0900 | [diff] [blame] | 175 | logging.error('***CANNOT INSTALL VNDK SNAPSHOT***: {}'.format(error)) |
Jae Shin | 5233fe1 | 2017-12-18 22:29:48 +0900 | [diff] [blame] | 176 | raise |
| 177 | |
| 178 | |
Jae Shin | ca625dd | 2017-11-30 15:58:00 +0900 | [diff] [blame] | 179 | def commit(branch, build, version): |
Jae Shin | bd82ebb | 2018-06-21 14:13:46 +0900 | [diff] [blame] | 180 | logging.info('Making commit...') |
| 181 | utils.check_call(['git', 'add', '.']) |
Jae Shin | ca625dd | 2017-11-30 15:58:00 +0900 | [diff] [blame] | 182 | message = textwrap.dedent("""\ |
| 183 | Update VNDK snapshot v{version} to build {build}. |
| 184 | |
| 185 | Taken from branch {branch}.""").format( |
| 186 | version=version, branch=branch, build=build) |
Jae Shin | bd82ebb | 2018-06-21 14:13:46 +0900 | [diff] [blame] | 187 | utils.check_call(['git', 'commit', '-m', message]) |
Jae Shin | ca625dd | 2017-11-30 15:58:00 +0900 | [diff] [blame] | 188 | |
| 189 | |
| 190 | def get_args(): |
| 191 | parser = argparse.ArgumentParser() |
| 192 | parser.add_argument( |
Jae Shin | 9407521 | 2018-06-14 14:54:34 +0900 | [diff] [blame] | 193 | 'vndk_version', |
| 194 | type=int, |
Jae Shin | ca625dd | 2017-11-30 15:58:00 +0900 | [diff] [blame] | 195 | help='VNDK snapshot version to install, e.g. "27".') |
| 196 | parser.add_argument('-b', '--branch', help='Branch to pull build from.') |
| 197 | parser.add_argument('--build', help='Build number to pull.') |
| 198 | parser.add_argument( |
Jae Shin | 9407521 | 2018-06-14 14:54:34 +0900 | [diff] [blame] | 199 | '--local', |
Jae Shin | 01268ff | 2018-06-18 15:29:09 +0900 | [diff] [blame] | 200 | help=('Fetch local VNDK snapshot artifacts from specified local ' |
| 201 | 'directory instead of Android Build server. ' |
| 202 | 'Example: --local=/path/to/local/dir')) |
Jae Shin | ca625dd | 2017-11-30 15:58:00 +0900 | [diff] [blame] | 203 | parser.add_argument( |
Jae Shin | 9407521 | 2018-06-14 14:54:34 +0900 | [diff] [blame] | 204 | '--use-current-branch', |
| 205 | action='store_true', |
Jae Shin | ca625dd | 2017-11-30 15:58:00 +0900 | [diff] [blame] | 206 | help='Perform the update in the current branch. Do not repo start.') |
| 207 | parser.add_argument( |
Justin Yun | 5ff8cc2 | 2019-01-18 15:25:42 +0900 | [diff] [blame] | 208 | '--remote', |
| 209 | default='aosp', |
| 210 | help=('Remote name to fetch and check if the revision of VNDK snapshot ' |
| 211 | 'is included in the source to conform GPL license. default=aosp')) |
| 212 | parser.add_argument( |
Jae Shin | 9407521 | 2018-06-14 14:54:34 +0900 | [diff] [blame] | 213 | '-v', |
| 214 | '--verbose', |
| 215 | action='count', |
| 216 | default=0, |
Jae Shin | ca625dd | 2017-11-30 15:58:00 +0900 | [diff] [blame] | 217 | help='Increase output verbosity, e.g. "-v", "-vv".') |
| 218 | return parser.parse_args() |
| 219 | |
| 220 | |
| 221 | def main(): |
| 222 | """Program entry point.""" |
| 223 | args = get_args() |
| 224 | |
Jae Shin | bd82ebb | 2018-06-21 14:13:46 +0900 | [diff] [blame] | 225 | local = None |
Jae Shin | ca625dd | 2017-11-30 15:58:00 +0900 | [diff] [blame] | 226 | if args.local: |
Jae Shin | bd82ebb | 2018-06-21 14:13:46 +0900 | [diff] [blame] | 227 | local = os.path.expanduser(args.local) |
| 228 | |
| 229 | if local: |
Jae Shin | ca625dd | 2017-11-30 15:58:00 +0900 | [diff] [blame] | 230 | if args.build or args.branch: |
| 231 | raise ValueError( |
| 232 | 'When --local option is set, --branch or --build cannot be ' |
| 233 | 'specified.') |
Jae Shin | bd82ebb | 2018-06-21 14:13:46 +0900 | [diff] [blame] | 234 | elif not os.path.isdir(local): |
Jae Shin | ca625dd | 2017-11-30 15:58:00 +0900 | [diff] [blame] | 235 | raise RuntimeError( |
Jae Shin | 01268ff | 2018-06-18 15:29:09 +0900 | [diff] [blame] | 236 | 'The specified local directory, {}, does not exist.'.format( |
Jae Shin | bd82ebb | 2018-06-21 14:13:46 +0900 | [diff] [blame] | 237 | local)) |
Jae Shin | ca625dd | 2017-11-30 15:58:00 +0900 | [diff] [blame] | 238 | else: |
| 239 | if not (args.build and args.branch): |
| 240 | raise ValueError( |
| 241 | 'Please provide both --branch and --build or set --local ' |
| 242 | 'option.') |
| 243 | |
Jae Shin | af0c003 | 2018-06-21 11:54:05 +0900 | [diff] [blame] | 244 | vndk_version = args.vndk_version |
Jae Shin | ca625dd | 2017-11-30 15:58:00 +0900 | [diff] [blame] | 245 | |
| 246 | install_dir = os.path.join(PREBUILTS_VNDK_DIR, 'v{}'.format(vndk_version)) |
| 247 | if not os.path.isdir(install_dir): |
| 248 | raise RuntimeError( |
| 249 | 'The directory for VNDK snapshot version {ver} does not exist.\n' |
| 250 | 'Please request a new git project for prebuilts/vndk/v{ver} ' |
| 251 | 'before installing new snapshot.'.format(ver=vndk_version)) |
| 252 | |
Jae Shin | 9407521 | 2018-06-14 14:54:34 +0900 | [diff] [blame] | 253 | utils.set_logging_config(args.verbose) |
Jae Shin | ca625dd | 2017-11-30 15:58:00 +0900 | [diff] [blame] | 254 | |
| 255 | os.chdir(install_dir) |
| 256 | |
| 257 | if not args.use_current_branch: |
| 258 | start_branch(args.build) |
| 259 | |
| 260 | remove_old_snapshot(install_dir) |
Jae Shin | 4db81a5 | 2017-12-29 13:24:54 +0900 | [diff] [blame] | 261 | os.makedirs(utils.COMMON_DIR_PATH) |
Jae Shin | 6e1a796 | 2017-12-26 13:12:38 +0900 | [diff] [blame] | 262 | |
Jae Shin | 25d3abf | 2018-04-18 18:00:26 +0900 | [diff] [blame] | 263 | temp_artifact_dir = None |
Jae Shin | bd82ebb | 2018-06-21 14:13:46 +0900 | [diff] [blame] | 264 | if not local: |
Jae Shin | 25d3abf | 2018-04-18 18:00:26 +0900 | [diff] [blame] | 265 | temp_artifact_dir = tempfile.mkdtemp() |
| 266 | |
Jae Shin | 25d3abf | 2018-04-18 18:00:26 +0900 | [diff] [blame] | 267 | try: |
Jae Shin | bd82ebb | 2018-06-21 14:13:46 +0900 | [diff] [blame] | 268 | install_snapshot(args.branch, args.build, local, install_dir, |
Jae Shin | 25d3abf | 2018-04-18 18:00:26 +0900 | [diff] [blame] | 269 | temp_artifact_dir) |
| 270 | gather_notice_files(install_dir) |
Justin Yun | b59da8f | 2019-01-23 19:25:05 +0900 | [diff] [blame] | 271 | post_processe_files_if_needed(vndk_version) |
Jae Shin | 25d3abf | 2018-04-18 18:00:26 +0900 | [diff] [blame] | 272 | |
| 273 | buildfile_generator = GenBuildFile(install_dir, vndk_version) |
| 274 | update_buildfiles(buildfile_generator) |
| 275 | |
Jae Shin | bd82ebb | 2018-06-21 14:13:46 +0900 | [diff] [blame] | 276 | if not local: |
Jae Shin | 25d3abf | 2018-04-18 18:00:26 +0900 | [diff] [blame] | 277 | license_checker = GPLChecker(install_dir, ANDROID_BUILD_TOP, |
Justin Yun | 5ff8cc2 | 2019-01-18 15:25:42 +0900 | [diff] [blame] | 278 | temp_artifact_dir, args.remote) |
Jae Shin | 25d3abf | 2018-04-18 18:00:26 +0900 | [diff] [blame] | 279 | check_gpl_license(license_checker) |
Jae Shin | bd82ebb | 2018-06-21 14:13:46 +0900 | [diff] [blame] | 280 | logging.info( |
Jae Shin | 9407521 | 2018-06-14 14:54:34 +0900 | [diff] [blame] | 281 | 'Successfully updated VNDK snapshot v{}'.format(vndk_version)) |
| 282 | except Exception as error: |
Jae Shin | bd82ebb | 2018-06-21 14:13:46 +0900 | [diff] [blame] | 283 | logging.error('FAILED TO INSTALL SNAPSHOT: {}'.format(error)) |
Jae Shin | 9407521 | 2018-06-14 14:54:34 +0900 | [diff] [blame] | 284 | raise |
Jae Shin | 25d3abf | 2018-04-18 18:00:26 +0900 | [diff] [blame] | 285 | finally: |
| 286 | if temp_artifact_dir: |
Jae Shin | bd82ebb | 2018-06-21 14:13:46 +0900 | [diff] [blame] | 287 | logging.info( |
Jae Shin | 25d3abf | 2018-04-18 18:00:26 +0900 | [diff] [blame] | 288 | 'Deleting temp_artifact_dir: {}'.format(temp_artifact_dir)) |
| 289 | shutil.rmtree(temp_artifact_dir) |
| 290 | |
Jae Shin | bd82ebb | 2018-06-21 14:13:46 +0900 | [diff] [blame] | 291 | if not local: |
Jae Shin | ca625dd | 2017-11-30 15:58:00 +0900 | [diff] [blame] | 292 | commit(args.branch, args.build, vndk_version) |
Jae Shin | bd82ebb | 2018-06-21 14:13:46 +0900 | [diff] [blame] | 293 | logging.info( |
| 294 | 'Successfully created commit for VNDK snapshot v{}'.format( |
| 295 | vndk_version)) |
Jae Shin | 9407521 | 2018-06-14 14:54:34 +0900 | [diff] [blame] | 296 | |
Jae Shin | bd82ebb | 2018-06-21 14:13:46 +0900 | [diff] [blame] | 297 | logging.info('Done.') |
Jae Shin | ca625dd | 2017-11-30 15:58:00 +0900 | [diff] [blame] | 298 | |
| 299 | |
| 300 | if __name__ == '__main__': |
| 301 | main() |