| OLD | NEW |
| 1 #! /bin/sh | 1 #!/bin/sh |
| 2 # | 2 # |
| 3 # install - install a program, script, or datafile | 3 # install - install a program, script, or datafile |
| 4 # This comes from X11R5. | 4 # This comes from X11R5 (mit/util/scripts/install.sh). |
| 5 # |
| 6 # Copyright 1991 by the Massachusetts Institute of Technology |
| 7 # |
| 8 # Permission to use, copy, modify, distribute, and sell this software and its |
| 9 # documentation for any purpose is hereby granted without fee, provided that |
| 10 # the above copyright notice appear in all copies and that both that |
| 11 # copyright notice and this permission notice appear in supporting |
| 12 # documentation, and that the name of M.I.T. not be used in advertising or |
| 13 # publicity pertaining to distribution of the software without specific, |
| 14 # written prior permission. M.I.T. makes no representations about the |
| 15 # suitability of this software for any purpose. It is provided "as is" |
| 16 # without express or implied warranty. |
| 5 # | 17 # |
| 6 # Calling this script install-sh is preferred over install.sh, to prevent | 18 # Calling this script install-sh is preferred over install.sh, to prevent |
| 7 # `make' implicit rules from creating a file called install from it | 19 # `make' implicit rules from creating a file called install from it |
| 8 # when there is no Makefile. | 20 # when there is no Makefile. |
| 9 # | 21 # |
| 10 # This script is compatible with the BSD install script, but was written | 22 # This script is compatible with the BSD install script, but was written |
| 11 # from scratch. | 23 # from scratch. It can only install one file at a time, a restriction |
| 12 # | 24 # shared with many OS's install programs. |
| 13 | 25 |
| 14 | 26 |
| 15 # set DOITPROG to echo to test this script | 27 # set DOITPROG to echo to test this script |
| 16 | 28 |
| 17 # Don't use :- since 4.3BSD and earlier shells don't like it. | 29 # Don't use :- since 4.3BSD and earlier shells don't like it. |
| 18 doit="${DOITPROG-}" | 30 doit="${DOITPROG-}" |
| 19 | 31 |
| 20 | 32 |
| 21 # put in absolute paths if you don't have them in your path; or use env. vars. | 33 # put in absolute paths if you don't have them in your path; or use env. vars. |
| 22 | 34 |
| 23 mvprog="${MVPROG-mv}" | 35 mvprog="${MVPROG-mv}" |
| 24 cpprog="${CPPROG-cp}" | 36 cpprog="${CPPROG-cp}" |
| 25 chmodprog="${CHMODPROG-chmod}" | 37 chmodprog="${CHMODPROG-chmod}" |
| 26 chownprog="${CHOWNPROG-chown}" | 38 chownprog="${CHOWNPROG-chown}" |
| 27 chgrpprog="${CHGRPPROG-chgrp}" | 39 chgrpprog="${CHGRPPROG-chgrp}" |
| 28 stripprog="${STRIPPROG-strip}" | 40 stripprog="${STRIPPROG-strip}" |
| 29 rmprog="${RMPROG-rm}" | 41 rmprog="${RMPROG-rm}" |
| 30 mkdirprog="${MKDIRPROG-mkdir}" | 42 mkdirprog="${MKDIRPROG-mkdir}" |
| 31 | 43 |
| 32 tranformbasename="" | 44 transformbasename="" |
| 33 transform_arg="" | 45 transform_arg="" |
| 34 instcmd="$mvprog" | 46 instcmd="$mvprog" |
| 35 chmodcmd="$chmodprog 0755" | 47 chmodcmd="$chmodprog 0755" |
| 36 chowncmd="" | 48 chowncmd="" |
| 37 chgrpcmd="" | 49 chgrpcmd="" |
| 38 stripcmd="" | 50 stripcmd="" |
| 39 rmcmd="$rmprog -f" | 51 rmcmd="$rmprog -f" |
| 40 mvcmd="$mvprog" | 52 mvcmd="$mvprog" |
| 41 src="" | 53 src="" |
| 42 dst="" | 54 dst="" |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 99 else | 111 else |
| 100 true | 112 true |
| 101 fi | 113 fi |
| 102 | 114 |
| 103 if [ x"$dir_arg" != x ]; then | 115 if [ x"$dir_arg" != x ]; then |
| 104 dst=$src | 116 dst=$src |
| 105 src="" | 117 src="" |
| 106 | 118 |
| 107 if [ -d $dst ]; then | 119 if [ -d $dst ]; then |
| 108 instcmd=: | 120 instcmd=: |
| 121 chmodcmd="" |
| 109 else | 122 else |
| 110 instcmd=mkdir | 123 instcmd=mkdir |
| 111 fi | 124 fi |
| 112 else | 125 else |
| 113 | 126 |
| 114 # Waiting for this to be detected by the "$instcmd $src $dsttmp" command | 127 # Waiting for this to be detected by the "$instcmd $src $dsttmp" command |
| 115 # might cause directories to be created, which would be especially bad | 128 # might cause directories to be created, which would be especially bad |
| 116 # if $src (and thus $dsttmp) contains '*'. | 129 # if $src (and thus $dsttmp) contains '*'. |
| 117 | 130 |
| 118 if [ -f $src -o -d $src ] | 131 if [ -f $src -o -d $src ] |
| (...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 229 | 242 |
| 230 # Now rename the file to the real destination. | 243 # Now rename the file to the real destination. |
| 231 | 244 |
| 232 $doit $rmcmd -f $dstdir/$dstfile && | 245 $doit $rmcmd -f $dstdir/$dstfile && |
| 233 $doit $mvcmd $dsttmp $dstdir/$dstfile | 246 $doit $mvcmd $dsttmp $dstdir/$dstfile |
| 234 | 247 |
| 235 fi && | 248 fi && |
| 236 | 249 |
| 237 | 250 |
| 238 exit 0 | 251 exit 0 |
| OLD | NEW |