| Guido van Rossum | 01b68fd | 1996-05-24 18:58:43 +0000 | [diff] [blame] | 1 | #!/bin/sh | 
 | 2 |  | 
 | 3 | # | 
 | 4 | # install - install a program, script, or datafile | 
 | 5 | # This comes from X11R5; it is not part of GNU. | 
 | 6 | # | 
 | 7 | # $XConsortium: install.sh,v 1.2 89/12/18 14:47:22 jim Exp $ | 
 | 8 | # | 
 | 9 | # This script is compatible with the BSD install script, but was written | 
 | 10 | # from scratch. | 
 | 11 | # | 
 | 12 |  | 
 | 13 |  | 
 | 14 | # set DOITPROG to echo to test this script | 
 | 15 |  | 
 | 16 | # Don't use :- since 4.3BSD and earlier shells don't like it. | 
 | 17 | doit="${DOITPROG-}" | 
 | 18 |  | 
 | 19 |  | 
 | 20 | # put in absolute paths if you don't have them in your path; or use env. vars. | 
 | 21 |  | 
 | 22 | mvprog="${MVPROG-mv}" | 
 | 23 | cpprog="${CPPROG-cp}" | 
 | 24 | chmodprog="${CHMODPROG-chmod}" | 
 | 25 | chownprog="${CHOWNPROG-chown}" | 
 | 26 | chgrpprog="${CHGRPPROG-chgrp}" | 
 | 27 | stripprog="${STRIPPROG-strip}" | 
 | 28 | rmprog="${RMPROG-rm}" | 
 | 29 |  | 
 | 30 | instcmd="$mvprog" | 
 | 31 | chmodcmd="" | 
 | 32 | chowncmd="" | 
 | 33 | chgrpcmd="" | 
 | 34 | stripcmd="" | 
 | 35 | rmcmd="$rmprog -f" | 
 | 36 | mvcmd="$mvprog" | 
 | 37 | src="" | 
 | 38 | dst="" | 
 | 39 |  | 
 | 40 | while [ x"$1" != x ]; do | 
 | 41 |     case $1 in | 
 | 42 | 	-c) instcmd="$cpprog" | 
 | 43 | 	    shift | 
 | 44 | 	    continue;; | 
 | 45 |  | 
 | 46 | 	-m) chmodcmd="$chmodprog $2" | 
 | 47 | 	    shift | 
 | 48 | 	    shift | 
 | 49 | 	    continue;; | 
 | 50 |  | 
 | 51 | 	-o) chowncmd="$chownprog $2" | 
 | 52 | 	    shift | 
 | 53 | 	    shift | 
 | 54 | 	    continue;; | 
 | 55 |  | 
 | 56 | 	-g) chgrpcmd="$chgrpprog $2" | 
 | 57 | 	    shift | 
 | 58 | 	    shift | 
 | 59 | 	    continue;; | 
 | 60 |  | 
 | 61 | 	-s) stripcmd="$stripprog" | 
 | 62 | 	    shift | 
 | 63 | 	    continue;; | 
 | 64 |  | 
 | 65 | 	*)  if [ x"$src" = x ] | 
 | 66 | 	    then | 
 | 67 | 		src=$1 | 
 | 68 | 	    else | 
 | 69 | 		dst=$1 | 
 | 70 | 	    fi | 
 | 71 | 	    shift | 
 | 72 | 	    continue;; | 
 | 73 |     esac | 
 | 74 | done | 
 | 75 |  | 
 | 76 | if [ x"$src" = x ] | 
 | 77 | then | 
 | 78 | 	echo "install:  no input file specified" | 
 | 79 | 	exit 1 | 
 | 80 | fi | 
 | 81 |  | 
 | 82 | if [ x"$dst" = x ] | 
 | 83 | then | 
 | 84 | 	echo "install:  no destination specified" | 
 | 85 | 	exit 1 | 
 | 86 | fi | 
 | 87 |  | 
 | 88 |  | 
 | 89 | # If destination is a directory, append the input filename; if your system | 
 | 90 | # does not like double slashes in filenames, you may need to add some logic | 
 | 91 |  | 
 | 92 | if [ -d $dst ] | 
 | 93 | then | 
 | 94 | 	dst="$dst"/`basename $src` | 
 | 95 | fi | 
 | 96 |  | 
 | 97 | # Make a temp file name in the proper directory. | 
 | 98 |  | 
| Guido van Rossum | c594baa | 1998-05-05 20:39:58 +0000 | [diff] [blame] | 99 | # Avoid dirname, which doesn't exist everywhere... | 
 | 100 | dstdir=`echo $dst | sed 's,/[^/]*$,,'` | 
| Guido van Rossum | 01b68fd | 1996-05-24 18:58:43 +0000 | [diff] [blame] | 101 | dsttmp=$dstdir/#inst.$$# | 
 | 102 |  | 
 | 103 | # Move or copy the file name to the temp name | 
 | 104 |  | 
| Guido van Rossum | 54047c8 | 1998-08-13 16:08:45 +0000 | [diff] [blame] | 105 | $doit $instcmd $src $dsttmp || exit $? | 
| Guido van Rossum | 01b68fd | 1996-05-24 18:58:43 +0000 | [diff] [blame] | 106 |  | 
 | 107 | # and set any options; do chmod last to preserve setuid bits | 
 | 108 |  | 
 | 109 | if [ x"$chowncmd" != x ]; then $doit $chowncmd $dsttmp; fi | 
 | 110 | if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd $dsttmp; fi | 
 | 111 | if [ x"$stripcmd" != x ]; then $doit $stripcmd $dsttmp; fi | 
 | 112 | if [ x"$chmodcmd" != x ]; then $doit $chmodcmd $dsttmp; fi | 
 | 113 |  | 
 | 114 | # Now rename the file to the real destination. | 
 | 115 |  | 
 | 116 | $doit $rmcmd $dst | 
| Guido van Rossum | 54047c8 | 1998-08-13 16:08:45 +0000 | [diff] [blame] | 117 | $doit $mvcmd $dsttmp $dst || exit $? | 
| Guido van Rossum | 01b68fd | 1996-05-24 18:58:43 +0000 | [diff] [blame] | 118 |  | 
 | 119 |  | 
 | 120 | exit 0 |