blob: 7bdb910fdf93b29f0355e4f9e18523b3313f2c43 [file] [log] [blame]
David Burger234efd72020-02-26 17:34:47 -07001#!/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 Burger234efd72020-02-26 17:34:47 -07008function bail() {
9 echo "${1}"
10 exit 1
11}
12
13function usage() {
14 echo "Usage: $0 <program> <project>" >&2
15 exit 1
16}
17
David Burger234efd72020-02-26 17:34:47 -070018if [[ $# -ne 2 ]]; then
19 usage
20fi
21
Sean McAllister01931d12020-03-12 10:34:40 -060022# Exit if any command fails, print commands and their arguments.
23set -ex
24
25# Move to this script's directory.
26cd "$(dirname "$0")"
27
David Burger234efd72020-02-26 17:34:47 -070028program="${1}"
29project="${2}"
30
31project_url="https://chrome-internal.googlesource.com/chromeos/project/${program}/${project}"
32project_src="../../src/project/${program}/${project}"
33
34if [[ -d "${project_src}" ]]; then
35 bail "${project_src} already exists, exiting."
36fi
37
38git clone "${project_url}" "${project_src}"
39
40local_manifests_dir="../../.repo/local_manifests"
41
42if [[ ! -d "${local_manifests_dir}" ]]; then
43 mkdir -p "${local_manifests_dir}"
44fi
45
46symlink="${local_manifests_dir}/${project}.xml"
47if [[ -e "${symlink}" ]]; then
48 bail "${symlink} already exists, exiting."
49fi
50
51local_manifest="${project_src}/local_manifest.xml"
52if [[ ! -e "${local_manifest}" ]]; then
53 bail "Expected local manifest ${local_manifest} does not exist, exiting."
54fi
55
56ln -sr "${local_manifest}" "${symlink}"
57
58repo sync --force-sync -j48