• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1#!/usr/bin/env python3
2# -*- coding: utf-8 -*-
3# Copyright 2019 The ChromiumOS Authors
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
14
15import argparse
16import os
17import shutil
18import sys
19
20
21def _find_repo_root(script_root):
22    repo_root = os.path.abspath(os.path.join(script_root, "../../../../"))
23    if not os.path.isdir(os.path.join(repo_root, ".repo")):
24        return None
25    return repo_root
26
27
28def main():
29    parser = argparse.ArgumentParser(description=__doc__)
30    parser.add_argument(
31        "--chroot_path",
32        help="Path to where CrOS' source tree lives. Will autodetect if you're "
33        "running this from inside the CrOS source tree.",
34    )
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(
44                "Couldn't detect the CrOS checkout root; please provide a "
45                "value for --chroot_path"
46            )
47
48    chromiumos_overlay = os.path.join(
49        repo_root, "src/third_party/chromiumos-overlay"
50    )
51
52    clone_files = [
53        "failure_modes.py",
54        "get_llvm_hash.py",
55        "git_llvm_rev.py",
56        "patch_manager.py",
57        "subprocess_helpers.py",
58    ]
59
60    filesdir = os.path.join(
61        chromiumos_overlay, "sys-devel/llvm/files/patch_manager"
62    )
63    for f in clone_files:
64        source = os.path.join(my_dir, f)
65        dest = os.path.join(filesdir, f)
66        print("%r => %r" % (source, dest))
67        shutil.copyfile(source, dest)
68
69
70if __name__ == "__main__":
71    main()
72