File: pact-commit

package info (click to toggle)
pact 980714-3
  • links: PTS
  • area: main
  • in suites: slink
  • size: 13,096 kB
  • ctags: 26,034
  • sloc: ansic: 109,076; lisp: 9,645; csh: 7,147; fortran: 1,050; makefile: 136; lex: 95; sh: 32
file content (378 lines) | stat: -rwxr-xr-x 8,564 bytes parent folder | download
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
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
#!/bin/csh -f
#>
#> PACT-COMMIT - commit to the PACT repository
#>
#> Usage: pact-commit [-f] [-h] [-n] [-v] [-M <msgfile>] "message"
#>
#> Options:
#>          f - do sync and full, clean build first
#>          h - Display the help package
#>          m - Commit manager only
#>          n - Do not change any files.
#>              NOT USEFUL use "pact-sync -n"
#>          s - Sleep if Lock on
#>          v - Display the Version and Release of the Source Control System
#>          M - Name of file with a message about the commit.  
#>  "message" - Brief message about the commit. Every thing following the
#>              options is included as part of the message. Use quotes to
#>              preserve blanks, special characters.
#>
#> The "message" or at least one option MUST be specified.
#>
####################
# include "cpyright.h"
#

# see PCD for the reason for this
set Here = `pwd` ; cd ; set RealHome = `pwd` ; cd $Here ; unset $Here

if ($?USER == 0) then
   if ($?LOGNAME == 0) then
      set USER = "anonymous"
   else
      set USER = $LOGNAME
   endif
endif

set UserDir   = `pwd | sed "s|$RealHome|$home|"`
set BaseDir   = $UserDir/..
set WhoIAm    = $USER
set Manager   = manager
set Message   = ""
set MsgFile   = ""
set Report    = ""
set CvsOpt    = ""
set ManOnly   = FALSE

set TagID     = `/bin/date '+D%y_%m_%d_%H_%M_%S'`
set TAGing    = ""

set HelpCode  = $UserDir/$0
set CommitLog = $UserDir/commit.log
set UpdateLog = $UserDir/update.log
set Changed   = $UserDir/Changed
set UnChanged = $UserDir/UnChanged
set System    = `./system-id`

set SCSRepository = ""
set SRCDate       = ""
set Sleep         = "NO"

set CleanBuild   = FALSE

switch (`uname -s`)
   case "IRIX":
        set MAIL = Mail
        breaksw

   default:
        set MAIL = mail
        breaksw
endsw

if ($#argv == 0) then
   goto Help
endif


set Opt = "$HelpCode:t  $argv"

while ("$1" =~ -*)
   switch ($1)
      case -f*:
	      set CleanBuild = TRUE
	      breaksw

      case -h*:                                  #print Usage:
	      goto Help

      case -m*:                                  #manager only
              set ManOnly = TRUE
	      breaksw

      case -M*:                                  #get log message from file
              shift
              set MsgFile = $UserDir/$1
              if (! -e $MsgFile ) then
                 echo "Can not find message file $MsgFile"
                 goto Help
              endif
              breaksw

      case -n*:                                  #NO update, report only
	      set Report = " Report ONLY..."
	      set CvsOpt = "-nq"
	      breaksw

      case -s*:
              set Sleep = "YES"
              breaksw

      case -T*:                                  #NO tagging
#	      set TAGing = "FALSE"
	      breaksw

      case -v*:                                  #Display version...
              source $UserDir/pact-scs
	      echo "  Source Version:   " $SCSVersion
	      echo "  Software Release: " $SCSRelease
	      echo ""
	      exit(1)

      default:
 	      goto Help
   endsw
   shift
end
set Message = (\"<$WhoIAm|$TagID> $argv\")

# define the Source Control System
source $UserDir/pact-scs

# do everything with full option
if (($CleanBuild == TRUE) && ($ManOnly == FALSE)) then
   ./pact-sync
   pact remove
   pact build
endif

groups | grep dpact > /dev/null
if ($status == 1) then
   echo ""
   echo "You must be in the PACT developers group to run PACT-COMMIT"
   echo ""
   exit(1)
endif

#
# check if repository is locked
#
if ($Sleep == "YES") then
   ./check.lock
else
   if (-e $SCSLock) then
      echo ""
      echo " *** REPOSITORY IS LOCKED ***"
      echo ""
      cat $SCSLock
      echo ""
      echo ""
      exit(1)
   endif
endif

#
# initiate a lock on the repository
#
touch $SCSLock
echo $Message >>& $SCSLock

#
# run the test suite
#
if ($ManOnly == FALSE) then
   echo -n "Testing ................... "  >>& $SCSLock
   pact test
   if ($status != 0) then
      rm $SCSLock
      echo ""
      echo "Your version failed the test suite"
      echo "All tests must pass before the commit will be allowed"
      echo ""
      exit(1)
   endif
   echo "done"  >>& $SCSLock
endif

rm -f $CommitLog $Changed $UnChanged $UpdateLog

echo "Commit Log		Host: `uname -n` running `uname`" >>&! $CommitLog
echo "User:  $WhoIAm		Date: `date`" >>& $CommitLog
echo " "   >>& $CommitLog
echo "Operation: $Opt "  >>& $CommitLog 
echo " "  >>& $CommitLog

echo " "
if ($ManOnly == TRUE) then
   echo "Committing changes to the Manager only"
   echo "Committing changes to the Manager only" >>& $CommitLog
else
   cd $BaseDir
   echo "Committing source changes"
   echo "Committing source changes" >>& $CommitLog
endif

#
# do the $SCSName update
#
echo " "
echo " " >>& $CommitLog
echo "Checking Local PACT Sources"
echo "Checking Local PACT Sources" >>& $CommitLog
echo -n "Checking PACT Sources ..... "  >>& $SCSLock
echo "Host: `uname -n`           Date: `date`" >>&! $UpdateLog
echo " "  >>& $UpdateLog
($Update >> $UpdateLog) >& /dev/null
if ($status != 0) then
   rm $SCSLock
   echo "$SCSName UPDATE FAILED"
   exit($status)
endif
echo "Local PACT Sources Checked"
echo "done"  >>& $SCSLock

#
# categorize the update status of the files
# as M,A,R - ok to commit and C - resolve conflicts
#
awk '($1 ~ /[MAR]/) {print $2}' $UpdateLog > $UnChanged
awk '($1 == "C") {print $2}' $UpdateLog > $Changed

set ChangedList   = `cat $Changed`
set UnChangedList = `cat $UnChanged`

if ($#ChangedList > 0) then
   rm $SCSLock
   echo ""
   echo "There are files with conflicts to be resolved."
   echo "See $Changed for the list."
   echo ""
   cd $Manager
   exit(1)
else
   rm $Changed
endif

#
# do the actual commit
#
echo " "
echo " " >>& $CommitLog
echo "Committing Local PACT Sources"
echo "Committing Local PACT Sources" >>& $CommitLog
echo -n "Committing PACT Sources ... "  >>& $SCSLock
if ($MsgFile == "" ) then
     echo "$Commit -m $Message" >>& $CommitLog
     eval "$Commit -m $Message" >>& $CommitLog
     if ($status != 0) then
	rm $SCSLock
        echo "Commit FAILED"
        exit(1)
     endif
else
     set tmpMSG = "$UserDir/tmpMSG"
     rm -f $tmpMSG
     echo $Message | sed s/\"//g > $tmpMSG
     cat   $MsgFile >> $tmpMSG
     echo "$Commit -f $tmpMSG" >>& $CommitLog
     eval "$Commit -f $tmpMSG" >>& $CommitLog
     if ($status != 0) then
        rm -f $tmpMSG
	rm $SCSLock
        echo "Commit FAILED"
        exit(1)
     endif
     rm -f $tmpMSG
endif

#
# report on changed files
#
echo " "
echo "   The following files have been updated:"
cat $UnChanged
echo " "

echo "Local PACT Sources Committed"
echo "done"  >>& $SCSLock

if ($ManOnly == TRUE) then
   cd $BaseDir
endif

#
# tag the new repository version
#
echo " "
echo " " >>& $CommitLog
echo "Tagging this version with $TagID"
echo "Tagging this version with $TagID" >>& $CommitLog
echo -n "Tagging ................... "  >>& $SCSLock
echo "$Tag $TagID pact" >>& $CommitLog
eval "$Tag $TagID pact" >>& $CommitLog
echo "Version tagged"
echo "done"  >>& $SCSLock

#
# release the lock
#
echo ""
echo "" >>& $CommitLog
echo "The Repository is Unlocked"
echo "The Repository is Unlocked" >>& $CommitLog
rm $SCSLock

#
# untouch the local source libraries
#
# since CVS has touched the sources
# lets touch the relevant files and keep the time stamps
# properly ordered

if ($ManOnly == FALSE) then
   echo ""
   echo "" >>& $CommitLog
   echo "Resetting time stamps on Local PACT Sources"
   echo "Resetting time stamps on Local PACT Sources" >>& $CommitLog
   find . -name "*.[chf]" -exec touch {} \;
   cd dev/$System/lib
   touch foo.a
   mkdir ftmp
   mv *.a ftmp
   cd ftmp
   foreach lib (*.a)
      if ($lib == "foo.a") then
         rm $lib
      else if ($lib == "libpdb.a") then
         mv $lib ..
      else
         ar x $lib
         rm $lib
         touch *.o
         ar rc $lib *.o
         mv $lib ..
         touch ../$lib
         rm *.o
      endif
   end
   cd ..
   rm -rf ftmp
   touch ../bin/*

# PDB depends on the detect executable so extra
# measures must be taken now
   if (-e libpdb.a) then
      touch ../../../pdb/pdform.h
      ar x libpdb.a
      rm libpdb.a
      touch *.o
      ar rc libpdb.a *.o
      rm *.o
   endif
   echo "Time stamps reset"
endif

cd $UserDir

echo ""
echo "" >>& $CommitLog
echo "PACT Repository Updated"
echo "PACT Repository Updated" >>& $CommitLog
echo "See the file $CommitLog for more detail."
echo ""

exit($status)

Help:
   awk '($1 == "#>") {print}' $HelpCode      #print Usage:
   exit(1)