-
Notifications
You must be signed in to change notification settings - Fork 4
/
setup.sh
executable file
·148 lines (122 loc) · 4.57 KB
/
setup.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
#!/bin/bash
# Note: Collabora repository with pending patches
# https://git.collabora.com/cgit/linux.git/log/?h=topic/chromeos/waiting-for-upstream
chromeos_path=$(python3 -c "from common import chromeos_path; print(chromeos_path)")
chromeos_repo=$(python3 -c "from config import chromeos_repo; print(chromeos_repo)")
stable_path=$(python3 -c "from common import stable_path; print(stable_path)")
stable_repo=$(python3 -c "from config import stable_repo; print(stable_repo)")
upstream_path=$(python3 -c "from common import upstream_path; print(upstream_path)")
upstream_repo=$(python3 -c "from config import upstream_repo; print(upstream_repo)")
next_path=$(python3 -c "from common import next_path; print(next_path)")
next_repo=$(python3 -c "from config import next_repo; print(next_repo)")
rebase_baseline_branch=$(python3 -c "from config import rebase_baseline_branch; print(rebase_baseline_branch)")
android_repo=$(python3 -c "from config import android_repo; print(android_repo)")
if [[ "${android_repo}" != "None" ]]; then
android_baseline_branch=$(python3 -c "from config import android_baseline_branch; print(android_baseline_branch)")
android_path=$(python3 -c "from common import android_path; print(android_path)")
fi
nextdb=$(python3 -c "from common import nextdb; print(nextdb)")
rebasedb=$(python3 -c "from common import rebasedb; print(rebasedb)")
progdir=$(dirname "$0")
cd "${progdir}" || exit 1
# Simple clone:
# Clone repository, do not add 'upstream' remote
clone_simple()
{
local destdir=$1
local repository=$2
local force=$3
echo "Cloning ${repository} into ${destdir}"
if [[ -d "${destdir}" ]]; then
pushd "${destdir}" >/dev/null || return 1
git checkout master
if [[ -n "${force}" ]]; then
# This is needed if the origin may have been rebased
git fetch -p origin
git reset --hard origin/master
else
git pull -p
fi
popd >/dev/null || return 1
else
git clone "${repository}" "${destdir}"
fi
}
clone_simple "${upstream_path}" "${upstream_repo}"
if [[ "${stable_repo}" != "None" ]]; then
clone_simple "${stable_path}" "${stable_repo}"
fi
# Complex clone:
# Clone repository, check out branch, add 'upstream' remote
# Also, optionally, add 'next' remote
clone_complex()
{
local destdir=$1
local repository=$2
local branch=$3
echo "Cloning ${repository}:${branch} into ${destdir}"
if [[ -d "${destdir}" ]]; then
pushd "${destdir}" >/dev/null || return 1
git reset --hard HEAD
git fetch origin
if git rev-parse --verify "${branch}" >/dev/null 2>&1; then
git checkout "${branch}"
if ! git pull; then
# git pull may fail if the remote repository was rebased.
# Pull it the hard way.
git reset --hard "origin/${branch}"
fi
else
git checkout -b "${branch}" "origin/${branch}"
fi
git remote -v | grep upstream || {
git remote add upstream "${upstream_path}"
}
git fetch upstream
if [[ "${next_repo}" != "None" ]]; then
git remote -v | grep next || {
git remote add next "${next_path}"
}
git fetch next
fi
popd >/dev/null || return 1
else
git clone "${repository}" "${destdir}"
pushd "${destdir}" >/dev/null || return 1
git checkout -b "${branch}" "origin/${branch}"
git remote add upstream "${upstream_path}"
git fetch upstream
if [[ "${next_repo}" != "None" ]]; then
git remote add next "${next_path}"
git fetch next
fi
popd >/dev/null || return 1
fi
}
if [[ "${next_repo}" != "None" ]]; then
clone_simple "${next_path}" "${next_repo}" "force"
fi
clone_complex "${chromeos_path}" "${chromeos_repo}" "${rebase_baseline_branch}"
if [[ "${android_repo}" != "None" ]]; then
clone_complex "${android_path}" "${android_repo}" "${android_baseline_branch}"
fi
# Remove and re-create all databases (for now) except upstream database.
rm -f "${rebasedb}" "${nextdb}"
echo "Initializing database"
./initdb.py
echo "Initializing upstream database"
./initdb-upstream.py
if [[ "${next_repo}" != "None" ]]; then
echo "Initializing next database"
./initdb-next.py
fi
echo "Updating rebase database with upstream commits"
./update.py
echo "Calculating initial revert list"
./revertlist.py
echo "Calculating initial drop list"
./drop.py
echo "Calculating replace list"
./upstream.py
echo "Calculating topics"
./topics.py