File: pact-update

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 (559 lines) | stat: -rwxr-xr-x 16,692 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
#!/bin/csh
#
# PACT-UPDATE - update/install the PACT distribution system on this machine
# (PACT-SRC)    Some of the complexity of this process stems from the fact
#               that there are several ways of obtaining the source:
#                -  from a CVS repository
#                -  from an anonymous FTP node as a distribution tar file
#                -  from an executable PACT distribution file. PACT-SRC
#               and that the other parts of the manager interlock with
#               this script
#
# Usage: (see the help package below)
#
####################
# Source Version: 2.0
# Software Release #92-0043
#
# include "cpyright.h"
#
  goto Begin

#................................................... help package
HelpPackage:
  echo ""
  echo "Purpose:"
  echo "     update/install the PACT distribution system on this machine"
  echo "     (also runs as first part of a PACT-SRC file)"
  echo ""
  echo "Usage:"
  echo "       pact-update [-b <mail-dest>] [-c] [-f <directory>]"
  echo "                   [-i <directory>] [-k]"
  echo "                   [+-n <host>] | [-s] | [-t <tar-file>]"
  echo "                   <config>"
  echo "       pact-update -h | -v"
  echo ""
  echo "Options:"
  echo "       -b          - mail destination for background compilation"
  echo "       -c          - stop after configuring the distribution"
  echo "       -f          - get configuration file from named directory"
  echo "       -i          - base installation directory (default /usr/local)"
  echo "       -k          - keep existing PACT distribution, ie. keep 'pact/'"
  echo "                     in directory where new distribution being built"
  echo "          -- specify origin of source --                            "
  echo "       -n          - get the PACT source from the specified host   "
  echo "                   - via anonymous FTP without the documentation   "
  echo "       +n          - get the PACT source from the specified host   "
  echo "                   - via anonymous FTP with the documenation       "
  echo "       -s          - sources are out and only need to be configured"
  echo "                     (default for command pact-update)             "
  echo "       NOTE: default for command pact-src is to extract compressed tar"
  echo "                     file from end of pact-src script.             "
  echo "       -t          - compressed or uncompressed tar file, example  "
  echo "                     for pact.tar.gz type:   -t pact.tar            "
  echo ""
  echo "       <config>    - system to configure the installation for"
  echo "                     (auto = detects the system configuration)"
#  echo "                       aix        IBM RS6000 systems"
#  echo "                       hp         HP RISC 700 systems"
#  echo "                       irix       SGI IRIX systems"
#  echo "                       irixg      SGI IRIX systems with GCC"
#  echo "                       irix64     SGI IRIX 6.x systems"
#  echo "                       linux      LINUX systems"
#  echo "                       meiko      MEIKO solaris systems"
#  echo "                       mips       MIPS OS systems"
#  echo "                       osf        OSF systems"
#  echo "                       osfg       OSF systems with GCC"
#  echo "                       paragon    Intel Paragon systems running OSF1"
#  echo "                       solaris    Sun Solaris systems"
#  echo "                       sun        standard Sun systems"
#  echo "                       sung       Sun systems with GCC"
#  echo "                       sunmos     Intel Paragon systems running SUNMOS"
#  echo "                       t3d        CRAY t3d systems"
#  echo "                       ultrix     DEC ULTRIX systems"
#  echo "                       unicos     CRAY UNICOS systems"
  echo ""      
  echo "       -h          - print this help package"
  echo "       -v          - only print the PACT Version (No update)"
  echo ""
  exit(1)

#---------------------------------- Execution Entry 
Begin:

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

# don't assume the umask is reasonable - set it for PACT's needs
umask 002

unalias cd

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

set Base       = `pwd | sed "s|$RealHome|$home|"`
set LogFile    = $Base/Build.Log
set KEEP       = FALSE
set BACKGR     = FALSE
set HELP       = FALSE
set SaveDocs   = FALSE
set Manager    = manager
set ConfigDir  = ""
set ConfigOnly = FALSE
set Host       = ""
set MailAddr   = $USER
set Nodename   = `hostname`
set Pattern    = 'pact.README pact*-src pact*.tar.gz'
set InstArg    = ""
set WhoIAm     = $USER

set Name = $0
set Name = $Name:t

if ($Name == "pact-update") then
   set SrcMode   = "cvs"
else
   set SrcMode   = "self"
endif

# Source Control System variables
set CheckOut  = "cvs co"
set ADM       = "CVS"

# --------------------------------------------------------------------------

#                       HANDLE COMMAND LINE ARGUMENTS

# --------------------------------------------------------------------------
set Opt = "$Name  $argv"

if ($#argv < 1) then
   set HELP = TRUE
else if ("$1" == "-h" || "$1" == "-help" ||"$1" == "help") then
   set HELP = TRUE
endif
if ("$1" == "-v") then
   if (-e ../score/score.h) then
      set Vers = `grep "define VERSION" ../score/score.h`
      if ($#Vers > 0) then
         echo "PACT Version:" $Vers[4]
      endif
   else
      echo "Version unknown"
   endif
   exit(0)
endif

while ("$1" =~ -*)
   switch ($1)
      case -b:
               shift
               set BACKGR = TRUE
               set MailAddr = $1
               breaksw
      case -c:
               set ConfigOnly = TRUE
               breaksw
      case -f:
               shift
               set ConfigDir = $1
               breaksw
      case -i:
               shift
               set InstArg = "-i $1"
               breaksw
      case -k:
               set KEEP = TRUE
               breaksw
      case +n:
               set SaveDocs = TRUE
      case -n:
               shift
               set Host    = $1
               set SrcMode = "net"
               breaksw
      case -s:
               set SrcMode = "source"
               set KEEP = TRUE
               breaksw
      case -t:
               shift
               set TarFile = $1
               set SrcMode = "tar"
               breaksw
   endsw
   shift
end

if ($#argv < 1 || $HELP == "TRUE" ) then
   goto HelpPackage
endif

set Configuration = $1

unalias cd

rm -f $LogFile
touch $LogFile
echo "Operation:  $Opt "          >>& $LogFile
echo "Update PACT installation on $Nodename" >>& $LogFile
echo ""				  >>& $LogFile
echo "Update Log		Host: `uname -n` running `uname`" >>&! $LogFile
echo "User: $WhoIAm		Date: `date`" >>& $LogFile
echo ""				  >>& $LogFile
echo ""				  >>& $LogFile

# --------------------------------------------------------------------------

#                                 OBTAIN SOURCES

# --------------------------------------------------------------------------

switch ($SrcMode)

# sources are out and ready
   case source:
        breaksw

# cvs repository based update
   case cvs:
        groups | grep dpact > /dev/null
        if ($status == 1) then
           echo ""
           echo "You must be in the PACT developers group to access the repository"
           echo ""
           exit(1)
        endif
        breaksw

# anonymous ftp based update
   case net:
        echo "Getting the PACT sources from $Host"
        echo "Getting the PACT sources from $Host" >>& $LogFile

# echo the FTP command into the log
        echo "" >>& $LogFile
        echo "FTP Commands for Update" >>& $LogFile
        (echo "   open $Host" ; \
         echo "   user anonymous password $USER@$Nodename" ; \
         echo "   prompt" ; \
         echo "   bin" ; \
         echo "   cd pub" ; \
         echo "   mget $Pattern" ; \
         echo "   quit" ) >>& $LogFile
        echo "" >>& $LogFile

# do the transfer
        (echo "open $Host" ; \
         echo "user anonymous password $USER@$Nodename" ; \
         echo "prompt" ; \
         echo "bin" ; \
         echo "cd pub" ; \
         echo "mget $Pattern" ; \
         echo "quit" ) | ftp -n >>& $LogFile

        touch pact-foo-doc.tar.gz >>& $LogFile
        if ($SaveDocs == TRUE) then
           foreach i (pact*-doc.tar.gz)
              if ($i == pact-foo-doc.tar.gz) then
                 rm $i >>& $LogFile
              else
                 gzip -d $i >>& $LogFile
              endif
           end
        else
           rm -f pact*-doc.tar.gz >>& $LogFile
        endif

        set Name = ""
        touch pact-foo-src >>& $LogFile
        foreach i (pact*-src)
          if ($i != pact-foo-src) then
             set Name = $i >>& $LogFile
          else
             rm $i >>& $LogFile
          endif
        end
        if ($Name == "") then
           echo "FTP failed to find PACT sources on $Host" >>& $LogFile
           exit(1)
        endif

        if (-e pact/manager/.pact-date) then
           set OldDate = `cat pact/manager/.pact-date`
           set NewDate = $Name
           pact/manager/compare-date $NewDate $OldDate >>& $LogFile
           switch ($status)
              case 1:
                     echo "Local PACT distribution is out of date"
                     echo "Local PACT distribution is out of date" >>& $LogFile
                     breaksw
              case 0:
              case -1:
                     echo "Local PACT distribution is up to date"
                     echo "Local PACT distribution is up to date" >>& $LogFile
                     rm -f pact*.tar*
                     exit(0)
                     breaksw
           endsw
        endif

# self extraction update
   case self:
        set STDOUT = extr.tmp
        rm -f $STDOUT
        touch $STDOUT

# write the shell script to extract the compressed 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 '   set File = $File:t' >>& $STDOUT
        echo '   echo $File' >>& $STDOUT
        echo '   cat > $File' >>& $STDOUT
        echo 'endif' >>& $STDOUT
        echo 'exit($status)' >>& $STDOUT

        chmod a+x $STDOUT

# extract the tar file
        set TarFile = `cat ./$Name | ./$STDOUT`
        set TarFile = $TarFile:r
        set SrcMode = "tar"

        rm -f $STDOUT
        breaksw

# error
   default:
        echo ""
        echo "I have no idea how to do an update without a tar file, a"
        echo "CVS repository, or a network node."
        echo ""
        exit(1)
        breaksw
endsw

# --------------------------------------------------------------------------

#                                 SETUP SOURCES

# --------------------------------------------------------------------------

if ($KEEP == "FALSE") then
   if (-d pact) then
      echo "Removing old PACT files"
      echo "Removing old PACT files" >>& $LogFile
      rm -r pact
   endif
endif

switch ($SrcMode)
   case tar:
        echo "Unpacking the PACT sources"
        echo "Unpacking the PACT sources" >>& $LogFile

        if (-e $TarFile.gz) then
           gzip -d $TarFile.gz
        endif
	if (-e $TarFile.Z) then
	   uncompress $TarFile.Z
	endif

# determine whether local tar supports o option
        set TarArgs = xvmof
        mkdir futmp
        cd futmp >>& /dev/null
        echo "foo" > file.tmp
        tar cvf tmp.tar file.tmp >>& /dev/null
        tar $TarArgs tmp.tar >>& /dev/null
        if ($status != 0) then
           set TarArgs = xvmf
        endif
        cd .. >>& /dev/null
        rm -r futmp

        tar $TarArgs $TarFile >>& $LogFile
        if ($status != 0) then
           echo ""
           echo "  ERROR: TAR failed"
           echo "" >>& $LogFile
           echo "  ERROR: TAR failed" >>& $LogFile
           echo ""
           exit($status)
        endif

        cd pact

        echo "PACT sources unpacked"
        echo "PACT sources unpacked" >>& $LogFile
        breaksw

   case source:
        cd pact
        breaksw

   default:

        echo "Checking out the PACT Sources"
        echo "Checking out the PACT Sources" >>& $LogFile

        $CheckOut pact >>& $LogFile
        if ($status != 0) then
           echo ""
           echo "  ERROR: Source Control System failed"
           echo "" >>& $LogFile
           echo "  ERROR: Source Control System failed" >>& $LogFile
           echo ""
           exit($status)
        endif

# delete an unnecessary directory layer */
        mv pact/* .
        rmdir pact

# remove the $SCSName sub-directories
        echo "Removing Source Control Information"
        echo "Removing Source Control Information" >>& $LogFile
        set List = `find . -name $ADM -print`
        foreach i ($List)
           rm -r $i
        end

        echo "PACT sources checked out"
        echo "PACT sources checked out" >>& $LogFile
        breaksw
endsw

echo "Current directory after source setup $cwd" >>& $LogFile

# --------------------------------------------------------------------------

#                              CONFIGURE DISTRIBUTION

# --------------------------------------------------------------------------

if ($ConfigDir != "") then
   set Configure = "-f $ConfigDir"
else
   set Configure = ""
endif

echo "Changing to manager directory: $Manager"
echo "Changing to manager directory: $Manager" >>& $LogFile
cd $Manager >>& /dev/null

set System    = `./system-id`
set EnvFile   = "env-$System"

echo "Configuring PACT for $Configuration"
echo "Configuring PACT for $Configuration" >>& $LogFile
if ($Configuration == "auto") then
   ./pact-config -n $InstArg >>& $LogFile
   set xstatus = $status
else
   ./pact-config $InstArg $Configure $Configuration >>& $LogFile
   set xstatus = $status
endif

if ($xstatus != 0) then
   echo ""
   echo "  ERROR: PACT-CONFIG failed"
   echo "" >>& $LogFile
   echo "  ERROR: PACT-CONFIG failed" >>& $LogFile
   echo ""
   exit($xstatus)
endif

if ($ConfigOnly == TRUE) then
   exit(0)
endif

echo "Sourcing environment file $EnvFile for $System"
echo "Sourcing environment file $EnvFile for $System" >>& $LogFile
if (-e $EnvFile) then
   source $EnvFile
   rehash
else
   echo ""
   echo "  ERROR: bad environment file"
   echo ""
   echo "" >>& $LogFile
   echo "  ERROR: bad environment file" >>& $LogFile
   echo "" >>& $LogFile
   exit(1)
endif

# --------------------------------------------------------------------------

#                               COMPILE DISTRIBUTION

# --------------------------------------------------------------------------

echo "Compiling the PACT distribution"
echo "Compiling the PACT distribution" >>& $LogFile

##########set DName = ("pact"`./code-date -u -f ymd`"-src")
set DName = `cat ./.pact-date`

if ($BACKGR == "FALSE") then

   pact update >>& $LogFile
   set upresult = $status
   echo "Host: `uname -n`" >>& $LogFile
   echo "Date: `date`" >>& $LogFile

   if ($upresult != 0) then
      echo ""
      echo "  ERROR: Make PACT failed"
      echo "" >>& $LogFile
      echo "  ERROR: Make PACT failed" >>& $LogFile
      echo ""
      echo "See the log file:  $LogFile"
      exit($status)
   endif

   tail -8 $LogFile
   echo "Compilation complete"
   echo "Compilation complete" >>& $LogFile

   rm -f .pact-date
   echo $DName 
   echo $DName > .pact-date
   echo $DName >>& $LogFile
   mv $LogFile ../../$Nodename.BUILD
   echo "See the log file " ../../$Nodename.BUILD

else
   echo "   Backgrounding the compilation, will advise via mail"
   echo "   Backgrounding the compilation, will advise via mail" >>& $LogFile
   (pact update >>& $LogFile ; \
    echo "Host: `uname -n`" >>& $LogFile ; \
    echo "Date: `date`" >>& $LogFile ; \
    rm -f .pact-date ; \
    echo $DName > .pact-date ; \
    tail -60 $LogFile | mail $MailAddr ; \
    mv $LogFile ../../$Nodename.BUILD) &
   nohup
endif

# --------------------------------------------------------------------------
# --------------------------------------------------------------------------

cd $Base >>& /dev/null
echo ""

exit($status)