blob: fb389a31bbd32cbe0dded51dffdc292c389d2f45 [file] [log] [blame]
David Burger234efd72020-02-26 17:34:47 -07001#!/bin/bash
Jack Neusb371b952021-10-07 17:34:45 +00002# Copyright 2021 The Chromium OS Authors. All rights reserved.
David Burger234efd72020-02-26 17:34:47 -07003# Use of this source code is governed by a BSD-style license that can be
4# found in the LICENSE file.
5
Jack Neusb87c73b2021-11-10 20:20:18 +00006find_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 Neusb8b00c42021-07-28 15:07:38 +000014
Jack Neusb87c73b2021-11-10 20:20:18 +000015# Setup a project.
Jack Neusb371b952021-10-07 17:34:45 +000016mkdir /tmp/setup_project 2>/dev/null
17cipd install -force -root /tmp/setup_project \
18 chromiumos/infra/setup_project/\$\{platform\} prod
Jack Neusb87c73b2021-11-10 20:20:18 +000019
Jack Neusb371b952021-10-07 17:34:45 +000020# If --checkout is not supplied, assume that this script is being run from
Jack Neusb87c73b2021-11-10 20:20:18 +000021# a checkout. Find the root of the checkout.
Jack Neusb371b952021-10-07 17:34:45 +000022if [[ "$*" != *"-checkout"* ]]; then
Jack Neusb87c73b2021-11-10 20:20:18 +000023 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 Neusb371b952021-10-07 17:34:45 +000030fi
31/tmp/setup_project/setup_project setup-project "$@"