1 # Copyright (c) 2013 The Chromium OS Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file.
5 """Sync the Chrome source code used by Sonic to the specified directory."""
7 from chromite.lib import commandline
8 from chromite.lib import cros_build_lib, git
9 from chromite.buildbot import repository
10 from chromite.lib import osutils
14 """Creates the argparse parser."""
15 parser = commandline.ArgumentParser(description=__doc__)
17 parser.add_argument('--reset', help='Revert local changes',
18 action='store_true', default=False)
19 parser.add_argument('chrome_root', help='Directory to sync chrome in')
26 options = parser.parse_args(argv)
28 mc = git.ManifestCheckout.Cached(__file__)
30 # TODO(cmasone): http://crbug.com/241805 support "internal"
31 # checkouts of sonic chrome, once source access and codename issues
33 repo_url = (mc.remotes['sonic-partner']['fetch'] +
34 mc.FindProjectCheckout('partner/manifest')['name'])
36 repo = repository.RepoRepository(repo_url=repo_url,
37 directory=options.chrome_root)
39 # Revert any lingering local changes.
40 if not osutils.SafeMakedirs(options.chrome_root) and options.reset:
43 except cros_build_lib.RunCommandError:
44 osutils.RmDir(options.chrome_root)
45 osutils.SafeMakedirs(options.chrome_root)