• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1#!/usr/bin/env python3
2# -*- coding: utf-8 -*-
3# Copyright 2019 The Chromium OS Authors. All rights reserved.
4# Use of this source code is governed by a BSD-style license that can be
5# found in the LICENSE file.
6
7"""Clones helper scripts into chromiumos-overlay.
8
9Some files in here also need to live in chromiumos-overlay (e.g., the
10patch_manager ones). This script simplifies the copying of those around.
11"""
12
13# Necessary until crbug.com/1006448 is fixed
14from __future__ import print_function
15
16import argparse
17import os
18import shutil
19import sys
20
21
22def _find_repo_root(script_root):
23  repo_root = os.path.abspath(os.path.join(script_root, '../../../../'))
24  if not os.path.isdir(os.path.join(repo_root, '.repo')):
25    return None
26  return repo_root
27
28
29def main():
30  parser = argparse.ArgumentParser(description=__doc__)
31  parser.add_argument(
32      '--chroot_path',
33      help="Path to where CrOS' source tree lives. Will autodetect if you're "
34      'running this from inside the CrOS source tree.')
35  args = parser.parse_args()
36
37  my_dir = os.path.abspath(os.path.dirname(__file__))
38
39  repo_root = args.chroot_path
40  if repo_root is None:
41    repo_root = _find_repo_root(my_dir)
42    if repo_root is None:
43      sys.exit("Couldn't detect the CrOS checkout root; please provide a "
44               'value for --chroot_path')
45
46  chromiumos_overlay = os.path.join(repo_root,
47                                    'src/third_party/chromiumos-overlay')
48
49  clone_files = [
50      'failure_modes.py',
51      'get_llvm_hash.py',
52      'git_llvm_rev.py',
53      'patch_manager.py',
54      'subprocess_helpers.py',
55  ]
56
57  filesdir = os.path.join(chromiumos_overlay,
58                          'sys-devel/llvm/files/patch_manager')
59  for f in clone_files:
60    source = os.path.join(my_dir, f)
61    dest = os.path.join(filesdir, f)
62    print('%r => %r' % (source, dest))
63    shutil.copyfile(source, dest)
64
65
66if __name__ == '__main__':
67  main()
68