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