David Burger | 234efd7 | 2020-02-26 17:34:47 -0700 | [diff] [blame] | 1 | #!/bin/bash |
Jack Neus | b371b95 | 2021-10-07 17:34:45 +0000 | [diff] [blame] | 2 | # Copyright 2021 The Chromium OS Authors. All rights reserved. |
David Burger | 234efd7 | 2020-02-26 17:34:47 -0700 | [diff] [blame] | 3 | # Use of this source code is governed by a BSD-style license that can be |
| 4 | # found in the LICENSE file. |
| 5 | |
Jack Neus | b87c73b | 2021-11-10 20:20:18 +0000 | [diff] [blame^] | 6 | find_checkout_root() { |
| 7 | path="$(dirname "$0")" |
| 8 | while [[ "${path}" != "/" && ! -d "${path}/.repo" ]] |
| 9 | do |
| 10 | path="$(dirname "${path}")" |
| 11 | done |
| 12 | echo "${path}" |
| 13 | } |
Jack Neus | b8b00c4 | 2021-07-28 15:07:38 +0000 | [diff] [blame] | 14 | |
Jack Neus | b87c73b | 2021-11-10 20:20:18 +0000 | [diff] [blame^] | 15 | # Setup a project. |
Jack Neus | b371b95 | 2021-10-07 17:34:45 +0000 | [diff] [blame] | 16 | mkdir /tmp/setup_project 2>/dev/null |
| 17 | cipd install -force -root /tmp/setup_project \ |
| 18 | chromiumos/infra/setup_project/\$\{platform\} prod |
Jack Neus | b87c73b | 2021-11-10 20:20:18 +0000 | [diff] [blame^] | 19 | |
Jack Neus | b371b95 | 2021-10-07 17:34:45 +0000 | [diff] [blame] | 20 | # If --checkout is not supplied, assume that this script is being run from |
Jack Neus | b87c73b | 2021-11-10 20:20:18 +0000 | [diff] [blame^] | 21 | # a checkout. Find the root of the checkout. |
Jack Neus | b371b95 | 2021-10-07 17:34:45 +0000 | [diff] [blame] | 22 | if [[ "$*" != *"-checkout"* ]]; then |
Jack Neus | b87c73b | 2021-11-10 20:20:18 +0000 | [diff] [blame^] | 23 | checkout_root="$(find_checkout_root)" |
| 24 | if [[ "${checkout_root}" != "/" ]]; then |
| 25 | set -- "$@" "-checkout=$(find_checkout_root)/" |
| 26 | else |
| 27 | echo "You are invoking setup_project.sh from outside of a CrOS checkout." |
| 28 | echo "Please specify the location of the checkout with -checkout." |
| 29 | fi |
Jack Neus | b371b95 | 2021-10-07 17:34:45 +0000 | [diff] [blame] | 30 | fi |
| 31 | /tmp/setup_project/setup_project setup-project "$@" |