1 | #!/bin/sh |
---|
2 | |
---|
3 | #--------------------------------------------------------------------- |
---|
4 | # |
---|
5 | # This script should be installed within the loginfo file of CVS |
---|
6 | # using the following line : |
---|
7 | # |
---|
8 | # ... |
---|
9 | #.cmtcvsinfos $CVSROOT/CVSROOT/cmt_buildcvsinfos2.sh |
---|
10 | # ... |
---|
11 | # |
---|
12 | # and is used whenever one tries to import a module named .cmtcvsinfos/<protocol-level>/<module> |
---|
13 | # |
---|
14 | #--------------------------------------------------------------------- |
---|
15 | |
---|
16 | #set -x |
---|
17 | |
---|
18 | #--------------------------------------------------------------------- |
---|
19 | get_cvsroot () |
---|
20 | { |
---|
21 | echo ${CVSROOT} | sed -e 's#^:[^:]*:##' |
---|
22 | } |
---|
23 | |
---|
24 | #--------------------------------------------------------------------- |
---|
25 | check_head () |
---|
26 | { |
---|
27 | head=$1 |
---|
28 | version=$2 |
---|
29 | |
---|
30 | echo "${head} ${version}" | awk '{\ |
---|
31 | head = $1; \ |
---|
32 | version = $2; \ |
---|
33 | nh = split (head, hlist); \ |
---|
34 | nv = split (version, vlist); \ |
---|
35 | for (i = 0; i < nh; i++) \ |
---|
36 | { \ |
---|
37 | if (hlist[i] != vlist[i]) \ |
---|
38 | { \ |
---|
39 | print "0"; \ |
---|
40 | next; \ |
---|
41 | } \ |
---|
42 | } \ |
---|
43 | print "1"; \ |
---|
44 | }' |
---|
45 | } |
---|
46 | |
---|
47 | #--------------------------------------------------------------------- |
---|
48 | check_newer () |
---|
49 | { |
---|
50 | v1=$1; |
---|
51 | v2=$2; |
---|
52 | |
---|
53 | #echo "check_newer v1=${v1} v2=${v2}" |
---|
54 | |
---|
55 | if test "${v2}" = ""; then |
---|
56 | echo "1" |
---|
57 | return |
---|
58 | fi |
---|
59 | |
---|
60 | echo "${v1} ${v2}" | awk '{\ |
---|
61 | v1 = $1;\ |
---|
62 | v2 = $2;\ |
---|
63 | n1 = len (v1);\ |
---|
64 | if (n1 == 0) \ |
---|
65 | {\ |
---|
66 | print "0";\ |
---|
67 | next;\ |
---|
68 | }\ |
---|
69 | n1 = split (v1, list1);\ |
---|
70 | if (n1 == 0) \ |
---|
71 | {\ |
---|
72 | print "0";\ |
---|
73 | next;\ |
---|
74 | }\ |
---|
75 | n2 = split (v2, list2);\ |
---|
76 | for (i = 0; i < n1; i++)\ |
---|
77 | {\ |
---|
78 | if (i > n2)\ |
---|
79 | {\ |
---|
80 | print "1";\ |
---|
81 | next; |
---|
82 | }\ |
---|
83 | if (list1[i] > list2[i])\ |
---|
84 | {\ |
---|
85 | print "1";\ |
---|
86 | next; |
---|
87 | }\ |
---|
88 | }\ |
---|
89 | print "0";\ |
---|
90 | }' |
---|
91 | } |
---|
92 | |
---|
93 | #--------------------------------------------------------------------- |
---|
94 | get_tags () |
---|
95 | { |
---|
96 | module=$1 |
---|
97 | |
---|
98 | if test -r "${CVSROOT}/${module}/cmt/requirements,v" ; then |
---|
99 | test_file="${CVSROOT}/${module}/cmt/requirements,v" |
---|
100 | elif test -r "${CVSROOT}/${module}/mgr/requirements,v" ; then |
---|
101 | test_file="${CVSROOT}/${module}/mgr/requirements,v" |
---|
102 | else |
---|
103 | test_file=`find "${CVSROOT}/${module}" -name '*,v' -print | head -n 1` |
---|
104 | fi |
---|
105 | |
---|
106 | # tags=`tr ' ' '\n' < "${test_file}" | \ |
---|
107 | # awk '/symbols/,/locks/ {n=split($0,w,"."); if ((n == 2) || (n == 4) || (n == 6)) print; }' | \ |
---|
108 | # sed -e 's#:.*##' -e 's#[ ]*##'` |
---|
109 | # print "${tags}" |
---|
110 | |
---|
111 | started=0 |
---|
112 | finished=0 |
---|
113 | top= |
---|
114 | toptags= |
---|
115 | cvstags= |
---|
116 | |
---|
117 | #symbols |
---|
118 | # v10:1.1.1.1 |
---|
119 | # v2:1.1.1.1 |
---|
120 | # v1r2:1.1.1.1 |
---|
121 | # v1r1:1.1.1.1 |
---|
122 | # v1:1.1.1.1 |
---|
123 | # cmt:1.1.1; |
---|
124 | #locks; strict; |
---|
125 | |
---|
126 | alltags=`tr ' ' '\n' < "${test_file}" | \ |
---|
127 | awk '/symbols/,/locks/ { \ |
---|
128 | if (done == 1) next; \ |
---|
129 | n = split ($0,w,"."); \ |
---|
130 | if ((n != 2) && (n != 4) && (n != 6)) next; \ |
---|
131 | if ($1 == "symbols") \ |
---|
132 | { \ |
---|
133 | print $2; \ |
---|
134 | } \ |
---|
135 | else \ |
---|
136 | { \ |
---|
137 | print $1; \ |
---|
138 | } \ |
---|
139 | if ($1 == "locks;") done = 1; \ |
---|
140 | }'` |
---|
141 | |
---|
142 | for t in ${alltags}; do |
---|
143 | tag=`echo ${t} | sed -e 's#:.*##'` |
---|
144 | v=`echo ${t} | sed -e 's#.*:##'` |
---|
145 | |
---|
146 | if test `check_newer ${v} ${top}` = "1"; then |
---|
147 | top=${v} |
---|
148 | fi |
---|
149 | done |
---|
150 | |
---|
151 | tags= |
---|
152 | |
---|
153 | for t in ${alltags}; do |
---|
154 | tag=`echo ${t} | sed -e 's#:.*##'` |
---|
155 | v=`echo ${t} | sed -e 's#.*:##'` |
---|
156 | |
---|
157 | if test "${v}" = "${top}"; then |
---|
158 | tags="${tags} ${tag}(t) " |
---|
159 | else |
---|
160 | tags="${tags} ${tag} " |
---|
161 | fi |
---|
162 | |
---|
163 | done |
---|
164 | |
---|
165 | echo "${tags}" |
---|
166 | } |
---|
167 | |
---|
168 | #--------------------------------------------------------------------- |
---|
169 | get_branches () |
---|
170 | { |
---|
171 | module=$1 |
---|
172 | |
---|
173 | branches= |
---|
174 | for branch in `ls "${CVSROOT}/${module}" | grep -v Attic` ; do |
---|
175 | if test -d "${CVSROOT}/${module}/${branch}" ; then |
---|
176 | if test ! -r "${CVSROOT}/${module}/${branch}/cmt/requirements,v" ; then |
---|
177 | if test ! -r "${CVSROOT}/${module}/${branch}/mgr/requirements,v" ; then |
---|
178 | if test "${branches}" = "" ; then |
---|
179 | branches="${branch}" |
---|
180 | else |
---|
181 | branches="${branches} ${branch}" |
---|
182 | fi |
---|
183 | fi |
---|
184 | fi |
---|
185 | fi |
---|
186 | done |
---|
187 | echo "${branches}" |
---|
188 | } |
---|
189 | |
---|
190 | #--------------------------------------------------------------------- |
---|
191 | get_subpackages () |
---|
192 | { |
---|
193 | module=$1 |
---|
194 | |
---|
195 | subpackages= |
---|
196 | for branch in `ls "${CVSROOT}/${module}" | grep -v Attic` ; do |
---|
197 | if test -d "${CVSROOT}/${module}/${branch}" ; then |
---|
198 | if test -r "${CVSROOT}/${module}/${branch}/cmt/requirements,v" ; then |
---|
199 | if test "${subpackages}" = "" ; then |
---|
200 | subpackages="${branch}" |
---|
201 | else |
---|
202 | subpackages="${subpackages} ${branch}" |
---|
203 | fi |
---|
204 | elif test -r "${CVSROOT}/${module}/${branch}/mgr/requirements,v" ; then |
---|
205 | if test "${subpackages}" = "" ; then |
---|
206 | subpackages="${branch}" |
---|
207 | else |
---|
208 | subpackages="${subpackages} ${branch}" |
---|
209 | fi |
---|
210 | fi |
---|
211 | fi |
---|
212 | done |
---|
213 | echo "${subpackages}" |
---|
214 | } |
---|
215 | |
---|
216 | #--------------------------------------------------------------------- |
---|
217 | # main |
---|
218 | #--------------------------------------------------------------------- |
---|
219 | |
---|
220 | rm -f -r $CVSROOT/.cmtcvsinfos/* |
---|
221 | |
---|
222 | read a |
---|
223 | |
---|
224 | root=$CVSROOT |
---|
225 | protocol_level=v1r1 |
---|
226 | |
---|
227 | module=`echo $a | sed -e "s#.*[.]cmtcvsinfos/${protocol_level}/##"` |
---|
228 | error= |
---|
229 | |
---|
230 | if test "${module}" = "" ; then |
---|
231 | echo "error=syntax error" |
---|
232 | exit 1 |
---|
233 | fi |
---|
234 | |
---|
235 | tags= |
---|
236 | tags_top= |
---|
237 | |
---|
238 | if test -d "${CVSROOT}/${module}" ; then |
---|
239 | alltags=`get_tags ${module}` |
---|
240 | for t in ${alltags}; do |
---|
241 | a=`echo ${t} | grep '[(]t[)]$'` |
---|
242 | is_top=$? |
---|
243 | if test "${is_top}" = 1; then |
---|
244 | if test "${tags}" = ""; then |
---|
245 | tags="${t}" |
---|
246 | else |
---|
247 | tags="${tags} ${t}" |
---|
248 | fi |
---|
249 | else |
---|
250 | t=`echo ${t} | sed -e 's#(t)##'` |
---|
251 | |
---|
252 | if test "${tags_top}" = ""; then |
---|
253 | tags_top="${t}" |
---|
254 | else |
---|
255 | tags_top="${tags_top} ${t}" |
---|
256 | fi |
---|
257 | fi |
---|
258 | done |
---|
259 | else |
---|
260 | error="### Module ${module} not found." |
---|
261 | fi |
---|
262 | |
---|
263 | branches= |
---|
264 | if test -d "${CVSROOT}/${module}" ; then |
---|
265 | branches=`get_branches ${module}` |
---|
266 | fi |
---|
267 | |
---|
268 | subpackages= |
---|
269 | if test -d "${CVSROOT}/${module}" ; then |
---|
270 | subpackages=`get_subpackages ${module}` |
---|
271 | fi |
---|
272 | |
---|
273 | if test ! "${error}" = ""; then |
---|
274 | echo error=${error} |
---|
275 | fi |
---|
276 | |
---|
277 | echo tags_top=${tags_top} |
---|
278 | echo tags=${tags} |
---|
279 | echo branches=${branches} |
---|
280 | echo subpackages=${subpackages} |
---|
281 | |
---|
282 | exit 1 |
---|
283 | |
---|
284 | |
---|