David Burger | 234efd7 | 2020-02-26 17:34:47 -0700 | [diff] [blame] | 1 | #!/bin/bash |
| 2 | # Copyright 2020 The Chromium OS Authors. All rights reserved. |
| 3 | # Use of this source code is governed by a BSD-style license that can be |
| 4 | # found in the LICENSE file. |
| 5 | |
| 6 | # Setup a project. |
| 7 | |
David Burger | 234efd7 | 2020-02-26 17:34:47 -0700 | [diff] [blame] | 8 | function bail() { |
| 9 | echo "${1}" |
| 10 | exit 1 |
| 11 | } |
| 12 | |
| 13 | function usage() { |
| 14 | echo "Usage: $0 <program> <project>" >&2 |
| 15 | exit 1 |
| 16 | } |
| 17 | |
David Burger | 234efd7 | 2020-02-26 17:34:47 -0700 | [diff] [blame] | 18 | if [[ $# -ne 2 ]]; then |
| 19 | usage |
| 20 | fi |
| 21 | |
Sean McAllister | 01931d1 | 2020-03-12 10:34:40 -0600 | [diff] [blame^] | 22 | # Exit if any command fails, print commands and their arguments. |
| 23 | set -ex |
| 24 | |
| 25 | # Move to this script's directory. |
| 26 | cd "$(dirname "$0")" |
| 27 | |
David Burger | 234efd7 | 2020-02-26 17:34:47 -0700 | [diff] [blame] | 28 | program="${1}" |
| 29 | project="${2}" |
| 30 | |
| 31 | project_url="https://chrome-internal.googlesource.com/chromeos/project/${program}/${project}" |
| 32 | project_src="../../src/project/${program}/${project}" |
| 33 | |
| 34 | if [[ -d "${project_src}" ]]; then |
| 35 | bail "${project_src} already exists, exiting." |
| 36 | fi |
| 37 | |
| 38 | git clone "${project_url}" "${project_src}" |
| 39 | |
| 40 | local_manifests_dir="../../.repo/local_manifests" |
| 41 | |
| 42 | if [[ ! -d "${local_manifests_dir}" ]]; then |
| 43 | mkdir -p "${local_manifests_dir}" |
| 44 | fi |
| 45 | |
| 46 | symlink="${local_manifests_dir}/${project}.xml" |
| 47 | if [[ -e "${symlink}" ]]; then |
| 48 | bail "${symlink} already exists, exiting." |
| 49 | fi |
| 50 | |
| 51 | local_manifest="${project_src}/local_manifest.xml" |
| 52 | if [[ ! -e "${local_manifest}" ]]; then |
| 53 | bail "Expected local manifest ${local_manifest} does not exist, exiting." |
| 54 | fi |
| 55 | |
| 56 | ln -sr "${local_manifest}" "${symlink}" |
| 57 | |
| 58 | repo sync --force-sync -j48 |