Merge "vndk-snapshot: Make the remote name settable"

This commit is contained in:
Treehugger Robot
2019-01-22 05:15:07 +00:00
committed by Gerrit Code Review
2 changed files with 26 additions and 6 deletions

View File

@@ -36,16 +36,23 @@ class GPLChecker(object):
MANIFEST_XML = utils.MANIFEST_FILE_NAME MANIFEST_XML = utils.MANIFEST_FILE_NAME
MODULE_PATHS_TXT = utils.MODULE_PATHS_FILE_NAME MODULE_PATHS_TXT = utils.MODULE_PATHS_FILE_NAME
def __init__(self, install_dir, android_build_top, temp_artifact_dir): def __init__(self, install_dir, android_build_top, temp_artifact_dir,
remote_git):
"""GPLChecker constructor. """GPLChecker constructor.
Args: Args:
install_dir: string, absolute path to the prebuilts/vndk/v{version} install_dir: string, absolute path to the prebuilts/vndk/v{version}
directory where the build files will be generated. directory where the build files will be generated.
android_build_top: string, absolute path to ANDROID_BUILD_TOP android_build_top: string, absolute path to ANDROID_BUILD_TOP
temp_artifact_dir: string, temp directory to hold build artifacts
fetched from Android Build server.
remote_git: string, remote name to fetch and check if the revision of
VNDK snapshot is included in the source if it is not in the current
git repository.
""" """
self._android_build_top = android_build_top self._android_build_top = android_build_top
self._install_dir = install_dir self._install_dir = install_dir
self._remote_git = remote_git
self._manifest_file = os.path.join(temp_artifact_dir, self._manifest_file = os.path.join(temp_artifact_dir,
self.MANIFEST_XML) self.MANIFEST_XML)
self._notice_files_dir = os.path.join(install_dir, self._notice_files_dir = os.path.join(install_dir,
@@ -140,14 +147,16 @@ class GPLChecker(object):
'Checking if the parent of revision {rev} exists in {proj}'. 'Checking if the parent of revision {rev} exists in {proj}'.
format(rev=revision, proj=git_project_path)) format(rev=revision, proj=git_project_path))
try: try:
cmd = ['git', '-C', path, 'fetch', 'goog', revision] cmd = ['git', '-C', path, 'fetch', self._remote_git, revision]
utils.check_call(cmd) utils.check_call(cmd)
cmd = ['git', '-C', path, 'rev-parse', 'FETCH_HEAD^2'] cmd = ['git', '-C', path, 'rev-parse', 'FETCH_HEAD^2']
parent_revision = utils.check_output(cmd).strip() parent_revision = utils.check_output(cmd).strip()
except subprocess.CalledProcessError as error: except subprocess.CalledProcessError as error:
logging.error( logging.error(
'Failed to get parent of revision {rev}: {err}'.format( 'Failed to get parent of revision {rev} from "{remote}": '
rev=revision, err=error)) '{err}'.format(
rev=revision, remote=self._remote_git, err=error))
logging.error('Try --remote to manually set remote name')
raise raise
else: else:
if not _check_rev_list(parent_revision): if not _check_rev_list(parent_revision):
@@ -226,6 +235,11 @@ def get_args():
help='VNDK snapshot version to check, e.g. "27".') help='VNDK snapshot version to check, e.g. "27".')
parser.add_argument('-b', '--branch', help='Branch to pull manifest from.') parser.add_argument('-b', '--branch', help='Branch to pull manifest from.')
parser.add_argument('--build', help='Build number to pull manifest from.') parser.add_argument('--build', help='Build number to pull manifest from.')
parser.add_argument(
'--remote',
default='aosp',
help=('Remote name to fetch and check if the revision of VNDK snapshot '
'is included in the source to conform GPL license. default=aosp'))
parser.add_argument( parser.add_argument(
'-v', '-v',
'--verbose', '--verbose',
@@ -248,6 +262,7 @@ def main():
args = get_args() args = get_args()
vndk_version = args.vndk_version vndk_version = args.vndk_version
install_dir = os.path.join(PREBUILTS_VNDK_DIR, 'v{}'.format(vndk_version)) install_dir = os.path.join(PREBUILTS_VNDK_DIR, 'v{}'.format(vndk_version))
remote = args.remote
if not os.path.isdir(install_dir): if not os.path.isdir(install_dir):
raise ValueError( raise ValueError(
'Please provide valid VNDK version. {} does not exist.' 'Please provide valid VNDK version. {} does not exist.'
@@ -264,7 +279,7 @@ def main():
manifest_dest) manifest_dest)
license_checker = GPLChecker(install_dir, ANDROID_BUILD_TOP, license_checker = GPLChecker(install_dir, ANDROID_BUILD_TOP,
temp_artifact_dir) temp_artifact_dir, remote)
try: try:
license_checker.check_gpl_projects() license_checker.check_gpl_projects()
except ValueError as error: except ValueError as error:

View File

@@ -184,6 +184,11 @@ def get_args():
'--use-current-branch', '--use-current-branch',
action='store_true', action='store_true',
help='Perform the update in the current branch. Do not repo start.') help='Perform the update in the current branch. Do not repo start.')
parser.add_argument(
'--remote',
default='aosp',
help=('Remote name to fetch and check if the revision of VNDK snapshot '
'is included in the source to conform GPL license. default=aosp'))
parser.add_argument( parser.add_argument(
'-v', '-v',
'--verbose', '--verbose',
@@ -250,7 +255,7 @@ def main():
if not local: if not local:
license_checker = GPLChecker(install_dir, ANDROID_BUILD_TOP, license_checker = GPLChecker(install_dir, ANDROID_BUILD_TOP,
temp_artifact_dir) temp_artifact_dir, args.remote)
check_gpl_license(license_checker) check_gpl_license(license_checker)
logging.info( logging.info(
'Successfully updated VNDK snapshot v{}'.format(vndk_version)) 'Successfully updated VNDK snapshot v{}'.format(vndk_version))