-
Notifications
You must be signed in to change notification settings - Fork 0
/
sandbox.sh
executable file
·178 lines (149 loc) · 4.48 KB
/
sandbox.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
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
#!/bin/bash
## --------------------------------------------------------------------
## Intent: Clone all voltha repos into local directory sandbox/.
## --------------------------------------------------------------------
##-------------------##
##---] GLOBALS [---##
##-------------------##
startPwd="$(realpath '.')"
readonly startPwd
## --------------------------------------------------------------------
## Intent: Guide image logo paths are usually incorrect so find 'em.
## --------------------------------------------------------------------
function gather_guide()
{
local logdir="$1"; shift
(
set -x
grep -r '://guide.opencord.org/logos' .
set +x
) >> "$logdir/logos.log"
return
}
## --------------------------------------------------------------------
## Intent: Library function used to load a list of repositories from disk.
## --------------------------------------------------------------------
function get_repos()
{
local -n ref=$1; shift
local conf
for conf in "$@";
do
local fyl
[[ -f "$conf" ]] \
&& { fyl="$conf"; } \
|| { fyl="${startPwd}/repositories/${conf}.git.clone"; }
readarray -t buffer < <(\
grep --fixed-strings '://' "$fyl" \
| awk -F\# '{print $1}' \
| grep '://' \
)
ref+=("${buffer[@]}")
done
return
}
# ## --------------------------------------------------------------------
# ## --------------------------------------------------------------------
# function version_bbsim()
# {
# # Chart.yaml :: appVersion: 1.12.10 correlates to git tag
# # https://gerrit.opencord.org/plugins/gitiles/voltha-helm-charts/+/refs/heads/master/bbsim/Chart.yaml#17
# return
# }
#
# echo "** SIGNPOST[LINENO=${LINENO}]"
#
# ## --------------------------------------------------------------------
# ## --------------------------------------------------------------------
# function version_voltha_openolt_adapter()
# {
# cat<<EOF
# name: "voltha-adapter-openolt"
# version: "2.11.3"
# appVersion: "4.2.6"
# EOF
# return
# }
#
# ## --------------------------------------------------------------------
# ## --------------------------------------------------------------------
# function version_check()
# {
# cat<<EOF
# REPOS:
# o bbsim
# o voltha-adapter-openolt
# o obtain appVersion string from chart.yaml
# o verify repo: git tag | grep "$appVersion"
# EOF
# EOF
# }
## --------------------------------------------------------------------
## Intent: Iterate and checkout all votlha repos for sanity checking
## --------------------------------------------------------------------
function bulk_checkout()
{
local logdir="$1"; shift
cat <<EOF
** -----------------------------------------------------------------------
** ${BASH_SOURCE[0]}
** -----------------------------------------------------------------------
EOF
declare -a repos=()
get_repos repos 'onos' 'voltha' 'tools'
for git_url in "${repos[@]}";
do
repo="${url##*/}"
[[ -d "$repo" ]] && continue
echo
git clone "${git_url}" >/dev/null
pushd "${repo}" >/dev/null
[[ -v create_branch ]] && { git checkout -b dev-joey-voltha-release; }
mkdir -p "$logdir/$name"
git branch > "$logdir/$name/branches"
git tag > "$logdir/$name/tag"
popd >/dev/null
done
return
}
## --------------------------------------------------------------------
## Intent: Display program usage
## --------------------------------------------------------------------
function usage()
{
cat <<EOH
Usage: $0
--edit Create user branches during clone + checkout
--sandbox Destination directory for git clone
EOH
return
}
##----------------##
##---] MAIN [---##
##----------------##
sandbox='sandbox'
while [[ $# -gt 0 ]]; do
arg="$1"; shift
case "$arg" in
--help) usage; exit 0 ;;
--edit) declare -g -i create_branch=1 ;;
--sandbox)
declare -g sandbox="$1"; shift
readonly sandbox
;;
esac
done
proj=voltha
ver=9999999
semver="${proj}-${ver}"
logdir="${startPwd}/logs"
mkdir -p "$logdir"
mkdir -p "$sandbox"
# mktemp
mkdir -p "$sandbox"
pushd "$sandbox" >/dev/null
mkdir -p branches
bulk_checkout "$logdir"
# # gather_guide "$logdir"
popd >/dev/null
# [EOF]