-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetup_android.sh
More file actions
executable file
·101 lines (83 loc) · 2.63 KB
/
Copy pathsetup_android.sh
File metadata and controls
executable file
·101 lines (83 loc) · 2.63 KB
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
#!/bin/bash
set -e
set -u
set -o pipefail
SRC=$(dirname "$(readlink -e "$0")")
source "${SRC}/utils.sh"
function usage {
cat <<DELIM__
usage: $(basename "$0") [options]
$ $(basename "$0") --aosp==<path-to-android-root> --branch=<user-name>/update-binaries
Options:
--aosp Android Root path
--branch Branch name
--clean (OPTIONAL) clean up AOSP projects
--help (OPTIONAL) display usage
DELIM__
}
function projects_path {
local -n projects_ref="$1"
local aosp="$2"
local ti_binaries_path=""
local toplevel=""
pushd "${SRC}"
for ti_config in config/boards/*.yaml; do
ti_binaries_path=$(config_value "${ti_config}" android.binaries_path)
pushd "${aosp}/${ti_binaries_path}"
toplevel=$(git rev-parse --sq --show-toplevel)
if [[ ! ${projects_ref[*]} =~ ${toplevel} ]]; then
projects_ref+=("${toplevel}")
fi
popd
done
}
function main {
local aosp=""
local branch=""
local clean=false
local opts_args="aosp:,branch:,clean,help"
local opts=$(getopt -o '' -l "${opts_args}" -- "$@")
eval set -- "${opts}"
while true; do
case "$1" in
--aosp) aosp=$(find_path "$2"); shift 2 ;;
--branch) branch="$2"; shift 2 ;;
--clean) clean=true; shift ;;
--help) usage; exit 0 ;;
--) shift; break ;;
esac
done
# check arguments
[ -z "${aosp}" ] && error_usage_exit "Cannot find Android Root Path"
[ -z "${branch}" ] && error_usage_exit "Please provide branch name"
declare -a projects
projects_path projects "${aosp}"
for project in "${projects[@]}"; do
pushd "${project}"
echo "Setup: ${project}"
# clean up project
if [[ "${clean}" == true ]]; then
git clean --quiet -xdf
git reset --quiet --hard
fi
# check local changes
if ! git diff-index --quiet HEAD; then
error_exit "error: Local changes detected"
fi
# check if branch exist
if git show-ref --quiet "${branch}"; then
git checkout --quiet --detach
git branch --quiet -D "${branch}"
fi
# detect remote: [baylibre]
local remote="baylibre"
local output=$(git remote | grep baylibre)
[ -n "${output}" ] && remote="baylibre"
# create branch
local repo_branch=$(repo --color=never info . 2>&1 | perl -ne 'print "$1" if /^Manifest revision: (.*)/')
git fetch --quiet "${remote}" "${repo_branch}"
git checkout --quiet "${remote}/${repo_branch}" -b "${branch}"
popd
done
}
main "$@"