home *** CD-ROM | disk | FTP | other *** search
/ Skunkware 5 / Skunkware 5.iso / src / X11 / Fresco / build / Unix / config / util / bsdinst.sh < prev    next >
Encoding:
Linux/UNIX/POSIX Shell Script  |  1995-07-12  |  1.9 KB  |  137 lines

  1. #!/bin/sh
  2.  
  3. #
  4. # This accepts bsd-style install arguments and makes the appropriate calls
  5. # to the System V install.
  6. #
  7.  
  8. flags=""
  9. dst=""
  10. src=""
  11. dostrip=""
  12. owner=""
  13. mode=""
  14.  
  15. while [ x$1 != x ]; do
  16.     case $1 in 
  17.     -c) shift
  18.         continue;;
  19.  
  20.     -m) flags="$flags $1 $2 "
  21.         mode="$2"
  22.         shift
  23.         shift
  24.         continue;;
  25.  
  26.     -o) flags="$flags -u $2 "
  27.         owner="$2"
  28.         shift
  29.         shift
  30.         continue;;
  31.  
  32.     -g) flags="$flags $1 $2 "
  33.         shift
  34.         shift
  35.         continue;;
  36.  
  37.     -s) dostrip="strip"
  38.         shift
  39.         continue;;
  40.  
  41.     *)  if [ x$src = x ] 
  42.         then
  43.         src=$1
  44.         else
  45.         dst=$1
  46.         fi
  47.         shift
  48.         continue;;
  49.     esac
  50. done
  51.  
  52. case "$mode" in
  53. "")
  54.     ;;
  55. *)
  56.     case "$owner" in
  57.     "")
  58.         flags="$flags -u root"
  59.         ;;
  60.     esac
  61.     ;;
  62. esac
  63.  
  64. if [ x$src = x ] 
  65. then
  66.     echo "$0:  no input file specified"
  67.     exit 1
  68. fi
  69.  
  70. if [ x$dst = x ] 
  71. then
  72.     echo "$0:  no destination specified"
  73.     exit 1
  74. fi
  75.  
  76.  
  77. # set up some variable to be used later
  78.  
  79. rmcmd=""
  80. srcdir="."
  81.  
  82. # if the destination isn't a directory we'll need to copy it first
  83.  
  84. if [ ! -d $dst ]
  85. then
  86.     dstbase=`basename $dst`
  87.     cp $src /tmp/$dstbase
  88.     rmcmd="rm -f /tmp/$dstbase"
  89.     src=$dstbase
  90.     srcdir=/tmp
  91.     dst="`echo $dst | sed 's,^\(.*\)/.*$,\1,'`"
  92.     if [ x$dst = x ]
  93.     then
  94.         dst="."
  95.     fi
  96. fi
  97.  
  98.  
  99. # If the src file has a directory, copy it to /tmp to make install happy
  100.  
  101. srcbase=`basename $src`
  102.  
  103. if [ "$src" != "$srcbase" -a "$src" != "./$srcbase" ] 
  104. then
  105.     cp $src /tmp/$srcbase
  106.     src=$srcbase
  107.     srcdir=/tmp
  108.     rmcmd="rm -f /tmp/$srcbase"
  109. fi
  110.  
  111. # do the actual install
  112.  
  113. if [ -f /usr/sbin/install ]
  114. then
  115.     installcmd=/usr/sbin/install
  116. elif [ -f /etc/install ]
  117. then
  118.     installcmd=/etc/install
  119. else
  120.     installcmd=install
  121. fi
  122.  
  123. # This rm is commented out because some people want to be able to
  124. # install through symbolic links.  Uncomment it if it offends you.
  125. # rm -f $dst/$srcbase
  126. (cd $srcdir ; $installcmd -f $dst $flags $src)
  127.  
  128. if [ x$dostrip = xstrip ]
  129. then
  130.     strip $dst/$srcbase
  131. fi
  132.  
  133. # and clean up
  134.  
  135. $rmcmd
  136.  
  137.