File: pact-import

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 (615 lines) | stat: -rwxr-xr-x 17,351 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
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
#!/bin/csh -f
#
# PACT-IMPORT - import PACT sources from another repository
#
# Usage:   pact-import
#
# Modification History:
#   08-12-94 Jan Moura, LLNL:  Tests/corrections; extended trace messages;
#                              added tagging; list source file conflicts;
#                              checkout from repo by import-tag; testing
####################
# include "cpyright.h"
#
set help = FALSE

while ($#argv >= 1)
   switch ($argv[1])
      case -h:
         set help = TRUE
         breaksw
   endsw
   shift
end

if ($help == "TRUE") then
   echo " "
   echo " PACT-IMPORT - import PACT sources from another repository"
   echo " "
   echo "Usage:   pact-import [-h]"
   echo " "
   echo "Options: "
   echo "   -h  Print this message"
   echo " "
   exit(1)
endif

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

unalias cd
set DEBUG = TRUE

set DateFile      = $CVSROOT/.import-date
set TagFile       = $CVSROOT/.import-tag
set LogFile       = $cwd/import.log
set ImportingDir  = $cwd
set SCSDir        = "."
set SCSRepository = ""
set SRCDate       = ""
set HN            = "`uname -n`"
set Message       = (\" $USER on "$HN", Running import.\")


# do an ls to wake up the automounter if one is present
ls $CVSROOT > /dev/null

set Repository = `find $CVSROOT -name manager -print`
#set Repository = `expr $Repository:h : $CVSROOT'\/\(.*\)'`

if (!(-d $Repository)) then
   echo ""
   echo "Non existent repository: $Repository"
   echo ""
   exit(1)
endif

if (!(-e $SCSDir/pact-scs)) then
   echo " "
   echo "Can't find Source Control System Information in $SCSDir"
   echo " "
   exit(1)
endif

# Source Control System Variables
source $SCSDir/pact-scs

#
# check if repository is locked
#
if (-e $SCSLock) then
   echo ""
   echo " *** REPOSITORY IS LOCKED ***"
   echo ""
   cat $SCSLock
   echo ""
   echo ""
   exit(1)
endif

set Source = ""
touch pact-foo.tar.gz
foreach i (pact*tar.gz)
   if ($i != pact-foo.tar.gz) then
      set Source = $i
   else
      rm $i
   endif
end

set Distr = ""
touch pact-foo-src
foreach i (pact*-src)
   if ($i != pact-foo-src) then
      set Distr = $i
   else
      rm $i
   endif
end

echo "Getting new sources ...... "
if ($Source != "") then

   set CodeDate = `expr $Source : 'pact\(.*\).tar.gz'`
   set SrcFile  = "pact$CodeDate.tar.gz"

else if ($Distr != "" ) then
   echo "Distributions must be of the form pact.*.tar.gz"
   exit(1)

   set CodeDate = `expr $Distr : 'pact\(.*\)-src'`
   set SrcFile  = "pact$CodeDate.tar.gz"

   set STDOUT = extr.tmp
   rm -f $STDOUT
   touch $STDOUT

# write the shell script to extract the gzip'd tar file
   echo "#\!/bin/csh -f" >>& $STDOUT
   echo 'set Signature = "-----------------------***   SEPARATOR   ***-----------------------"' >>& $STDOUT
   echo 'while (1)' >>& $STDOUT
   echo '   set Input = "$<"' >>& $STDOUT
   echo '   if ("$Input" == "$Signature") then' >>& $STDOUT
   echo '      set File = "$<"' >>& $STDOUT
   echo '      break' >>& $STDOUT
   echo '   endif' >>& $STDOUT
   echo 'end' >>& $STDOUT
   echo 'if ($?File) then' >>& $STDOUT
   echo '   cat > '$SrcFile >>& $STDOUT
   echo 'endif' >>& $STDOUT
   echo 'exit($status)' >>& $STDOUT

   chmod a+x $STDOUT
   cat $Distr | $STDOUT
   rm $Distr
   rm -f $STDOUT

else

   echo "No sources to import"
   exit(1)

endif

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

rm -f $LogFile
touch $LogFile

echo "Version: $CodeDate Source File: $SrcFile"
echo "Date/Time: " `date`
echo "Version: $CodeDate Source File: $SrcFile" >>& $LogFile
echo "Date/Time: " `date` >>& $LogFile
if (-d import) then
   echo "Removing old import directory"
   echo "Removing old import directory" >>& $LogFile
   rm -rf import >>& $LogFile
endif

echo "Creating import directory"
echo " --------------------------------------------" >>& $LogFile
echo "Creating import directory" >>& $LogFile
mkdir import

echo "Moving new sources into import directory"
echo "Moving new sources into import directory" >>& $LogFile
mv $SrcFile import/pact.tar.gz >>& $LogFile

if (-e $DateFile) then
   set ImportDate = `cat $DateFile`
endif

if (-e $TagFile) then
   set ImportTag = `cat $TagFile`
endif

cd import

echo "Uncompressing new sources"
echo " --------------------------------------------" >>& $LogFile
echo "Uncompressing new sources" >>& $LogFile
gzip -d pact.tar.gz >>& $LogFile
if ($status != 0) then
   echo "Uncompress failed, check tar file in manager/import"
   echo "Entering inferior shell to correct tar file"
   echo "Type exit at the prompt to resume"
   set here = $cwd
   csh -f
   echo ""
   cd $here
endif
echo "" >>& $LogFile

echo "Backing up the repository to pact/manager/import/repos.tar.gz"
echo "Backing up the repository to pact/manager/import/repos.tar.gz" >>& $LogFile
tar cvf - $CVSROOT | gzip > repos.tar.gz
echo "" >>& $LogFile

if ($?ImportDate) then

   mkdir new

# we are in the import/new directory now
   cd new

   mv ../pact.tar .

   echo -n "Unpacking new sources ...... "  >>& $SCSLock
   echo "Unpacking new sources"
   echo "Current Directory:  " `pwd` 
   echo "------------------------------------------------------------------------------" >>& $LogFile
   echo "" >>& $LogFile
   echo "Unpacking new sources" >>& $LogFile
   echo "Current Directory:  " `pwd` >>& $LogFile
   echo "" >>& $LogFile
   echo "------------------------------------------------------------------------------" >>& $LogFile
   tar xvf pact.tar >>& $LogFile
   if ($status != 0) then
      echo "TAR extract failed, check sources in manager/import"
      echo "Entering inferior shell to correct sources"
      echo "Type exit at the prompt to resume"
      set here = $cwd
      csh -f
      echo ""
      cd $here
   endif
   echo "" >>& $LogFile
   echo "done"  >>& $SCSLock

   cd ..
   mkdir old

# we are in the import/old directory now
   cd old
   set Repository = $Repository:h
   echo -n "Checking out old sources ... "  >>& $SCSLock
   echo "Checking out sources from $Repository"
   echo "Current Directory:  " `pwd` 
   echo "cvs co -r $ImportTag pact" 
   echo "------------------------------------------------------------------------------" >>& $LogFile
   echo "" >>& $LogFile
   echo "Checking out sources from $Repository" >>& $LogFile
   echo "Current Directory:  " `pwd` >>& $LogFile
   echo "cvs co -r $ImportTag pact" >>& $LogFile
   echo "" >>& $LogFile
   echo "------------------------------------------------------------------------------" >>& $LogFile
   echo "" >>& $LogFile
   cvs co -r "$ImportTag" pact >>& $LogFile
   echo "done"  >>& $SCSLock

# rename the old files to *.old
   echo -n "Processing old sources ..... "  >>& $SCSLock
   echo "Processing old sources"
   echo "" >>& $LogFile
   echo "Processing old sources" >>& $LogFile
   rm -f tmp tmp.lst
   touch tmp
   echo "#\!/bin/csh -f" >> tmp
   echo 'while (1)' >> tmp
   echo '   set x = $<' >> tmp
   echo '   if (($#x < 1) || ($x == "")) then' >> tmp
   echo '      exit(0)' >> tmp
   echo '   endif' >> tmp
   echo '   if (!(-d "$x")) then' >> tmp
   echo '      mv $x $x.old' >> tmp
   echo '      touch $x.chk' >> tmp
   echo '   endif' >> tmp
   echo 'end' >> tmp
   chmod a+x tmp

#   echo "" >>& $LogFile
#   echo "The shell script to process the old sources:" >>& $LogFile
#   echo "" >>& $LogFile
#   cat tmp >>& $LogFile
#   echo "" >>& $LogFile

   cd pact
   echo "done"  >>& $SCSLock

# we are in the import/old/pact directory now
   find . -name CVS -prune -o -print > ../tmp.lst
   cat ../tmp.lst | ../tmp
   cd ..

# we are in the import/old directory now
   rm -f tmp tmp.lst
   echo "" >>& $LogFile


# eliminate old directories with no new counterparts
# saves making repository changes erroneously
   echo "Adjusting the directory tree"
   echo "Current Directory:  " `pwd` 
   echo "------------------------------------------------------------------------------" >>& $LogFile
   echo "" >>& $LogFile
   echo "Adjusting the directory tree" >>& $LogFile
   echo "Current Directory:  " `pwd` >>& $LogFile
   echo "" >>& $LogFile
   echo "------------------------------------------------------------------------------" >>& $LogFile
   rm -f tmp
   touch tmp
   echo "#\!/bin/csh -f" >> tmp
   echo 'while (1)' >> tmp
   echo '   set x = $<' >> tmp
   echo '   if ($x == ".") then' >> tmp
   echo '      exit(0)' >> tmp
   echo '   endif' >> tmp
   echo '   echo "   $x"' >> tmp
   echo '   if ((-d $x) && !(-d ../../new/pact/$x)) then' >> tmp
   echo '      rm -rf $x' >> tmp
   echo '      echo "      There is no $x directory in the new sources to import"' >> tmp
   echo '   endif' >> tmp
   echo 'end' >> tmp
   chmod a+x tmp

#   echo "" >>& $LogFile
#   echo "The shell script to prune directories:" >>& $LogFile
#   echo "" >>& $LogFile
#   cat tmp >>& $LogFile
#   echo "" >>& $LogFile

   cd pact

# we are in the import/old/pact directory now
# list all the directories of this tree sorted from most nested to least
# then blow them away if they have no counterpart in the other tree
   find . -type d \! -name CVS -print | sort -r | sed s'|\.\/||' > ../tmp.lst
   cat ../tmp.lst | ../tmp
   cd ..

# we are in the import/old directory now
   rm -f tmp tmp.lst
   echo "" >>& $LogFile

   cd ../new
# we are in the import/new directory now

# move the new files to the old directories as *.new
   echo -n "Processing new sources ..... "  >>& $SCSLock
   echo "Processing new sources"
   echo "" >>& $LogFile
   echo "Processing new sources" >>& $LogFile
   rm -f tmp
   touch tmp
   echo "#\!/bin/csh -f" >> tmp
   echo 'if (!(-d $1)) then' >> tmp
   echo '   mv $1 ../../old/pact/$1.new' >> tmp
   echo '   touch ../../old/pact/$1.chk' >> tmp
   echo 'endif' >> tmp
   chmod a+x tmp

#   echo "" >>& $LogFile
#   echo "The shell script to process the new sources:" >>& $LogFile
#   echo "" >>& $LogFile
#   cat tmp >>& $LogFile
#   echo "" >>& $LogFile

   cd pact
   echo "done"  >>& $SCSLock

# we are in the import/new/pact directory now

   find . -exec ../tmp {} \; >>& $LogFile
   cd ..

# we are in the import/new directory now
   rm -f tmp
   echo "" >>& $LogFile

   cd ../old
# we are in the import/old directory now

# reconcile things
   echo -n "Reconciling sources ........ "  >>& $SCSLock
   echo "Reconciling sources"
   echo "Current Directory:  " `pwd`
   echo "------------------------------------------------------------------------------" >>& $LogFile
   echo "" >>& $LogFile
   echo "Reconciling sources" >>& $LogFile
   echo "Current Directory:  " `pwd` >>& $LogFile
   echo "" >>& $LogFile
   echo "------------------------------------------------------------------------------" >>& $LogFile
   rm -f tmp
   touch tmp
   echo "#\!/bin/csh -f" >> tmp
   echo 'set Base    = $1:r' >> tmp
   echo 'set BaseDir = $Base:h' >> tmp
   echo 'set File    = $Base:t' >> tmp
   echo 'set Here    = $cwd' >> tmp
   echo 'if ((-e $Base.new) && (-e $Base.old)) then' >> tmp
   echo '   cp $Base.new $Base' >> tmp
   echo 'else if (-e $Base.new) then' >> tmp
   echo '   cp $Base.new $Base' >> tmp
   echo '   cd $BaseDir' >> tmp
   echo '   cvs add $File' >> tmp
   echo '   cd $Here' >> tmp
   echo 'else if (-e $Base.old) then' >> tmp
   echo '   cd $BaseDir' >> tmp
   echo '   cvs update -A $File' >> tmp
   echo '   rm $File' >>  tmp
   echo '   cvs remove $File' >> tmp
   echo '   cd $Here' >> tmp
   echo 'endif' >> tmp
   echo 'rm $1' >> tmp
   chmod a+x tmp

#   echo "" >>& $LogFile
#   echo "The shell script to reconcile sources:" >>& $LogFile
#   echo "" >>& $LogFile
#   cat tmp >>& $LogFile
#   echo "" >>& $LogFile

   cd pact
   echo "done"  >>& $SCSLock

# we are in the import/old/pact directory now

   echo  Find nnn.CHK from `pwd` >>& $LogFile
   find . \( -name "*.chk" -o -name ".*.chk" \) -exec ../tmp {} \; >>& $LogFile
   echo  Find nnn.NEW from `pwd` >>& $LogFile
   find . \( -name "*.new" -o -name ".*.new" \) -exec rm {} \; >>& $LogFile
   echo  Find nnn.OLD from `pwd` >>& $LogFile
   find . \( -name "*.old" -o -name ".*.old" \) -exec rm {} \; >>& $LogFile
   cd ..

# we are in the import/old directory now
   rm -f tmp
   echo "" >>& $LogFile

   echo -n "Updating the sources ....... "  >>& $SCSLock
   echo "Updating the new source"
   echo "Current Directory:  " `pwd` 
   echo "------------------------------------------------------------------------------" >>& $LogFile
   echo "" >>& $LogFile
   echo "Updating the new source" >>& $LogFile
   echo "Current Directory:  " `pwd` >>& $LogFile
   echo "" >>& $LogFile
   echo "------------------------------------------------------------------------------" >>& $LogFile
   rm -f tmp Update.list
   touch tmp
   cvs update -A >>& tmp
   cat tmp >>& $LogFile
   awk '($1 ~ /^[UCMAR]$/) {print $1 "   " $2}' tmp >& Update.list
   if (-z Update.list ) then
      echo "UPDATE failed, NOTHING to update, Update.list is empty"
      echo "check sources in manager/import"
      echo "Entering inferior shell to correct sources"
      echo "Type exit at the prompt to resume"
      set here = $cwd
      csh -f
      echo ""
      cd $here
   endif
   echo "" >>& $LogFile

   set CONFS = "NO"
   grep "C " Update.list >& /dev/null
   if ($status == 0 ) then
      set CONFS = "YES"
      echo ""
      echo " *** UPDATE SOURCE CONFLICTS. ***"
      grep "C " Update.list
      echo "Entering DEBUG mode to correct sources"
   endif
   echo "done"  >>& $SCSLock

   if ($DEBUG == TRUE) then
      echo ""
      if ($CONFS == "YES") then
         echo "CONFLICT mode:"
         echo "   ** Open new logon window **"
         echo "   FIRST correct conflicting sources,"
         echo "   THEN check file Update.list in"
      else
         echo "CHECK mode:"
         echo "   ** Open new logon window **"
         echo "   Check file Update.list in"
      endif
      echo " manager/import/old to verify the files to commit"
      echo ""
      echo "Entering inferior shell for ACTION. When ready,"
      echo "type exit at the prompt to COMMIT sources."
      set here = $cwd
      csh -f
      echo ""
      cd $here
   endif
 
   rm -f tmp 
   echo "" >>& $LogFile

   echo -n "Committing the sources ..... "  >>& $SCSLock
   echo "Committing the new source"
   echo "Current Directory:  " `pwd`
   echo "cvs commit -m ***** Import from $CodeDate *****" 
   echo "------------------------------------------------------------------------------" >>& $LogFile
   echo "" >>& $LogFile
   echo "Committing the new source" >>& $LogFile
   echo "Current Directory:  " `pwd` >>& $LogFile
   echo "cvs commit -m ***** Import from $CodeDate *****" >>& $LogFile
   echo "" >>& $LogFile
   echo "------------------------------------------------------------------------------" >>& $LogFile
   echo "cvs commit -m Import from $CodeDate" >>& $LogFile
   cvs commit -m "***** Import from $CodeDate *****" >>& $LogFile
   set Error = $status
   if ($Error != 0) then
      echo "Error status = " $Error
      echo "COMMIT failed, check sources in manager/import"
      echo "Entering inferior shell to correct sources"
      echo "Type exit at the prompt to resume"
      set here = $cwd
      csh -f
      echo ""
      cd $here
   endif
   echo "" >>& $LogFile
   echo "done"  >>& $SCSLock

   set TagID     = `/bin/date '+X%y_%m_%d_%H_%M_%S'`
   echo " "
   echo -n "Tagging the sources ........ "  >>& $SCSLock
   echo "Tagging this version with $TagID"
   echo "------------------------------------------------------------------------------" >>& $LogFile
   echo "" >>& $LogFile
   echo "Tagging this version with $TagID" >>& $LogFile
   echo "Current Directory:  " `pwd` >>& $LogFile
   echo "" >>& $LogFile
   echo "------------------------------------------------------------------------------" >>& $LogFile
   echo "" >>& $LogFile

   echo "cvs rtag $TagID pact" >>& $LogFile
   cvs rtag $TagID pact >>& $LogFile
   echo "done"  >>& $SCSLock


else

   echo "Unpacking new sources"
   echo "Unpacking new sources" >>& $LogFile
   tar xvf pact.tar  >>& $LogFile
   if ($status != 0) then
      echo "TAR extract failed, check sources in manager/import"
      exit(1)
   endif

   cd pact

   echo "Importing sources from $cwd into $Repository"
   echo "Importing sources from $cwd into $Repository" >>& $LogFile
   cvs import -m "Import from $CodeDate" $Repository v$CodeDate r$CodeDate >>& $LogFile
   if ($status != 0) then
      echo "IMPORT failed, check sources in manager/import"
      exit(1)
   endif

   cd ../../..

   echo "Merging sources"
   echo "Merging sources" >>& $LogFile

   cvs update -jv$CodeDate:yesterday -jv$CodeDate >>& $LogFile
   if ($status != 0) then
      echo "MERGE failed, check sources in manager/import"
      exit(1)
   endif

   cd manager

endif


cd $ImportingDir

rm -f $DateFile $TagFile
echo `date '+%D %T '` "PDT" > $DateFile
echo "$TagID" > $TagFile

echo "Cleaning up the import directory"
echo "Cleaning up the import directory" >>& $SCSLock
echo "Cleaning up the import directory" >>& $LogFile
rm -rf import >>& $LogFile

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

echo ""
echo "Version $CodeDate imported"
echo "Date/Time: " `date`
echo "Version $CodeDate imported" >>& $LogFile
echo "Date/Time: " `date` >>& $LogFile

exit(0)