def install_snapshot(branch, build, install_dir, temp_artifact_dir): """Installs VNDK snapshot build artifacts to prebuilts/vndk/v{version}. 1) Fetch build artifacts from Android Build server or from local DIST_DIR 2) Unzip build artifacts Args: branch: string or None, branch name of build artifacts build: string or None, build number of build artifacts install_dir: string, directory to install VNDK snapshot temp_artifact_dir: string, temp directory to hold build artifacts fetched from Android Build server. For 'local' option, is set to None. """ artifact_pattern = 'android-vndk-*.zip' if branch and build: artifact_dir = temp_artifact_dir os.chdir(temp_artifact_dir) logger().info('Fetching {pattern} from {branch} (bid: {build})'.format( pattern=artifact_pattern, branch=branch, build=build)) utils.fetch_artifact(branch, build, artifact_pattern) manifest_pattern = 'manifest_{}.xml'.format(build) logger().info('Fetching {file} from {branch} (bid: {build})'.format( file=manifest_pattern, branch=branch, build=build)) utils.fetch_artifact(branch, build, manifest_pattern, utils.MANIFEST_FILE_NAME) os.chdir(install_dir) else: logger().info('Fetching local VNDK snapshot from {}'.format(DIST_DIR)) artifact_dir = DIST_DIR artifacts = glob.glob(os.path.join(artifact_dir, artifact_pattern)) artifact_cnt = len(artifacts) if artifact_cnt < 4: raise RuntimeError( 'Expected four android-vndk-*.zip files in {path}. Instead ' 'found {cnt}.'.format(path=artifact_dir, cnt=artifact_cnt)) for artifact in artifacts: logger().info('Unzipping VNDK snapshot: {}'.format(artifact)) check_call(['unzip', '-q', artifact, '-d', install_dir])
def main(): """For local testing purposes. Note: VNDK snapshot must be already installed under prebuilts/vndk/v{version}. """ ANDROID_BUILD_TOP = utils.get_android_build_top() PREBUILTS_VNDK_DIR = utils.join_realpath(ANDROID_BUILD_TOP, 'prebuilts/vndk') args = get_args() vndk_version = args.vndk_version install_dir = os.path.join(PREBUILTS_VNDK_DIR, 'v{}'.format(vndk_version)) remote = args.remote if not os.path.isdir(install_dir): raise ValueError( 'Please provide valid VNDK version. {} does not exist.' .format(install_dir)) utils.set_logging_config(args.verbose) temp_artifact_dir = tempfile.mkdtemp() os.chdir(temp_artifact_dir) manifest_pattern = 'manifest_{}.xml'.format(args.build) manifest_dest = os.path.join(temp_artifact_dir, utils.MANIFEST_FILE_NAME) logging.info('Fetching {file} from {branch} (bid: {build})'.format( file=manifest_pattern, branch=args.branch, build=args.build)) utils.fetch_artifact(args.branch, args.build, manifest_pattern, manifest_dest) license_checker = GPLChecker(install_dir, ANDROID_BUILD_TOP, temp_artifact_dir, remote) try: license_checker.check_gpl_projects() except ValueError as error: logging.error('Error: {}'.format(error)) raise finally: logging.info( 'Deleting temp_artifact_dir: {}'.format(temp_artifact_dir)) shutil.rmtree(temp_artifact_dir) logging.info('Done.')
def install_snapshot(branch, build, local_dir, install_dir, temp_artifact_dir): """Installs VNDK snapshot build artifacts to prebuilts/vndk/v{version}. 1) Fetch build artifacts from Android Build server or from local_dir 2) Unzip build artifacts Args: branch: string or None, branch name of build artifacts build: string or None, build number of build artifacts local_dir: string or None, local dir to pull artifacts from install_dir: string, directory to install VNDK snapshot temp_artifact_dir: string, temp directory to hold build artifacts fetched from Android Build server. For 'local' option, is set to None. """ artifact_pattern = 'android-vndk-*.zip' if branch and build: artifact_dir = temp_artifact_dir os.chdir(temp_artifact_dir) logger.info('Fetching {pattern} from {branch} (bid: {build})'.format( pattern=artifact_pattern, branch=branch, build=build)) utils.fetch_artifact(branch, build, artifact_pattern) manifest_pattern = 'manifest_{}.xml'.format(build) logger.info('Fetching {file} from {branch} (bid: {build})'.format( file=manifest_pattern, branch=branch, build=build)) utils.fetch_artifact(branch, build, manifest_pattern, utils.MANIFEST_FILE_NAME) os.chdir(install_dir) elif local_dir: logger.info('Fetching local VNDK snapshot from {}'.format(local_dir)) artifact_dir = local_dir artifacts = glob.glob(os.path.join(artifact_dir, artifact_pattern)) for artifact in artifacts: logger.info('Unzipping VNDK snapshot: {}'.format(artifact)) utils.check_call(['unzip', '-qn', artifact, '-d', install_dir], logger)
def install_snapshot(branch, build, local_dir, install_dir, temp_artifact_dir): """Installs VNDK snapshot build artifacts to prebuilts/vndk/v{version}. 1) Fetch build artifacts from Android Build server or from local_dir 2) Unzip build artifacts Args: branch: string or None, branch name of build artifacts build: string or None, build number of build artifacts local_dir: string or None, local dir to pull artifacts from install_dir: string, directory to install VNDK snapshot temp_artifact_dir: string, temp directory to hold build artifacts fetched from Android Build server. For 'local' option, is set to None. """ artifact_pattern = 'android-vndk-*.zip' if branch and build: artifact_dir = temp_artifact_dir os.chdir(temp_artifact_dir) logging.info('Fetching {pattern} from {branch} (bid: {build})'.format( pattern=artifact_pattern, branch=branch, build=build)) utils.fetch_artifact(branch, build, artifact_pattern) manifest_pattern = 'manifest_{}.xml'.format(build) logging.info('Fetching {file} from {branch} (bid: {build})'.format( file=manifest_pattern, branch=branch, build=build)) utils.fetch_artifact(branch, build, manifest_pattern, utils.MANIFEST_FILE_NAME) os.chdir(install_dir) elif local_dir: logging.info('Fetching local VNDK snapshot from {}'.format(local_dir)) artifact_dir = local_dir artifacts = glob.glob(os.path.join(artifact_dir, artifact_pattern)) for artifact in artifacts: logging.info('Unzipping VNDK snapshot: {}'.format(artifact)) utils.check_call(['unzip', '-qn', artifact, '-d', install_dir])