CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
orangepi-xunlong

Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place. Commercial Alternative to JupyterHub.

GitHub Repository: orangepi-xunlong/orangepi-build
Path: blob/next/external/cache/sources/wl/include/epivers.sh
Views: 3959
1
#! /bin/bash
2
#
3
# Create the epivers.h file from epivers.h.in
4
#
5
# Epivers.h version support svn/sparse/gclient workspaces
6
#
7
# $Id: epivers.sh 389101 2013-03-05 17:23:14Z $
8
#
9
# Version generation works off of svn property HeadURL, if
10
# not set it keys its versions from current svn workspace or
11
# via .gclient_info deps contents
12
#
13
# GetCompVer.py return value and action needed
14
# i. trunk => use current date as version string
15
# ii. local => use SVNURL expanded by HeadURL keyword
16
# iii. <tag> => use it as as is
17
# (some components can override and say give me native ver)
18
# iv. empty =>
19
# a) If TAG is specified use it
20
# a) If no TAG is specified use date
21
#
22
# Contact: Prakash Dhavali
23
# Contact: hnd-software-scm-list
24
#
25
26
# If the version header file already exists, increment its build number.
27
# Otherwise, create a new file.
28
if [ -f epivers.h ]; then
29
30
# If REUSE_VERSION is set, epivers iteration is not incremented
31
# This can be used precommit and continuous integration projects
32
if [ -n "$REUSE_VERSION" ]; then
33
echo "Previous epivers.h exists. Skipping version increment"
34
exit 0
35
fi
36
37
build=$(grep EPI_BUILD_NUMBER epivers.h | sed -e "s,.*BUILD_NUMBER[ ]*,,")
38
build=$(expr ${build} + 1)
39
echo build=${build}
40
sed -e "s,.*_BUILD_NUMBER.*,#define EPI_BUILD_NUMBER ${build}," \
41
< epivers.h > epivers.h.new
42
cp -p epivers.h epivers.h.prev
43
mv epivers.h.new epivers.h
44
exit 0
45
46
else # epivers.h doesn't exist
47
48
SVNCMD=${SVNCMD:-"svn --non-interactive"}
49
SRCBASE=${SRCBASE:-..}
50
NULL=/dev/null
51
[ -z "$VERBOSE" ] || NULL=/dev/stderr
52
53
# Check for the in file, if not there we're in the wrong directory
54
if [ ! -f epivers.h.in ]; then
55
echo "ERROR: No epivers.h.in found"
56
exit 1
57
fi
58
59
# Following SVNURL should be expanded on checkout
60
SVNURL='$HeadURL: http://svn.sj.broadcom.com/svn/wlansvn/proj/tags/AARDVARK/AARDVARK_REL_6_30_254/src/include/epivers.sh $'
61
62
# .gclient_info is created by gclient checkout/sync steps
63
# and contains "DEPS='<deps-url1> <deps-url2> ..." entry
64
GCLIENT_INFO=${GCLIENT_INFO:-${SRCBASE}/../.gclient_info}
65
66
# In gclient, derive SVNURL from gclient_info file
67
if [ -s "${GCLIENT_INFO}" ]; then
68
source ${GCLIENT_INFO}
69
if [ -z "$DEPS" ]; then
70
echo "ERROR: DEPS entry missing in $GCLIENT_INFO"
71
exit 1
72
else
73
for dep in $DEPS; do
74
SVNURL=${SVNURL:-$dep}
75
# Set SVNURL to first DEPS with /tags/ (if any)
76
if [[ $dep == */tags/* ]]; then
77
SVNURL=$dep
78
echo "INFO: Found gclient DEPS: $SVNURL"
79
break
80
fi
81
done
82
fi
83
elif [ -f "${GCLIENT_INFO}" ]; then
84
echo "ERROR: $GCLIENT_INFO exists, but it is empty"
85
exit 1
86
fi
87
88
# If SVNURL isn't expanded, extract it from svn info
89
if echo "$SVNURL" | egrep -vq 'HeadURL.*epivers.sh.*|http://.*/DEPS'; then
90
[ -n "$VERBOSE" ] && \
91
echo "DBG: SVN URL ($SVNURL) wasn't expanded. Getting it from svn info"
92
SVNURL=$($SVNCMD info epivers.sh 2> $NULL | egrep "^URL:")
93
fi
94
95
if echo "${TAG}" | grep -q "_BRANCH_\|_TWIG_"; then
96
branchtag=$TAG
97
else
98
branchtag=""
99
fi
100
101
# If this is a tagged build, use the tag to supply the numbers
102
# Tag should be in the form
103
# <NAME>_REL_<MAJ>_<MINOR>
104
# or
105
# <NAME>_REL_<MAJ>_<MINOR>_RC<RCNUM>
106
# or
107
# <NAME>_REL_<MAJ>_<MINOR>_RC<RCNUM>_<INCREMENTAL>
108
109
MERGERLOG=${SRCBASE}/../merger_sources.log
110
GETCOMPVER=getcompver.py
111
GETCOMPVER_NET=/projects/hnd_software/gallery/src/tools/build/$GETCOMPVER
112
GETCOMPVER_NET_WIN=Z:${GETCOMPVER_NET}
113
114
#
115
# If there is a local copy GETCOMPVER use it ahead of network copy
116
#
117
if [ -s "$GETCOMPVER" ]; then
118
GETCOMPVER_PATH="$GETCOMPVER"
119
elif [ -s "${SRCBASE}/../src/tools/build/$GETCOMPVER" ]; then
120
GETCOMPVER_PATH="${SRCBASE}/../src/tools/build/$GETCOMPVER"
121
elif [ -s "$GETCOMPVER_NET" ]; then
122
GETCOMPVER_PATH="$GETCOMPVER_NET"
123
elif [ -s "$GETCOMPVER_NET_WIN" ]; then
124
GETCOMPVER_PATH="$GETCOMPVER_NET_WIN"
125
fi
126
127
#
128
# If $GETCOMPVER isn't found, fetch it from SVN
129
# (this should be very rare)
130
#
131
if [ ! -s "$GETCOMPVER_PATH" ]; then
132
[ -n "$VERBOSE" ] && \
133
echo "DBG: Fetching $GETCOMPVER from trunk"
134
135
$SVNCMD export -q \
136
^/proj/trunk/src/tools/build/${GETCOMPVER} \
137
${GETCOMPVER} 2> $NULL
138
139
GETCOMPVER_PATH=$GETCOMPVER
140
fi
141
142
# Now get tag for src/include from automerger log
143
[ -n "$VERBOSE" ] && \
144
echo "DBG: python $GETCOMPVER_PATH $MERGERLOG src/include"
145
146
COMPTAG=$(python $GETCOMPVER_PATH $MERGERLOG src/include 2> $NULL | sed -e 's/[[:space:]]*//g')
147
148
echo "DBG: Component Tag String Derived = $COMPTAG"
149
150
# Process COMPTAG values
151
# Rule:
152
# If trunk is returned, use date as component tag
153
# If LOCAL_COMPONENT is returned, use SVN URL to get native tag
154
# If component is returned or empty, assign it to SVNTAG
155
# GetCompVer.py return value and action needed
156
# i. trunk => use current date as version string
157
# ii. local => use SVNURL expanded by HeadURL keyword
158
# iii. <tag> => use it as as is
159
# iv. empty =>
160
# a) If TAG is specified use it
161
# a) If no TAG is specified use SVNURL from HeadURL
162
163
SVNURL_VER=false
164
165
if [ "$COMPTAG" == "" ]; then
166
SVNURL_VER=true
167
elif [ "$COMPTAG" == "LOCAL_COMPONENT" ]; then
168
SVNURL_VER=true
169
elif [ "$COMPTAG" == "trunk" ]; then
170
SVNTAG=$(date '+TRUNKCOMP_REL_%Y_%m_%d')
171
else
172
SVNTAG=$COMPTAG
173
fi
174
175
# Given SVNURL path conventions or naming conventions, derive SVNTAG
176
# TO-DO: SVNTAG derivation logic can move to a central common API
177
# TO-DO: ${SRCBASE}/tools/build/svnurl2tag.sh
178
if [ "$SVNURL_VER" == "true" ]; then
179
case "${SVNURL}" in
180
*_BRANCH_*)
181
SVNTAG=$(echo $SVNURL | tr '/' '\n' | awk '/_BRANCH_/{printf "%s",$1}')
182
;;
183
*_TWIG_*)
184
SVNTAG=$(echo $SVNURL | tr '/' '\n' | awk '/_TWIG_/{printf "%s",$1}')
185
;;
186
*_REL_*)
187
SVNTAG=$(echo $SVNURL | tr '/' '\n' | awk '/_REL_/{printf "%s",$1}')
188
;;
189
*/branches/*)
190
SVNTAG=${SVNURL#*/branches/}
191
SVNTAG=${SVNTAG%%/*}
192
;;
193
*/proj/tags/*|*/deps/tags/*)
194
SVNTAG=${SVNURL#*/tags/*/}
195
SVNTAG=${SVNTAG%%/*}
196
;;
197
*/trunk/*)
198
SVNTAG=$(date '+TRUNKURL_REL_%Y_%m_%d')
199
;;
200
*)
201
SVNTAG=$(date '+OTHER_REL_%Y_%m_%d')
202
;;
203
esac
204
echo "DBG: Native Tag String Derived from URL: $SVNTAG"
205
else
206
echo "DBG: Native Tag String Derived: $SVNTAG"
207
fi
208
209
TAG=${SVNTAG}
210
211
# Normalize the branch name portion to "D11" in case it has underscores in it
212
branch_name=$(expr match "$TAG" '\(.*\)_\(BRANCH\|TWIG\|REL\)_.*')
213
TAG=$(echo $TAG | sed -e "s%^$branch_name%D11%")
214
215
# Split the tag into an array on underbar or whitespace boundaries.
216
IFS="_ " tag=(${TAG})
217
unset IFS
218
219
tagged=1
220
if [ ${#tag[*]} -eq 0 ]; then
221
tag=($(date '+TOT REL %Y %m %d 0 %y'));
222
# reconstruct a TAG from the date
223
TAG=${tag[0]}_${tag[1]}_${tag[2]}_${tag[3]}_${tag[4]}_${tag[5]}
224
tagged=0
225
fi
226
227
# Allow environment variable to override values.
228
# Missing values default to 0
229
#
230
maj=${EPI_MAJOR_VERSION:-${tag[2]:-0}}
231
min=${EPI_MINOR_VERSION:-${tag[3]:-0}}
232
rcnum=${EPI_RC_NUMBER:-${tag[4]:-0}}
233
234
# If increment field is 0, set it to date suffix if on TOB
235
if [ -n "$branchtag" ]; then
236
[ "${tag[5]:-0}" -eq 0 ] && echo "Using date suffix for incr"
237
today=${EPI_DATE_STR:-$(date '+%Y%m%d')}
238
incremental=${EPI_INCREMENTAL_NUMBER:-${tag[5]:-${today:-0}}}
239
else
240
incremental=${EPI_INCREMENTAL_NUMBER:-${tag[5]:-0}}
241
fi
242
origincr=${EPI_INCREMENTAL_NUMBER:-${tag[5]:-0}}
243
build=${EPI_BUILD_NUMBER:-0}
244
245
# Strip 'RC' from front of rcnum if present
246
rcnum=${rcnum/#RC/}
247
248
# strip leading zero off the number (otherwise they look like octal)
249
maj=${maj/#0/}
250
min=${min/#0/}
251
rcnum=${rcnum/#0/}
252
incremental=${incremental/#0/}
253
origincr=${origincr/#0/}
254
build=${build/#0/}
255
256
# some numbers may now be null. replace with with zero.
257
maj=${maj:-0}
258
min=${min:-0}
259
260
rcnum=${rcnum:-0}
261
incremental=${incremental:-0}
262
origincr=${origincr:-0}
263
build=${build:-0}
264
265
if [ -n "$EPI_VERSION_NUM" ]; then
266
vernum=$EPI_VERSION_NUM
267
elif [ ${tagged} -eq 1 ]; then
268
# vernum is 32chars max
269
vernum=$(printf "0x%02x%02x%02x%02x" ${maj} ${min} ${rcnum} ${origincr})
270
else
271
vernum=$(printf "0x00%02x%02x%02x" ${tag[7]} ${min} ${rcnum})
272
fi
273
274
# make sure the size of vernum is under 32 bits.
275
# Otherwise, truncate. The string will keep full information.
276
vernum=${vernum:0:10}
277
278
# build the string directly from the tag, irrespective of its length
279
# remove the name , the tag type, then replace all _ by .
280
tag_ver_str=${TAG/${tag[0]}_}
281
tag_ver_str=${tag_ver_str/${tag[1]}_}
282
tag_ver_str=${tag_ver_str//_/.}
283
284
# record tag type
285
tagtype=
286
287
if [ "${tag[1]}" = "BRANCH" -o "${tag[1]}" = "TWIG" ]; then
288
tagtype=" (TOB)"
289
echo "tag type: $tagtype"
290
fi
291
292
echo "Effective version string: $tag_ver_str"
293
294
if [ "$(uname -s)" == "Darwin" ]; then
295
# Mac does not like 2-digit numbers so convert the number to single
296
# digit. 5.100 becomes 5.1
297
if [ $min -gt 99 ]; then
298
minmac=$(expr $min / 100)
299
else
300
minmac=$min
301
fi
302
epi_ver_dev="${maj}.${minmac}.0"
303
else
304
epi_ver_dev="${maj}.${min}.${rcnum}"
305
fi
306
307
# Finally get version control revision number of <SRCBASE> (if any)
308
vc_version_num=$($SVNCMD info ${SRCBASE} 2> $NULL | awk -F': ' '/^Last Changed Rev: /{printf "%s", $2}')
309
310
# OK, go do it
311
echo "maj=${maj}, min=${min}, rc=${rcnum}, inc=${incremental}, build=${build}"
312
313
sed \
314
-e "s;@EPI_MAJOR_VERSION@;${maj};" \
315
-e "s;@EPI_MINOR_VERSION@;${min};" \
316
-e "s;@EPI_RC_NUMBER@;${rcnum};" \
317
-e "s;@EPI_INCREMENTAL_NUMBER@;${incremental};" \
318
-e "s;@EPI_BUILD_NUMBER@;${build};" \
319
-e "s;@EPI_VERSION@;${maj}, ${min}, ${rcnum}, ${incremental};" \
320
-e "s;@EPI_VERSION_STR@;${tag_ver_str};" \
321
-e "s;@EPI_VERSION_TYPE@;${tagtype};" \
322
-e "s;@VERSION_TYPE@;${tagtype};" \
323
-e "s;@EPI_VERSION_NUM@;${vernum};" \
324
-e "s;@EPI_VERSION_DEV@;${epi_ver_dev};" \
325
-e "s;@VC_VERSION_NUM@;r${vc_version_num};" \
326
< epivers.h.in > epivers.h
327
328
# In shared workspaces across different platforms, ensure that
329
# windows generated file is made platform neutral without CRLF
330
if uname -s | egrep -i -q "cygwin"; then
331
dos2unix epivers.h > $NULL 2>&1
332
fi
333
fi # epivers.h
334
335