-
Notifications
You must be signed in to change notification settings - Fork 3
/
mk_svn_tag.sh
executable file
·270 lines (207 loc) · 7.65 KB
/
mk_svn_tag.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
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
#!/bin/bash
cleanup() {
rm -f ${TMP_PREFIX}*
return 0
}
usage() {
cat >&2 <<- EOF
**************************************************************************
release kernel : help you to release kernel source tree .
Usage: ${0} [Options] [URL_FROM] [URL_TO_PATH]
[URL_FROM] : SVN URL path which you want to release to
(folder with revision & timestamp will be created automatically).
default is "${URL_RELEASE_PATH}"
[URL_TO_PATH] : SVN URL which you want to release from .
default is "${URL_RELEASE_FROM}"
[Options]:
-r <revision> : release revision of [URL_FROM] .
example:
release kernel source revision HEAD from "http://ebkrd2sw-desktop/svn/mx50/trunk/ltib/rpm/linux-2.6.35.3" to
"http://ebkrd2sw-desktop/svn/mx50/tags/kernel/release" :
${0} "http://ebkrd2sw-desktop/svn/mx50/trunk/ltib/rpm/linux-2.6.35.3" "http://ebkrd2sw-desktop/svn/mx50/tags/kernel/release"
release kernel source revision 1234 from "http://ebkrd2sw-desktop/svn/mx50/trunk/ltib/rpm/linux-2.6.35.3" to
"http://ebkrd2sw-desktop/svn/mx50/tags/kernel/release" :
${0} -r 1234 "http://ebkrd2sw-desktop/svn/mx50/trunk/ltib/rpm/linux-2.6.35.3" "http://ebkrd2sw-desktop/svn/mx50/tags/kernel/release"
release kernel source from working folder to "http://ebkrd2sw-desktop/svn/mx50/tags/kernel/release" :
${0} . "http://ebkrd2sw-desktop/svn/mx50/tags/kernel/release"
**************************************************************************
EOF
return 0
}
_GetURL_SVN_MRev() {
URL="${1}"
REV="${2}"
if [ -z "${REV}" ];then
REV="HEAD"
fi
if [ "$(echo "${URL}"|grep "^.*://")" ];then
querry_local="0"
else
querry_local="1"
fi
if [ "${querry_local}" = "1" ];then
REVISION="$(LANG=C svn info "${URL}"|grep "Last\ Changed\ Rev"|sed -e "s/Last\ Changed\ Rev:\ //")"
else
REVISION="$(LANG=C svn info -r "${REV}" "${URL}"|grep "Last\ Changed\ Rev"|sed -e "s/Last\ Changed\ Rev:\ //")"
fi
echo "${REVISION}"
return 0
}
load_kernel_info() {
echo "loading kernel information .... "
KRev_file="$1"
if [ -f "${KRev_file}" ];then
echo -n ""
else
echo "\"${KRev_file}\" cannot found !"
return 1
fi
_kernel_url="$(cat "${KRev_file}" |grep "^URL:"|sed -e "s/URL:[[:blank:]]*//")"
#_kernel_rev="$(cat "${KRev_file}" |grep "^Revision:"|sed -e "s/Revision:[[:blank:]]*//")"
_kernel_rev="$(cat "${KRev_file}" |grep "^Last Changed Rev:"|sed -e "s/Last Changed Rev:[[:blank:]]*//")"
echo "Kernel URL:\"${_kernel_url}\""
echo "Kernel REV:${_kernel_rev}"
_kernel_root_URL="$(echo "${_kernel_url}"|sed -e "s/\/[[:alnum:]]*\/[[:alnum:]]*\/[[:alnum:]]*\/[[:alnum:]]*$//")"
#if [ "${HWCFG_CPU_NAME}" = "m166e" ] && [ "${HWCFG_CPU_NAME}" = "mx35" ];then
# _kernel_compile_h_URL="${_kernel_root_URL}/include/linux/compile.h"
#else
_kernel_compile_h_URL="${_kernel_root_URL}/include/generated/compile.h"
#fi
echo "_kernel_compile_h_URL=\"${_kernel_compile_h_URL}\""
if [ "${_kernel_rev}" ] && [ "${_kernel_compile_h_URL}" ];then
svn export -r "${_kernel_rev}" "${_kernel_compile_h_URL}" "/tmp/sdmk_${ID_STRING}_kcompile.h"
KERNEL_INFO_STRING="r${_kernel_rev} ($(cat "/tmp/sdmk_${ID_STRING}_kcompile.h"|grep "^#define UTS_VERSION"|sed -e "s/^#define\ UTS_VERSION //"|sed -e "s/\"//g"))"
echo "kernel info=\"${KERNEL_INFO_STRING}\""
rm -f "/tmp/sdmk_${ID_STRING}_kcompile.h"
fi
return 0
}
PURPOSE="release"
LAST_RELEASE_INFO=".last_${PURPOSE}" # last release url ,you can cat this file ,it is a string .
URL_BASE="http://ebkrd2sw-desktop/svn/mx50"
#URL_BASE="file:///work/test/svn/testrepo"
TIMESTAMP_STR="$(date +%Y%m%d_%H%M%S)" # release name : the name you want to release into URL path .
ID_STRING="${TIMESTAMP_STR}"
TMP_PREFIX=".tmp-${TIMESTAMP_STR}"
COMMIT_MSG_FILE="${TMP_PREFIX}-commit_msg"
REL_FROM_SVNINFO="${TMP_PREFIX}-svninfo"
URL_RELEASE_PATH="${URL_BASE}/tags/kernel/${PURPOSE}" # URL path : where you want to release from your working folder .
URL_RELEASE_FROM="${URL_BASE}/trunk/ltib/rpm/BUILD/linux-2.6.35.3" # URL path : where you want to release from your working folder .
#URL_RELEASE_FROM="${URL_BASE}/trunk" # URL path : where you want to release from your working folder .
REV_RELEASE_FROM="$(_GetURL_SVN_MRev "${URL_RELEASE_FROM}")"
while getopts "r:" opt
do
case ${opt} in
r )
REV_RELEASE_FROM="${OPTARG}"
REV_OPTION="-r ${REV_RELEASE_FROM}"
;;
\? )
unknown_opt=1
;;
esac
done
shift "$(expr ${OPTIND} - 1)"
if [ "$unknown_opt" = 1 ];then
usage
exit 0
fi
if [ "$2" ];then
URL_RELEASE_PATH="$2"
fi
if [ "$1" ];then
URL_RELEASE_FROM="$1"
fi
LANG=C svn info ${REV_OPTION} "${URL_RELEASE_FROM}" > "${REL_FROM_SVNINFO}"
load_kernel_info "${REL_FROM_SVNINFO}"
#if [ ! -f "${LAST_RELEASE_INFO}" ];then
# echo "\"${LAST_RELEASE_INFO}\" do not exist !!"
# cleanup ; exit 1
#fi
if [ -z "$(LANG=C svn info ${REV_OPTION} "${URL_RELEASE_PATH}")" ];then
echo "svn path \"${URL_RELEASE_PATH}\" do not exist , please create it first !"
cleanup ; exit 2
fi
#if [ -z "$(LANG=C svn info "${URL_RELEASE_PATH}/${LAST_RELEASE_INFO}")" ];then
# echo "svn path \"${URL_RELEASE_PATH}\${LAST_RELEASE_INFO}" do not exist , please create it first !"
# cleanup ; exit 3
#fi
if [ -z "$(echo "${URL_RELEASE_FROM}"|grep "^.*://")" ] && [ "$(LANG=C svn st "${URL_RELEASE_FROM}"|grep "^[MA!~C]")" ];then
# local working folder with local modification .
URL_RELEASE_NAME="r${REV_RELEASE_FROM}_M${TIMESTAMP_STR}" # release name : the name you want to release into URL path .
else
URL_RELEASE_NAME="r${REV_RELEASE_FROM}_${TIMESTAMP_STR}" # release name : the name you want to release into URL path .
fi
input="${TMP_PREFIX}-edboxdefault"
cat << EOF > $input
[Purpose]
[Author]
[Test Report]
---- test device information ------
model name : N/A
sdmaker model no : N/A
sdmaker model revision : N/A
tester : N/A
---------- basic test items -----------
boot into rootfs : N/A
insmod Wifi : N/A
insmod USB Gadget : N/A
Suspend/Resume : N/A
EPD logo : N/A
EPD ebrmain main menu : N/A
EPD QT : N/A
Power Off : N/A
--------- special test items ----------
[Release information]
Release kernel source and binary by "$0" :
From : ${URL_RELEASE_FROM}
To : ${URL_RELEASE_PATH}/${URL_RELEASE_NAME}
KernelInfo : ${KERNEL_INFO_STRING}
[SVN info of ${URL_RELEASE_FROM}]
$(cat "${REL_FROM_SVNINFO}")
EOF
LANG=C dialog --stdout --ascii-lines --title "svn commit :" \
--fixed-font --editbox ${input} 0 0 > "${COMMIT_MSG_FILE}"
case $? in
0)
echo "OK"
# commit current working folder status into tag ...
if [ -z "${REV_RELEASE_FROM}" ];then
echo "there is no revision infomation @ ${URL_RELEASE_FROM} ..."
cleanup ; exit 5
fi
LANG=C svn cp ${REV_OPTION} -F "${COMMIT_MSG_FILE}" "${URL_RELEASE_FROM}" "${URL_RELEASE_PATH}/${URL_RELEASE_NAME}"
if [ $? != 0 ];then
echo "svn tag making fail !"
cleanup ; exit 6
fi
# commit into trunk ...
echo "RELEASE_URL=${URL_RELEASE_PATH}/${URL_RELEASE_NAME}" > "${LAST_RELEASE_INFO}"
echo "RELEASE_FROM_URL=${URL_RELEASE_FROM}" >> "${LAST_RELEASE_INFO}"
echo "RELEASE_FROM_REV=${REV_RELEASE_FROM}" >> "${LAST_RELEASE_INFO}"
if [ -z "$(svn st "${LAST_RELEASE_INFO}" | grep "^?")" ];then
svn add "${LAST_RELEASE_INFO}"
fi
if [ -z "$(cat "${LAST_RELEASE_INFO}"|grep "RELEASE_FROM_REV")" ] || [ "${REV_RELEASE_FROM}" -gt "$(cat "${LAST_RELEASE_INFO}"|grep "RELEASE_FROM_REV"|sed -e "s/RELEASE_FROM_REV=//")" ];then
# if there is no RELEASE_FROM_REV field in last release info .
LANG=C svn ci -F "${COMMIT_MSG_FILE}" "${LAST_RELEASE_INFO}"
fi
;;
1)
echo "Button 1 (Cancel) pressed"
cleanup ; exit 4
;;
2)
echo "Button 2 (Help) pressed"
cleanup ; exit 4
;;
3)
echo "Button 3 (Extra) pressed"
cleanup ; exit 4
;;
255)
echo "ESC pressed."
cleanup ; exit 4
;;
esac
cleanup ;exit 0