blob: 5cbb7e14830dff8d7a9488ccf53a8c46f2e306b6 [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")"
Jack Neusde61a362021-12-29 15:52:04 +00008 path="$(realpath "${path}")"
Jack Neusb87c73b2021-11-10 20:20:18 +00009 while [[ "${path}" != "/" && ! -d "${path}/.repo" ]]
10 do
11 path="$(dirname "${path}")"
12 done
13 echo "${path}"
14}
Jack Neusb8b00c42021-07-28 15:07:38 +000015
Jack Neusb87c73b2021-11-10 20:20:18 +000016# Setup a project.
Jack Neusb371b952021-10-07 17:34:45 +000017mkdir /tmp/setup_project 2>/dev/null
18cipd install -force -root /tmp/setup_project \
19 chromiumos/infra/setup_project/\$\{platform\} prod
Jack Neusde61a362021-12-29 15:52:04 +000020echo "Done installing CIPD package."
Jack Neusb87c73b2021-11-10 20:20:18 +000021
Jack Neusb371b952021-10-07 17:34:45 +000022# If --checkout is not supplied, assume that this script is being run from
Jack Neusb87c73b2021-11-10 20:20:18 +000023# a checkout. Find the root of the checkout.
Jack Neusb371b952021-10-07 17:34:45 +000024if [[ "$*" != *"-checkout"* ]]; then
Jack Neusde61a362021-12-29 15:52:04 +000025 echo "--checkout not supplied, searching for checkout root."
Jack Neusb87c73b2021-11-10 20:20:18 +000026 checkout_root="$(find_checkout_root)"
Jack Neusde61a362021-12-29 15:52:04 +000027 echo "Found checkout root ${checkout_root}."
Jack Neusb87c73b2021-11-10 20:20:18 +000028 if [[ "${checkout_root}" != "/" ]]; then
29 set -- "$@" "-checkout=$(find_checkout_root)/"
30 else
31 echo "You are invoking setup_project.sh from outside of a CrOS checkout."
32 echo "Please specify the location of the checkout with -checkout."
33 fi
Jack Neusb371b952021-10-07 17:34:45 +000034fi
35/tmp/setup_project/setup_project setup-project "$@"