| Index: tools/grab_deps.py
|
| diff --git a/tools/grab_deps.py b/tools/grab_deps.py
|
| new file mode 100755
|
| index 0000000000000000000000000000000000000000..3c9e19094f4036c8690da687353030a6121b9392
|
| --- /dev/null
|
| +++ b/tools/grab_deps.py
|
| @@ -0,0 +1,62 @@
|
| +#!/usr/bin/python
|
| +# Copyright 2014 Google Inc.
|
| +#
|
| +# Use of this source code is governed by a BSD-style license that can be
|
| +# found in the LICENSE file.
|
| +
|
| +
|
| +import sys
|
| +import os
|
| +import subprocess
|
| +import git_utils
|
| +import subprocess
|
| +import misc_utils
|
| +
|
| +from DEPS import deps
|
| +
|
| +
|
| +def rm_directory_if_exists(directory):
|
| + if os.path.isdir(directory) and not os.path.islink(directory):
|
| + shutil.rmtree(directory)
|
| + elif os.path.lexists(directory):
|
| + os.remove(directory)
|
| +
|
| +
|
| +def git_checkout_to_directory(repo, checkout, directory, verbose=False):
|
| + """TODO(halcanary): document this function.
|
| + """
|
| + git = git_utils.git_executable()
|
| + assert git
|
| + if not checkout:
|
| + checkout = 'origin/master'
|
| + try:
|
| + with misc_utils.ChangeDir(directory):
|
| + if verbose:
|
| + print '%s\n>>>> %s\n>>>> %s\n' % (directory, repo, checkout)
|
| + subprocess.check_call([git, 'fetch'])
|
| + subprocess.check_call([git, 'checkout', '--quiet', checkout])
|
| + except:
|
| + rm_directory_if_exists(directory)
|
| + subprocess.check_call([git, 'clone', repo, directory])
|
| + with misc_utils.ChangeDir(directory):
|
| + if verbose:
|
| + print '%s\n>>>> %s\n>>>> %s\n' % (directory, repo, checkout)
|
| + subprocess.check_call([git, 'checkout', '--quiet', checkout])
|
| +
|
| +
|
| +def main(argv):
|
| + dependencies = deps["ALL"].copy()
|
| + for arg in argv:
|
| + if arg not in deps:
|
| + print arg, '?'
|
| + exit(1)
|
| + for dep in deps[arg]:
|
| + dependencies[dep] = deps[arg][dep]
|
| + for directory in dependencies:
|
| + repo, checkout = dependencies[directory]
|
| + git_checkout_to_directory(repo, checkout, directory, verbose=True)
|
| +
|
| +
|
| +if __name__ == '__main__':
|
| + main(sys.argv[1:])
|
| +
|
|
|