home *** CD-ROM | disk | FTP | other *** search
/ Columbia Kermit / kermit.zip / ckscripts / install < prev    next >
Text File  |  2020-01-01  |  5KB  |  140 lines

  1. #!/usr/local/bin/kermit +
  2. ;
  3. ; i n s t a l l
  4. ;
  5. ; Script to install new C-Kermit binaries from a staging area to the
  6. ; kermit/test/bin area at the Kermit website.  For each binary, any old ones
  7. ; are deleted from the target area before moving the new one in because there
  8. ; is not enough room in the target area for all the old ones and all the new
  9. ; ones at the same time.  Runs in UNIX only.  C-Kermit 7.0 Beta.07 required.
  10. ; See the "cleandups" script for an explanation of the filenames, etc.
  11. ;
  12. ; Change the first line to have the path of C-Kermit 7.0 on your computer
  13. ; and give this file execute permission.  Then run this script exactly as if
  14. ; it were a shell script.
  15. ;
  16. ; Author: F. da Cruz, the Kermit Project, Columbia University, May 1999
  17. ;
  18. ; Parameters:
  19. ;  \%1 = Beta number (one or two digits, required)
  20. ;  \%2 = Function: INSTALL or TEST
  21. ;  \%3 = Source directory
  22. ;  \%4 = Target directory (default = /pub/ftp/kermit/test/bin)
  23. ;
  24. local \%b \%e \%f \%j \%k \%l \%m \%n \%x \%y   ; Local scalars
  25. local \&a[] \&b[]                               ; Local arrays
  26. local usage found freed lowest installing count ; Local macros
  27.  
  28. .\%m := \fbasename(\%0)         ; Script name for usage message
  29.  
  30. if LLT \v(version) 700000 exit 1 \%m: C-Kermit 7.0 required
  31. if not equal \v(system) UNIX exit 1 \%m: UNIX required
  32.  
  33. define usage {
  34.     exit 1 Usage: \%m betanumber {INSTALL,TEST} sourcedir targetdir
  35. }
  36. ; Check parameters...
  37. ;
  38. if not def \%1 usage
  39. if not numeric \%1 exit 1 Beta number not numeric
  40. if < \%1 1 exit 1 Beta number not positive
  41. if > \%1 99 exit 1 Beta number more than two digits -- Too many Betas!
  42.  
  43. undef installing                ; Assume TEST - no touching files for real.
  44. if not def \%2 .\%2 = TEST
  45. if match INSTALL \%2* .installing = 1
  46. else if not match TEST \%2* usage
  47.  
  48. ; Get and verify source directory
  49.  
  50. if not def \%3 .\%3 = .         ; Default is current directory
  51. cd \%3
  52. if fail exit 1 Can't cd to "\%3"
  53.  
  54. ; Get and verify destination directory
  55.  
  56. if not def \%4 .\%4 = /pub/ftp/kermit/test/bin
  57. .\%4 := \fpathname(\%4)
  58. if eq \fright(\%4,1) / .\%4 := \fstripx(\%4,/)
  59. if not dir \%4 exit 1 \%4 is not a directory.
  60.  
  61. ; Define constants (note new assignment operators)...
  62.  
  63. .\%e = 196                      ; C-Kermit edit number
  64. .lowest = 2                     ; C-Kermit 7.0.195 Betas started off at 2.
  65. .found = 0
  66. .freed = 0
  67. .count = 0
  68.  
  69. .\%x ::= \%1 - 1                ; Beta number before this one.
  70. .\%b := \flpad(\%1,2,0)         ; Current beta number left-padded with zero.
  71.  
  72. ; Say what will happen...
  73.  
  74. echo Installing binaries for Beta.\%b; lowest = \m(lowest); previous = \%x
  75. if def installing echo \%3: REALLY INSTALLING...
  76. else echo \%3: JUST TESTING and not really installing...
  77.  
  78. ; The following command assigns the list of files that matches the pattern
  79. ; for this Beta version to the array \&a[] and the number of files to \%n.
  80.  
  81. .\%n := \ffiles(ck*\%eb\%b*,&a)
  82. if < \%n 1 exit 1 No files match "ck*\%eb\%b*"
  83. echo Matches: \%n
  84.  
  85. sort a                          ; Sort the file-list array.
  86.  
  87. for \%i 1 \%n 1 {               ; Loop through file list for this beta.
  88.     if exist \%4/\&a[\%i] {
  89.         if not newer \&a[\%i] \%4/\&a[\%i] { ; If target file already exists
  90.             echo [SKIP] \&a[\%i]             ; and it's not older than source
  91.             continue                         ; skip this file.
  92.         }
  93.     }
  94.     for \%j \%x \m(lowest) -1 { ; Search for previous versions of same binary.
  95.         .\%l := \flpad(\%j,2,0)
  96.         .\%f := \%4/\freplace(\&a[\%i],b\%b,b\%l)
  97.         if exist \%f {                       ; Found one
  98.             increment found                  ; Count it
  99.             increment freed \fsize(\%f)      ; Get file size for stats 
  100.             if def installing {              ; If installing
  101.                 delete /verbose \%f          ; delete it verbosely
  102.                 if fail exit 1 FATAL - DELETE \%f
  103.             } else {                         ; Otherwise only listing
  104.                 echo [DELE] \%f              ; Say we would have deleted it
  105.             }
  106.         }
  107.     }
  108.     for \%j \%e-1 193 -1 {               ; Same deal for previous edits
  109.         .\%f := \%4/\freplace(\&a[\%i],\%eb\%b,\%j*)
  110.         .\%y := \ffiles(\%f,&b)
  111.         if = \%y 0 continue
  112.         sort /rev b
  113.         set flag on
  114.         for \%k 1 \%y 1 {
  115.             increment found
  116.             increment freed \fsize(\&b[\%k])
  117.             if def installing {
  118.                 delete /verbose \&b[\%k]
  119.                 if fail exit 1 FATAL - DELETE \&b[\%k]
  120.             } else {
  121.                 echo [DELE] \&b[\%k]
  122.             }            
  123.         }
  124.     }
  125.     if def installing {                      ; If installing
  126.         copy /list \&a[\%i] \%4/\&a[\%i]     ; Install the new binary
  127.         if fail exit 1 FATAL - COPY \&a[\%i]
  128.     } else {                                 ; Otherwise
  129.         echo [COPY] \&a[\%i] => \%4          ; just print a message
  130.     }
  131.     increment count                          ; Count this file
  132. }
  133. undef \%m
  134. if not def installing def \%m (NOT REALLY)
  135. echo Binaries installed: \m(count) \%m
  136. echo Files deleted:      \m(found) \%m
  137. echo Bytes Freed:        \m(freed) \%m
  138.  
  139. exit 0
  140.