source: CMT/v1r18p20051108/mgr/cmt_buildcvsinfos2.sh

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

Make include_dirs subject to private sections - see CL#277

  • Property svn:eol-style set to native
  • Property svn:executable set to *
File size: 5.5 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/<protocol-level>/<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
225protocol_level=v1r1
226
227module=`echo $a | sed -e "s#.*[.]cmtcvsinfos/${protocol_level}/##"`
228error=
229
230if test "${module}" = "" ; then
231  echo "error=syntax error"
232  exit 1
233fi
234
235tags=
236tags_top=
237
238if 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
259else
260  error="### Module ${module} not found."
261fi
262
263branches=
264if test -d "${CVSROOT}/${module}" ; then
265  branches=`get_branches ${module}`
266fi
267
268subpackages=
269if test -d "${CVSROOT}/${module}" ; then
270  subpackages=`get_subpackages ${module}`
271fi
272
273if test ! "${error}" = ""; then
274  echo error=${error}
275fi
276
277echo tags_top=${tags_top}
278echo tags=${tags}
279echo branches=${branches}
280echo subpackages=${subpackages}
281
282exit 1
283
284
Note: See TracBrowser for help on using the repository browser.