source: CMT/v1r18p20041201/mgr/cmt_buildcvsinfos2.sh @ 1

Last change on this file since 1 was 1, checked in by arnault, 19 years ago

Import all tags

File size: 5.8 KB
Line 
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/<module>
13#
14#---------------------------------------------------------------------
15
16#set -x
17
18#---------------------------------------------------------------------
19get_cvsroot ()
20{
21  echo ${CVSROOT} | sed -e 's#^:[^:]*:##'
22}
23
24#---------------------------------------------------------------------
25check_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#---------------------------------------------------------------------
48check_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#---------------------------------------------------------------------
94get_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#---------------------------------------------------------------------
169get_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#---------------------------------------------------------------------
191get_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
220rm -f -r $CVSROOT/.cmtcvsinfos/*
221
222read a
223
224root=$CVSROOT
225
226module=`echo $a | sed -e "s#.*[.]cmtcvsinfos/##"`
227error=
228
229if test "${module}" = "" ; then
230  echo "error=syntax error"
231  exit 1
232fi
233
234tags=
235tags_top=
236
237if test -d "${CVSROOT}/${module}" ; then
238  alltags=`get_tags ${module}`
239  for t in ${alltags}; do
240    a=`echo ${t} | grep '[(]t[)]$'`
241    is_top=$?
242    if test "${is_top}" = 1; then
243      if test "${tags}" = ""; then
244        tags="${t}"
245      else
246        tags="${tags} ${t}"
247      fi
248    else
249      t=`echo ${t} | sed -e 's#(t)##'`
250
251      if test "${tags_top}" = ""; then
252        tags_top="${t}"
253      else
254        tags_top="${tags_top} ${t}"
255      fi
256    fi
257  done
258else
259  error="### Module ${module} not found."
260fi
261
262branches=
263if test -d "${CVSROOT}/${module}" ; then
264  branches=`get_branches ${module}`
265fi
266
267subpackages=
268if test -d "${CVSROOT}/${module}" ; then
269  subpackages=`get_subpackages ${module}`
270fi
271
272if test ! "${error}" = ""; then
273  echo error=${error}
274fi
275
276echo tags_top=${tags_top}
277echo tags=${tags}
278echo branches=${branches}
279echo subpackages=${subpackages}
280
281exit 1
282
283
Note: See TracBrowser for help on using the repository browser.