home *** CD-ROM | disk | FTP | other *** search
/ OpenStep (Enterprise) / OpenStepENTCD.toast / OEDEV / DEV.Z / install < prev    next >
Encoding:
Text File  |  1996-09-08  |  4.2 KB  |  256 lines

  1. #!/bin/sh
  2. umask 022
  3.  
  4. bindir=$NEXT_ROOT/NextDeveloper/Executables/Utilities
  5. cmd="cp"
  6. links=""
  7. quick=""
  8. symlink=""
  9. link="$bindir/ln"
  10. save=0
  11. unlink=""
  12.  
  13. while [ 1 ]
  14. do
  15.     case $1 in
  16.     -s)
  17.         strip="strip"
  18.         shift;;
  19.     -sX)
  20.         echo "BOGUS PDO install option $1"
  21.         strip="strip -x"
  22.         shift;;
  23.     -sx)
  24.         strip="strip -x"
  25.         shift;;
  26.     -sA)
  27.         echo "BOGUS PDO install option $1"
  28.         strip="strip -arch all -A"
  29.         shift;;
  30.     -sS)
  31.         echo "BOGUS PDO install option $1"
  32.         strip="strip -arch all -S"
  33.         shift;;
  34.     -sSd)
  35.         echo "BOGUS PDO install option $1"
  36.         strip="strip -arch all -S -d $2"
  37.         shift
  38.         shift;;
  39.     -sgg)
  40.         echo "BOGUS PDO install option $1"
  41.         strip="strip -arch all -gg"
  42.         shift;;
  43.     -sAn)
  44.         echo "BOGUS PDO install option $1"
  45.         strip="strip -arch all -A -n"
  46.         shift;;
  47.     -r)
  48.         ranlib="ranlib"
  49.         shift;;
  50.     -q)
  51.         quick="quick"
  52.         shift;;
  53.     -c)
  54.         cmd="cp"
  55.         shift;;
  56.     -d)
  57.         cmp="cmp"
  58.         shift;;
  59.     -v)
  60.         vecho="echo"
  61.         shift;;
  62.     -m)
  63.         chmod="$bindir/chmod $2"
  64.         shift
  65.         shift;;
  66.     -o)
  67.         chown="chown -f $2"
  68.         shift
  69.         shift;;
  70.     -g)
  71.         chgrp="chgrp -f $2"
  72.         shift
  73.         shift;;
  74.     -xc)
  75.         cmd="sed"
  76. # sed on NT appears to be unable to handle []'s
  77. #        comments='/^[     ]*#/d'
  78.         comments='//d'
  79.         shift;;
  80.     -xs)
  81.         cmd="sed"
  82. #        comments='/^[     ]*[#:]/d'
  83.         comments='//d'
  84.         shift;;
  85.     -l)
  86.         links="$links $2"
  87.         shift
  88.         shift;;
  89.     -u)
  90.         unlink="$bindir/rm -f"
  91.         shift;;
  92.     -V)
  93.         stamp="$NEXT_ROOT/NextDeveloper/Executables/vers_string -f"
  94.         link="symlink -r -f"
  95.         shift;;
  96. #    -S)
  97.     -save)
  98.         save=1
  99.         shift;;
  100.     *)
  101.         break;;
  102.     esac
  103. done
  104.  
  105. if [ $# -lt 2 ]; then
  106.     echo "install: no destination specified"
  107.     exit 1
  108. fi
  109.  
  110. i=0
  111. argv=""
  112.  
  113. while [ $# -gt 0 ]
  114. do
  115. argv="$argv $1"
  116. dest=$1
  117. shift
  118. i=$(($i+1))
  119. done
  120.  
  121.  
  122. if [ $i -gt 2 ]; then
  123.     if [ ! -d $dest ]; then
  124.         echo "usage: install f1 f2 or f1 f2 ... dir"
  125.         exit 1;
  126.     fi
  127. fi
  128.  
  129. for j in $argv
  130. do
  131.     if [ $j = $dest ]; then 
  132.         break
  133.     fi;
  134.     if [ ! -f $j ]; then
  135.         echo "install: can't open $j"
  136.     fi;
  137.     if [ -d $dest ]; then
  138.         file=$dest/${j:?t}
  139.     else
  140.         file=$dest
  141.     fi;
  142.     if [ -f $file ]; then
  143. #    This won't work on NT since all files have 0 for the i-number
  144. #        if [ `ls -i $file | awk '{print $1}'` = \
  145. #             `ls -i $j | awk '{print $1}'` ]; then
  146. #            echo "install: can't move $j onto itself"
  147. #            exit 1 
  148. #        fi
  149.     fi;
  150.     if [ ! -z $stamp ]; then
  151.         symlink=$file
  152.         file=`$stamp $file`
  153.     fi;
  154.     if [ "$cmd" = "sed" ]; then
  155.         if [ -e $file ]; then
  156.             if [ $save -gt 0 ]; then
  157.                 $bindir/rm -f $file.old
  158.                 if [ ! ` $bindir/mv $file $file.old ` ]; then exit 1; fi;
  159.             fi;
  160.         fi;
  161.         if [ ! -z "$unlink" ]; then
  162.             $unlink $file
  163.         fi;
  164.         if [ ! -z $vecho ]; then
  165.             echo sed -e '<strip comments>' $j ">$file"
  166.         fi
  167.         $bindir/sed -e '1s;^#\!;&;p' -e '2s;^#(@)PROG;&;p' \
  168.             -e '2s;^#PROG;&;p' -e "$comments" $j >$file
  169.     elif [ ! -z $cmp ]; then
  170.         echo -n CMP $j $file
  171.         `$bindir/cmp -s $j $file` 
  172.         if [ $? -eq 0 ]; then
  173.             echo ';'
  174.         else
  175.             if [ -e $file ]; then
  176.                 if [ $save -gt 0 ]; then
  177.                     $bindir/rm -f $file.old
  178.                     `$bindir/mv $file $file.old`
  179.                     if [ $? -gt 0  ]; then exit 1; fi;
  180.                 fi
  181.             fi
  182.             if [ ! -z "$unlink" ]; then
  183.                 $unlink $file
  184.             fi
  185.             echo " THEN" "$cmd "
  186.             `$bindir/$cmd $j $file`
  187.             if [ $? -eq 0  ]; then exit 1; fi;
  188.         fi
  189.     else
  190.         if [ -e $file ]; then
  191.             if [ $save -gt 0 ]; then
  192.                 $bindir/rm -f $file.old
  193.                 `$bindir/mv $file $file.old`
  194.                 if [ $? -gt 0  ]; then exit 1; fi;
  195.             fi
  196.         fi
  197.         if [ ! -z $unlink ]; then
  198.             $unlink $file
  199.         fi
  200.         if [ ! -z $vecho ]; then
  201.             echo $cmd $j $file
  202.         fi
  203.          `$bindir/$cmd $j $file`;
  204.         if [ $? -gt 0 ]; then exit 1; fi;
  205.     fi
  206.  
  207.     if [ ! -z $strip ]; then
  208.         if [ ! -z $vecho ]; then
  209.             echo $strip $file
  210.         fi
  211.         ` $strip $file `
  212.         if [ $? -gt 0  ]; then exit 1; fi;
  213.     fi
  214.     if [ ! -z $ranlib ]; then
  215.         if [ ! -z $vecho ]; then
  216.             echo $ranlib $file
  217.         fi
  218.         ` $ranlib $file `
  219.         if [ $? -gt 0  ]; then exit 1; fi;
  220.     fi
  221.     if [ ! -z "$chmod" ]; then
  222.         if [ ! -z $vecho ]; then
  223.             echo $chmod $file
  224.         fi
  225.         ` $chmod $file `
  226.         if [ $? -gt 0  ]; then exit 1; fi;
  227.     fi
  228.     if [ ! -z $chown ]; then
  229.         if [ ! -z $vecho ]; then
  230.             echo $chown $file
  231.         fi
  232.         ` $chown $file `
  233.         if [ $? -gt 0  ]; then exit 1; fi;
  234.     fi
  235.     if [ ! -z $chgrp ]; then
  236.         if [ ! -z $vecho ]; then
  237.             echo $chgrp $file
  238.         fi
  239.         ` $chgrp $file `
  240.         if [ $? -gt 0  ]; then exit 1; fi;
  241.     fi
  242.  
  243. done
  244.  
  245. for i in $symlink $links 
  246. do
  247.     if [ ! -z $vecho]; then
  248.         echo $link $file $i
  249.     fi
  250.     rm -f $i
  251.     ` $link $file $i ` 
  252.     if [ $? -gt 0 ]; then exit 1; fi;
  253. done
  254.  
  255. exit 0
  256.