[infra] --nopull option for helper.py (#219)

The options is useful when changing base-images.
This commit is contained in:
Mike Aizatsky 2016-12-27 17:14:33 -08:00 committed by GitHub
parent 64f8b6593d
commit 0bbedbda65
1 changed files with 14 additions and 5 deletions

View File

@ -33,17 +33,23 @@ OSSFUZZ_DIR = os.path.dirname(os.path.dirname(os.path.realpath(__file__)))
BUILD_DIR = os.path.join(OSSFUZZ_DIR, 'build') BUILD_DIR = os.path.join(OSSFUZZ_DIR, 'build')
GLOBAL_ARGS = None
def main(): def main():
os.chdir(OSSFUZZ_DIR) os.chdir(OSSFUZZ_DIR)
if not os.path.exists(BUILD_DIR): if not os.path.exists(BUILD_DIR):
os.mkdir(BUILD_DIR) os.mkdir(BUILD_DIR)
parser = argparse.ArgumentParser('helper.py', description='oss-fuzz helpers') parser = argparse.ArgumentParser('helper.py', description='oss-fuzz helpers')
parser.add_argument(
'--nopull', default=False, action='store_const', const=True,
help='do not specify --pull while building an image')
parser.add_argument( parser.add_argument(
'command', 'command',
help='One of: generate, build_image, build_fuzzers, run_fuzzer, coverage, shell', help='One of: generate, build_image, build_fuzzers, run_fuzzer, coverage, shell',
nargs=argparse.REMAINDER) nargs=argparse.REMAINDER)
args = parser.parse_args() global GLOBAL_ARGS
GLOBAL_ARGS = args = parser.parse_args()
if not args.command: if not args.command:
parser.print_help() parser.print_help()
@ -110,10 +116,13 @@ def _build_image(image_name):
dockerfile_dir = os.path.join('projects', image_name) dockerfile_dir = os.path.join('projects', image_name)
command = [
'docker', 'build', '--pull', '-t', 'ossfuzz/' + image_name, build_args = []
dockerfile_dir, if not GLOBAL_ARGS.nopull:
] build_args += ['--pull']
build_args += ['-t', 'ossfuzz/' + image_name, dockerfile_dir ]
command = [ 'docker', 'build' ] + build_args
print('Running:', _get_command_string(command)) print('Running:', _get_command_string(command))
try: try: