1#!/bin/bash 2# Copyright 2021 The ChromiumOS Authors 3# Use of this source code is governed by a BSD-style license that can be 4# found in the LICENSE file. 5 6find_checkout_root() { 7 path="$(dirname "$0")" 8 path="$(realpath "${path}")" 9 while [[ "${path}" != "/" && ! -d "${path}/.repo" ]] 10 do 11 path="$(dirname "${path}")" 12 done 13 echo "${path}" 14} 15 16# Setup a project. 17mkdir -p /tmp/setup_project || exit $? 18cipd install -force -root /tmp/setup_project \ 19 chromiumos/infra/setup_project/\$\{platform\} latest || exit $? 20echo "Done installing CIPD package." 21 22# If --checkout is not supplied, assume that this script is being run from 23# a checkout. Find the root of the checkout. 24if [[ "$*" != *"-checkout"* ]]; then 25 echo "--checkout not supplied, searching for checkout root." 26 checkout_root="$(find_checkout_root)" 27 echo "Found checkout root ${checkout_root}." 28 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 34fi 35/tmp/setup_project/setup_project setup-project "$@" 36