Clone of mesa.
Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

minstall 2.5KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  1. #!/bin/sh
  2. # A minimal replacement for 'install' that supports installing symbolic links.
  3. # Only a limited number of options are supported:
  4. # -d dir Create a directory
  5. # -m mode Sets a file's mode when installing
  6. # If these commands aren't portable, we'll need some "if (arch)" type stuff
  7. SYMLINK="ln -s"
  8. MKDIR="mkdir -p"
  9. RM="rm -f"
  10. MODE=""
  11. if [ "$1" = "-d" ] ; then
  12. # make a directory path
  13. $MKDIR "$2"
  14. exit 0
  15. fi
  16. if [ "$1" = "-m" ] ; then
  17. # set file mode
  18. MODE=$2
  19. shift 2
  20. fi
  21. # install file(s) into destination
  22. if [ $# -ge 2 ] ; then
  23. # Last cmd line arg is the dest dir
  24. for FILE in $@ ; do
  25. DESTDIR="$FILE"
  26. done
  27. # Loop over args, moving them to DEST directory
  28. I=1
  29. for FILE in $@ ; do
  30. if [ $I = $# ] ; then
  31. # stop, don't want to install $DEST into $DEST
  32. exit 0
  33. fi
  34. DEST=$DESTDIR
  35. # On CYGWIN, because DLLs are loaded by the native Win32 loader,
  36. # they are installed in the executable path. Stub libraries used
  37. # only for linking are installed in the library path
  38. case `uname` in
  39. CYGWIN*)
  40. case $FILE in
  41. *.dll)
  42. DEST="$DEST/../bin"
  43. ;;
  44. *)
  45. ;;
  46. esac
  47. ;;
  48. *)
  49. ;;
  50. esac
  51. PWDSAVE=`pwd`
  52. # determine file's type
  53. if [ -h "$FILE" ] ; then
  54. #echo $FILE is a symlink
  55. # Unfortunately, cp -d isn't universal so we have to
  56. # use a work-around.
  57. # Use ls -l to find the target that the link points to
  58. LL=`ls -l "$FILE"`
  59. for L in $LL ; do
  60. TARGET=$L
  61. done
  62. #echo $FILE is a symlink pointing to $TARGET
  63. FILE=`basename "$FILE"`
  64. # Go to $DEST and make the link
  65. cd "$DEST" # pushd
  66. $RM "$FILE"
  67. $SYMLINK "$TARGET" "$FILE"
  68. cd "$PWDSAVE" # popd
  69. elif [ -f "$FILE" ] ; then
  70. #echo "$FILE" is a regular file
  71. # Only copy if the files differ
  72. if ! cmp -s $FILE $DEST/`basename $FILE`; then
  73. $RM "$DEST/`basename $FILE`"
  74. cp "$FILE" "$DEST"
  75. fi
  76. if [ $MODE ] ; then
  77. FILE=`basename "$FILE"`
  78. chmod $MODE "$DEST/$FILE"
  79. fi
  80. else
  81. echo "Unknown type of argument: " "$FILE"
  82. exit 1
  83. fi
  84. I=`expr $I + 1`
  85. done
  86. exit 0
  87. fi
  88. # If we get here, we didn't find anything to do
  89. echo "Usage:"
  90. echo " install -d dir Create named directory"
  91. echo " install [-m mode] file [...] dest Install files in destination"