2
0

ttinstall.sh 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. #!/bin/sh
  2. # %% (c) Copyright 1993, 1994 Hewlett-Packard Company
  3. # %% (c) Copyright 1993, 1994 International Business Machines Corp.
  4. # %% (c) Copyright 1993, 1994 Sun Microsystems, Inc.
  5. # %% (c) Copyright 1993, 1994 Novell, Inc.
  6. # %% $XConsortium: ttinstall.sh /main/3 1995/10/20 16:23:17 rswiston $
  7. # @(#)ttinstall.sh 1.10 30 Jul 1993
  8. # Shell script for doing installs.
  9. # The old bsd install did pretty much what we want, but the SYSV install
  10. # doesn't. Hence this shell script which does what we need.
  11. #
  12. # Usage: ttinstall <version> <dest-dir> file...
  13. #
  14. # ttinstall will create dest-dir if needed and copy each named file
  15. # to that directory. If a file's name ends in .so.[0-9] or .so.[0-9][0-9],
  16. # a symlink is created in the destination directory without the version.
  17. # (This breaks if any shared library has a version over 99, but I'm not
  18. # worried.)
  19. # If the file is ELF (binary or shared library), then mcs is used to
  20. # strip the comment and replace it with a short one containing
  21. # the version.
  22. if [ "$RECURSING_ON" != "$0" ]; then
  23. RECURSING_ON="$0"
  24. export RECURSING_ON
  25. exec ksh "$0" "$@"
  26. fi
  27. # HP-UX mkdir -p fails to work if any of the components
  28. # in the name are automounter symlinks... so fake mkdir -p with
  29. # a recursive shell function.
  30. function mkdir_p
  31. {
  32. # if directory names have trailing /, we get called with a null string
  33. if [[ "$1" = "" ]]
  34. then return
  35. fi
  36. # bail out if directory already exists -- this means recursion stops
  37. # as soon as we back up into an existing directory
  38. if [[ -d $1 ]]
  39. then return
  40. fi
  41. # only recurse if path has a slash in it.
  42. case $1 in
  43. */*) mkdir_p ${1%/*}
  44. mkdir $1
  45. ;;
  46. *) mkdir $1
  47. ;;
  48. esac
  49. return
  50. }
  51. version=$1; shift
  52. destdir=$1; shift
  53. datestamp=`date '+%d %h %y'`
  54. if [[ ! -d $destdir ]]
  55. then print -n -u2 Creating directory $destdir ...
  56. rm -f $destdir
  57. mkdir_p $destdir
  58. print done.
  59. fi
  60. while test "$1"
  61. do file="`basename $1`"
  62. print -n -u2 Installing $1 in $destdir ...
  63. rm -f $destdir/${1##*/}
  64. # Try to install by linking, otherwise copy
  65. ln $1 $destdir || cp $1 $destdir
  66. case $1 in
  67. *.so.[0-9]) print -n -u2 adding symlink ...
  68. rm -f $destdir/${file%.[0-9]}
  69. ln -s $file $destdir/${file%.[0-9]}
  70. ;;
  71. *.so.[0-9][0-9]) print -n -u2 adding symlink ...
  72. rm -f $destdir/${file%.[0-9][0-9]}
  73. ln -s $file $destdir/${file%.[0-9][0-9]}
  74. ;;
  75. esac
  76. print -u2 done.
  77. filetype=`file $1`
  78. case $filetype in
  79. *ELF*) print -n -u2 stripping comments ...
  80. mcs -d -a "@(#)ToolTalk $version $datestamp" $destdir/${1##*/}
  81. print -u2 done.
  82. ;;
  83. esac
  84. shift
  85. done