bsdinst.sh 1.9 KB

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