home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 January / usenetsourcesnewsgroupsinfomagicjanuary1994.iso / sources / unix / volume25 / kit / part01 / install.SH next >
Encoding:
Text File  |  1991-12-18  |  3.7 KB  |  212 lines

  1. case $CONFIG in
  2. '')
  3.     if test ! -f config.sh; then
  4.         ln ../config.sh . || \
  5.         ln ../../config.sh . || \
  6.         ln ../../../config.sh . || \
  7.         (echo "Can't find config.sh."; exit 1)
  8.     fi 2>/dev/null
  9.     . config.sh
  10.     ;;
  11. esac
  12. case "$0" in
  13. */*) cd `expr X$0 : 'X\(.*\)/'` ;;
  14. esac
  15. echo "Extracting install (with variable substitutions)"
  16. $spitshell >install <<!GROK!THIS!
  17. $startsh
  18. # @(#) Installing script accepting bsd-style arguments
  19. # Derived from a script found in the X11R4 distribution.
  20.  
  21. # $Id: install.SH,v 2.0.1.2 91/07/30 17:20:35 ram Exp $
  22. #
  23. # $Log:    install.SH,v $
  24. # Revision 2.0.1.2  91/07/30  17:20:35  ram
  25. # patch6: new install.SH script
  26. # Revision 2.0.1.1  91/05/27  14:20:35  ram
  27. # patch5: mkdir_p is now eval'ed instead of being a function
  28. # patch5: explicitely exit with a zero status when all is done
  29. # Revision 2.0  91/02/19  15:49:42  ram
  30. # Baseline for first official release.
  31.  
  32. chown='$chown'
  33. chmod='$chmod'
  34. chgrp='$chgrp'
  35. rm='$rm'
  36. mv='$mv'
  37. test='$test'
  38. sed='$sed'
  39. !GROK!THIS!
  40. $spitshell >>install <<'!NO!SUBS!'
  41.  
  42. mode=""
  43. dst=""
  44. src=""
  45. dostrip=""
  46. newdir=""
  47. uid=""
  48. gid=""
  49.  
  50. # simulates mkdir -p
  51. mkdir_p='
  52. name=$1;
  53. create='';
  54. while $test $name; do
  55.     if $test ! -d "$name"; then
  56.         create="$name $create";
  57.         name=`echo $name | $sed -e "s|^[^/]*$||"`;
  58.         name=`echo $name | $sed -e "s|\(.*\)/.*|\1|"`;
  59.     else
  60.         name='';
  61.     fi;
  62. done;
  63. for file in $create; do
  64.     mkdir $file && $test $verbose &&
  65.     echo "install: created directory $file" >&2;
  66. done
  67. '
  68.  
  69. verbose=''
  70.  
  71. while $test x$1 != x
  72. do
  73.     case $1 in 
  74.     -c) shift
  75.         continue
  76.         ;;
  77.     -m) mode="$2 "
  78.         shift
  79.         shift
  80.         continue
  81.         ;;
  82.     -o) uid="$2 "
  83.         shift
  84.         shift
  85.         continue
  86.         ;;
  87.     -g) gid="$2 "
  88.         shift
  89.         shift
  90.         continue
  91.         ;;
  92.     -s) dostrip="strip"
  93.         shift
  94.         continue
  95.         ;;
  96.     -d) newdir="$newdir$2 "
  97.         shift
  98.         shift
  99.         continue
  100.         ;;
  101.     -v) verbose='true'
  102.         shift
  103.         ;;
  104.     *) if $test x$src = x
  105.         then
  106.             src=$1
  107.         else
  108.             dst=$1
  109.         fi
  110.         shift
  111.         continue
  112.         ;;
  113.     esac
  114. done
  115.  
  116. # if -d option is used, we have to create the path given
  117. if $test ! x$newdir = x
  118. then
  119.     for i in $newdir
  120.     do
  121.         set x $i
  122.         shift
  123.         eval $mkdir_p
  124.     done
  125.     exit 0        # -d is the only action
  126. fi
  127.  
  128. if $test x$src = x
  129. then
  130.     echo "install: no input file specified" >&2
  131.     exit 1
  132. fi
  133.  
  134. if $test x$dst = x
  135. then
  136.     echo "install: no destination specified" >&2
  137.     exit 1
  138. fi
  139.  
  140. srcbase=`basename $src`
  141. dstbase=`basename $dst`
  142.  
  143. # If the destination is a directory, the target name is srcbase...
  144. if $test -d $dst; then
  145.     dstbase=$srcbase
  146. else
  147.     dst="`echo $dst | sed 's,^\(.*\)/.*$,\1,'`"
  148.     if $test ! -d $dst; then
  149.         dstbase=$dst
  150.         dst="."
  151.     fi
  152. fi
  153.  
  154. # If the src has a directory, extract the dir name...
  155. if $test "$src" != "$srcbase" -a "$src" != "./$srcbase"; then
  156.     src="`echo $src | sed 's,^\(.*\)/.*$,\1,'`"
  157. else
  158.     src="."
  159. fi
  160.  
  161. # dst is the destination directory and dstbase the base name.
  162. # srcbase is the base name of source and src the source dir.
  163.  
  164. srcpth=`(cd $src; pwd)`/$srcbase
  165. destpth=`(cd $dst; pwd)`/$dstbase
  166. if $test x$srcpth = x$destpth; then
  167.     $test $verbose && \
  168.     echo "install: destination and source are identical"
  169.     exit 0
  170. fi
  171.  
  172. # Do the install
  173. (
  174.     cd $src
  175.  
  176.     if $test -f $dst/$dstbase; then
  177.         $rm -f $dst/$dstbase && $test $verbose &&
  178.         echo "install: $dst/$dstbase removed"
  179.     fi
  180.     if $test -f $dst/$dstbase; then
  181.         $mv $dst/$dstbase $dst/OLD$dstbase && $test $verbose &&
  182.         echo "install: $dst/$dstbase renamed as OLD$dstbase"
  183.     fi
  184.  
  185.     cp $srcbase $dst/$dstbase && $test $verbose &&
  186.     echo "install: $srcbase installed as $dst/$dstbase"
  187.  
  188.     if $test ! x$dostrip = x; then
  189.         strip $dst/$dstbase 2>/dev/null && $test $verbose &&
  190.         echo "install: stripped $dst/$dstbase"
  191.     fi
  192.  
  193.     if $test ! x$uid = x; then
  194.         $chown $uid $dst/$dstbase
  195.     fi
  196.     if $test ! x$gid = x; then
  197.         $chgrp $gid $dst/$dstbase
  198.     fi
  199.     if $test ! x$mode = x
  200.     then
  201.         $chmod $mode $dst/$dstbase
  202.     fi
  203. )
  204.  
  205. exit 0
  206. !NO!SUBS!
  207. chmod 755 install
  208. $eunicefix install
  209.