open-src/app/winsysck/sun-src/install-sh
author Jay Cotton <Jay.Cotton@Sun.COM>
Thu, 24 Jul 2008 13:07:37 -0700
changeset 472 c6afe0d6b651
permissions -rwxr-xr-x
6727043 Move winsysck to open source tree
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
472
c6afe0d6b651 6727043 Move winsysck to open source tree
Jay Cotton <Jay.Cotton@Sun.COM>
parents:
diff changeset
     1
#!/bin/sh
c6afe0d6b651 6727043 Move winsysck to open source tree
Jay Cotton <Jay.Cotton@Sun.COM>
parents:
diff changeset
     2
#
c6afe0d6b651 6727043 Move winsysck to open source tree
Jay Cotton <Jay.Cotton@Sun.COM>
parents:
diff changeset
     3
# install - install a program, script, or datafile
c6afe0d6b651 6727043 Move winsysck to open source tree
Jay Cotton <Jay.Cotton@Sun.COM>
parents:
diff changeset
     4
#
c6afe0d6b651 6727043 Move winsysck to open source tree
Jay Cotton <Jay.Cotton@Sun.COM>
parents:
diff changeset
     5
# This originates from X11R5 (mit/util/scripts/install.sh), which was
c6afe0d6b651 6727043 Move winsysck to open source tree
Jay Cotton <Jay.Cotton@Sun.COM>
parents:
diff changeset
     6
# later released in X11R6 (xc/config/util/install.sh) with the
c6afe0d6b651 6727043 Move winsysck to open source tree
Jay Cotton <Jay.Cotton@Sun.COM>
parents:
diff changeset
     7
# following copyright and license.
c6afe0d6b651 6727043 Move winsysck to open source tree
Jay Cotton <Jay.Cotton@Sun.COM>
parents:
diff changeset
     8
#
c6afe0d6b651 6727043 Move winsysck to open source tree
Jay Cotton <Jay.Cotton@Sun.COM>
parents:
diff changeset
     9
# Copyright (C) 1994 X Consortium
c6afe0d6b651 6727043 Move winsysck to open source tree
Jay Cotton <Jay.Cotton@Sun.COM>
parents:
diff changeset
    10
#
c6afe0d6b651 6727043 Move winsysck to open source tree
Jay Cotton <Jay.Cotton@Sun.COM>
parents:
diff changeset
    11
# Permission is hereby granted, free of charge, to any person obtaining a copy
c6afe0d6b651 6727043 Move winsysck to open source tree
Jay Cotton <Jay.Cotton@Sun.COM>
parents:
diff changeset
    12
# of this software and associated documentation files (the "Software"), to
c6afe0d6b651 6727043 Move winsysck to open source tree
Jay Cotton <Jay.Cotton@Sun.COM>
parents:
diff changeset
    13
# deal in the Software without restriction, including without limitation the
c6afe0d6b651 6727043 Move winsysck to open source tree
Jay Cotton <Jay.Cotton@Sun.COM>
parents:
diff changeset
    14
# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
c6afe0d6b651 6727043 Move winsysck to open source tree
Jay Cotton <Jay.Cotton@Sun.COM>
parents:
diff changeset
    15
# sell copies of the Software, and to permit persons to whom the Software is
c6afe0d6b651 6727043 Move winsysck to open source tree
Jay Cotton <Jay.Cotton@Sun.COM>
parents:
diff changeset
    16
# furnished to do so, subject to the following conditions:
c6afe0d6b651 6727043 Move winsysck to open source tree
Jay Cotton <Jay.Cotton@Sun.COM>
parents:
diff changeset
    17
#
c6afe0d6b651 6727043 Move winsysck to open source tree
Jay Cotton <Jay.Cotton@Sun.COM>
parents:
diff changeset
    18
# The above copyright notice and this permission notice shall be included in
c6afe0d6b651 6727043 Move winsysck to open source tree
Jay Cotton <Jay.Cotton@Sun.COM>
parents:
diff changeset
    19
# all copies or substantial portions of the Software.
c6afe0d6b651 6727043 Move winsysck to open source tree
Jay Cotton <Jay.Cotton@Sun.COM>
parents:
diff changeset
    20
#
c6afe0d6b651 6727043 Move winsysck to open source tree
Jay Cotton <Jay.Cotton@Sun.COM>
parents:
diff changeset
    21
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
c6afe0d6b651 6727043 Move winsysck to open source tree
Jay Cotton <Jay.Cotton@Sun.COM>
parents:
diff changeset
    22
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
c6afe0d6b651 6727043 Move winsysck to open source tree
Jay Cotton <Jay.Cotton@Sun.COM>
parents:
diff changeset
    23
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL THE
c6afe0d6b651 6727043 Move winsysck to open source tree
Jay Cotton <Jay.Cotton@Sun.COM>
parents:
diff changeset
    24
# X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
c6afe0d6b651 6727043 Move winsysck to open source tree
Jay Cotton <Jay.Cotton@Sun.COM>
parents:
diff changeset
    25
# AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNEC-
c6afe0d6b651 6727043 Move winsysck to open source tree
Jay Cotton <Jay.Cotton@Sun.COM>
parents:
diff changeset
    26
# TION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
c6afe0d6b651 6727043 Move winsysck to open source tree
Jay Cotton <Jay.Cotton@Sun.COM>
parents:
diff changeset
    27
#
c6afe0d6b651 6727043 Move winsysck to open source tree
Jay Cotton <Jay.Cotton@Sun.COM>
parents:
diff changeset
    28
# Except as contained in this notice, the name of the X Consortium shall not
c6afe0d6b651 6727043 Move winsysck to open source tree
Jay Cotton <Jay.Cotton@Sun.COM>
parents:
diff changeset
    29
# be used in advertising or otherwise to promote the sale, use or other deal-
c6afe0d6b651 6727043 Move winsysck to open source tree
Jay Cotton <Jay.Cotton@Sun.COM>
parents:
diff changeset
    30
# ings in this Software without prior written authorization from the X Consor-
c6afe0d6b651 6727043 Move winsysck to open source tree
Jay Cotton <Jay.Cotton@Sun.COM>
parents:
diff changeset
    31
# tium.
c6afe0d6b651 6727043 Move winsysck to open source tree
Jay Cotton <Jay.Cotton@Sun.COM>
parents:
diff changeset
    32
#
c6afe0d6b651 6727043 Move winsysck to open source tree
Jay Cotton <Jay.Cotton@Sun.COM>
parents:
diff changeset
    33
#
c6afe0d6b651 6727043 Move winsysck to open source tree
Jay Cotton <Jay.Cotton@Sun.COM>
parents:
diff changeset
    34
# FSF changes to this file are in the public domain.
c6afe0d6b651 6727043 Move winsysck to open source tree
Jay Cotton <Jay.Cotton@Sun.COM>
parents:
diff changeset
    35
#
c6afe0d6b651 6727043 Move winsysck to open source tree
Jay Cotton <Jay.Cotton@Sun.COM>
parents:
diff changeset
    36
# Calling this script install-sh is preferred over install.sh, to prevent
c6afe0d6b651 6727043 Move winsysck to open source tree
Jay Cotton <Jay.Cotton@Sun.COM>
parents:
diff changeset
    37
# `make' implicit rules from creating a file called install from it
c6afe0d6b651 6727043 Move winsysck to open source tree
Jay Cotton <Jay.Cotton@Sun.COM>
parents:
diff changeset
    38
# when there is no Makefile.
c6afe0d6b651 6727043 Move winsysck to open source tree
Jay Cotton <Jay.Cotton@Sun.COM>
parents:
diff changeset
    39
#
c6afe0d6b651 6727043 Move winsysck to open source tree
Jay Cotton <Jay.Cotton@Sun.COM>
parents:
diff changeset
    40
# This script is compatible with the BSD install script, but was written
c6afe0d6b651 6727043 Move winsysck to open source tree
Jay Cotton <Jay.Cotton@Sun.COM>
parents:
diff changeset
    41
# from scratch.  It can only install one file at a time, a restriction
c6afe0d6b651 6727043 Move winsysck to open source tree
Jay Cotton <Jay.Cotton@Sun.COM>
parents:
diff changeset
    42
# shared with many OS's install programs.
c6afe0d6b651 6727043 Move winsysck to open source tree
Jay Cotton <Jay.Cotton@Sun.COM>
parents:
diff changeset
    43
c6afe0d6b651 6727043 Move winsysck to open source tree
Jay Cotton <Jay.Cotton@Sun.COM>
parents:
diff changeset
    44
c6afe0d6b651 6727043 Move winsysck to open source tree
Jay Cotton <Jay.Cotton@Sun.COM>
parents:
diff changeset
    45
# set DOITPROG to echo to test this script
c6afe0d6b651 6727043 Move winsysck to open source tree
Jay Cotton <Jay.Cotton@Sun.COM>
parents:
diff changeset
    46
c6afe0d6b651 6727043 Move winsysck to open source tree
Jay Cotton <Jay.Cotton@Sun.COM>
parents:
diff changeset
    47
# Don't use :- since 4.3BSD and earlier shells don't like it.
c6afe0d6b651 6727043 Move winsysck to open source tree
Jay Cotton <Jay.Cotton@Sun.COM>
parents:
diff changeset
    48
doit="${DOITPROG-}"
c6afe0d6b651 6727043 Move winsysck to open source tree
Jay Cotton <Jay.Cotton@Sun.COM>
parents:
diff changeset
    49
c6afe0d6b651 6727043 Move winsysck to open source tree
Jay Cotton <Jay.Cotton@Sun.COM>
parents:
diff changeset
    50
c6afe0d6b651 6727043 Move winsysck to open source tree
Jay Cotton <Jay.Cotton@Sun.COM>
parents:
diff changeset
    51
# put in absolute paths if you don't have them in your path; or use env. vars.
c6afe0d6b651 6727043 Move winsysck to open source tree
Jay Cotton <Jay.Cotton@Sun.COM>
parents:
diff changeset
    52
c6afe0d6b651 6727043 Move winsysck to open source tree
Jay Cotton <Jay.Cotton@Sun.COM>
parents:
diff changeset
    53
mvprog="${MVPROG-mv}"
c6afe0d6b651 6727043 Move winsysck to open source tree
Jay Cotton <Jay.Cotton@Sun.COM>
parents:
diff changeset
    54
cpprog="${CPPROG-cp}"
c6afe0d6b651 6727043 Move winsysck to open source tree
Jay Cotton <Jay.Cotton@Sun.COM>
parents:
diff changeset
    55
chmodprog="${CHMODPROG-chmod}"
c6afe0d6b651 6727043 Move winsysck to open source tree
Jay Cotton <Jay.Cotton@Sun.COM>
parents:
diff changeset
    56
chownprog="${CHOWNPROG-chown}"
c6afe0d6b651 6727043 Move winsysck to open source tree
Jay Cotton <Jay.Cotton@Sun.COM>
parents:
diff changeset
    57
chgrpprog="${CHGRPPROG-chgrp}"
c6afe0d6b651 6727043 Move winsysck to open source tree
Jay Cotton <Jay.Cotton@Sun.COM>
parents:
diff changeset
    58
stripprog="${STRIPPROG-strip}"
c6afe0d6b651 6727043 Move winsysck to open source tree
Jay Cotton <Jay.Cotton@Sun.COM>
parents:
diff changeset
    59
rmprog="${RMPROG-rm}"
c6afe0d6b651 6727043 Move winsysck to open source tree
Jay Cotton <Jay.Cotton@Sun.COM>
parents:
diff changeset
    60
mkdirprog="${MKDIRPROG-mkdir}"
c6afe0d6b651 6727043 Move winsysck to open source tree
Jay Cotton <Jay.Cotton@Sun.COM>
parents:
diff changeset
    61
c6afe0d6b651 6727043 Move winsysck to open source tree
Jay Cotton <Jay.Cotton@Sun.COM>
parents:
diff changeset
    62
transformbasename=""
c6afe0d6b651 6727043 Move winsysck to open source tree
Jay Cotton <Jay.Cotton@Sun.COM>
parents:
diff changeset
    63
transform_arg=""
c6afe0d6b651 6727043 Move winsysck to open source tree
Jay Cotton <Jay.Cotton@Sun.COM>
parents:
diff changeset
    64
instcmd="$mvprog"
c6afe0d6b651 6727043 Move winsysck to open source tree
Jay Cotton <Jay.Cotton@Sun.COM>
parents:
diff changeset
    65
chmodcmd="$chmodprog 0755"
c6afe0d6b651 6727043 Move winsysck to open source tree
Jay Cotton <Jay.Cotton@Sun.COM>
parents:
diff changeset
    66
chowncmd=""
c6afe0d6b651 6727043 Move winsysck to open source tree
Jay Cotton <Jay.Cotton@Sun.COM>
parents:
diff changeset
    67
chgrpcmd=""
c6afe0d6b651 6727043 Move winsysck to open source tree
Jay Cotton <Jay.Cotton@Sun.COM>
parents:
diff changeset
    68
stripcmd=""
c6afe0d6b651 6727043 Move winsysck to open source tree
Jay Cotton <Jay.Cotton@Sun.COM>
parents:
diff changeset
    69
rmcmd="$rmprog -f"
c6afe0d6b651 6727043 Move winsysck to open source tree
Jay Cotton <Jay.Cotton@Sun.COM>
parents:
diff changeset
    70
mvcmd="$mvprog"
c6afe0d6b651 6727043 Move winsysck to open source tree
Jay Cotton <Jay.Cotton@Sun.COM>
parents:
diff changeset
    71
src=""
c6afe0d6b651 6727043 Move winsysck to open source tree
Jay Cotton <Jay.Cotton@Sun.COM>
parents:
diff changeset
    72
dst=""
c6afe0d6b651 6727043 Move winsysck to open source tree
Jay Cotton <Jay.Cotton@Sun.COM>
parents:
diff changeset
    73
dir_arg=""
c6afe0d6b651 6727043 Move winsysck to open source tree
Jay Cotton <Jay.Cotton@Sun.COM>
parents:
diff changeset
    74
c6afe0d6b651 6727043 Move winsysck to open source tree
Jay Cotton <Jay.Cotton@Sun.COM>
parents:
diff changeset
    75
while [ x"$1" != x ]; do
c6afe0d6b651 6727043 Move winsysck to open source tree
Jay Cotton <Jay.Cotton@Sun.COM>
parents:
diff changeset
    76
    case $1 in
c6afe0d6b651 6727043 Move winsysck to open source tree
Jay Cotton <Jay.Cotton@Sun.COM>
parents:
diff changeset
    77
	-c) instcmd=$cpprog
c6afe0d6b651 6727043 Move winsysck to open source tree
Jay Cotton <Jay.Cotton@Sun.COM>
parents:
diff changeset
    78
	    shift
c6afe0d6b651 6727043 Move winsysck to open source tree
Jay Cotton <Jay.Cotton@Sun.COM>
parents:
diff changeset
    79
	    continue;;
c6afe0d6b651 6727043 Move winsysck to open source tree
Jay Cotton <Jay.Cotton@Sun.COM>
parents:
diff changeset
    80
c6afe0d6b651 6727043 Move winsysck to open source tree
Jay Cotton <Jay.Cotton@Sun.COM>
parents:
diff changeset
    81
	-d) dir_arg=true
c6afe0d6b651 6727043 Move winsysck to open source tree
Jay Cotton <Jay.Cotton@Sun.COM>
parents:
diff changeset
    82
	    shift
c6afe0d6b651 6727043 Move winsysck to open source tree
Jay Cotton <Jay.Cotton@Sun.COM>
parents:
diff changeset
    83
	    continue;;
c6afe0d6b651 6727043 Move winsysck to open source tree
Jay Cotton <Jay.Cotton@Sun.COM>
parents:
diff changeset
    84
c6afe0d6b651 6727043 Move winsysck to open source tree
Jay Cotton <Jay.Cotton@Sun.COM>
parents:
diff changeset
    85
	-m) chmodcmd="$chmodprog $2"
c6afe0d6b651 6727043 Move winsysck to open source tree
Jay Cotton <Jay.Cotton@Sun.COM>
parents:
diff changeset
    86
	    shift
c6afe0d6b651 6727043 Move winsysck to open source tree
Jay Cotton <Jay.Cotton@Sun.COM>
parents:
diff changeset
    87
	    shift
c6afe0d6b651 6727043 Move winsysck to open source tree
Jay Cotton <Jay.Cotton@Sun.COM>
parents:
diff changeset
    88
	    continue;;
c6afe0d6b651 6727043 Move winsysck to open source tree
Jay Cotton <Jay.Cotton@Sun.COM>
parents:
diff changeset
    89
c6afe0d6b651 6727043 Move winsysck to open source tree
Jay Cotton <Jay.Cotton@Sun.COM>
parents:
diff changeset
    90
	-o) chowncmd="$chownprog $2"
c6afe0d6b651 6727043 Move winsysck to open source tree
Jay Cotton <Jay.Cotton@Sun.COM>
parents:
diff changeset
    91
	    shift
c6afe0d6b651 6727043 Move winsysck to open source tree
Jay Cotton <Jay.Cotton@Sun.COM>
parents:
diff changeset
    92
	    shift
c6afe0d6b651 6727043 Move winsysck to open source tree
Jay Cotton <Jay.Cotton@Sun.COM>
parents:
diff changeset
    93
	    continue;;
c6afe0d6b651 6727043 Move winsysck to open source tree
Jay Cotton <Jay.Cotton@Sun.COM>
parents:
diff changeset
    94
c6afe0d6b651 6727043 Move winsysck to open source tree
Jay Cotton <Jay.Cotton@Sun.COM>
parents:
diff changeset
    95
	-g) chgrpcmd="$chgrpprog $2"
c6afe0d6b651 6727043 Move winsysck to open source tree
Jay Cotton <Jay.Cotton@Sun.COM>
parents:
diff changeset
    96
	    shift
c6afe0d6b651 6727043 Move winsysck to open source tree
Jay Cotton <Jay.Cotton@Sun.COM>
parents:
diff changeset
    97
	    shift
c6afe0d6b651 6727043 Move winsysck to open source tree
Jay Cotton <Jay.Cotton@Sun.COM>
parents:
diff changeset
    98
	    continue;;
c6afe0d6b651 6727043 Move winsysck to open source tree
Jay Cotton <Jay.Cotton@Sun.COM>
parents:
diff changeset
    99
c6afe0d6b651 6727043 Move winsysck to open source tree
Jay Cotton <Jay.Cotton@Sun.COM>
parents:
diff changeset
   100
	-s) stripcmd=$stripprog
c6afe0d6b651 6727043 Move winsysck to open source tree
Jay Cotton <Jay.Cotton@Sun.COM>
parents:
diff changeset
   101
	    shift
c6afe0d6b651 6727043 Move winsysck to open source tree
Jay Cotton <Jay.Cotton@Sun.COM>
parents:
diff changeset
   102
	    continue;;
c6afe0d6b651 6727043 Move winsysck to open source tree
Jay Cotton <Jay.Cotton@Sun.COM>
parents:
diff changeset
   103
c6afe0d6b651 6727043 Move winsysck to open source tree
Jay Cotton <Jay.Cotton@Sun.COM>
parents:
diff changeset
   104
	-t=*) transformarg=`echo $1 | sed 's/-t=//'`
c6afe0d6b651 6727043 Move winsysck to open source tree
Jay Cotton <Jay.Cotton@Sun.COM>
parents:
diff changeset
   105
	    shift
c6afe0d6b651 6727043 Move winsysck to open source tree
Jay Cotton <Jay.Cotton@Sun.COM>
parents:
diff changeset
   106
	    continue;;
c6afe0d6b651 6727043 Move winsysck to open source tree
Jay Cotton <Jay.Cotton@Sun.COM>
parents:
diff changeset
   107
c6afe0d6b651 6727043 Move winsysck to open source tree
Jay Cotton <Jay.Cotton@Sun.COM>
parents:
diff changeset
   108
	-b=*) transformbasename=`echo $1 | sed 's/-b=//'`
c6afe0d6b651 6727043 Move winsysck to open source tree
Jay Cotton <Jay.Cotton@Sun.COM>
parents:
diff changeset
   109
	    shift
c6afe0d6b651 6727043 Move winsysck to open source tree
Jay Cotton <Jay.Cotton@Sun.COM>
parents:
diff changeset
   110
	    continue;;
c6afe0d6b651 6727043 Move winsysck to open source tree
Jay Cotton <Jay.Cotton@Sun.COM>
parents:
diff changeset
   111
c6afe0d6b651 6727043 Move winsysck to open source tree
Jay Cotton <Jay.Cotton@Sun.COM>
parents:
diff changeset
   112
	*)  if [ x"$src" = x ]
c6afe0d6b651 6727043 Move winsysck to open source tree
Jay Cotton <Jay.Cotton@Sun.COM>
parents:
diff changeset
   113
	    then
c6afe0d6b651 6727043 Move winsysck to open source tree
Jay Cotton <Jay.Cotton@Sun.COM>
parents:
diff changeset
   114
		src=$1
c6afe0d6b651 6727043 Move winsysck to open source tree
Jay Cotton <Jay.Cotton@Sun.COM>
parents:
diff changeset
   115
	    else
c6afe0d6b651 6727043 Move winsysck to open source tree
Jay Cotton <Jay.Cotton@Sun.COM>
parents:
diff changeset
   116
		# this colon is to work around a 386BSD /bin/sh bug
c6afe0d6b651 6727043 Move winsysck to open source tree
Jay Cotton <Jay.Cotton@Sun.COM>
parents:
diff changeset
   117
		:
c6afe0d6b651 6727043 Move winsysck to open source tree
Jay Cotton <Jay.Cotton@Sun.COM>
parents:
diff changeset
   118
		dst=$1
c6afe0d6b651 6727043 Move winsysck to open source tree
Jay Cotton <Jay.Cotton@Sun.COM>
parents:
diff changeset
   119
	    fi
c6afe0d6b651 6727043 Move winsysck to open source tree
Jay Cotton <Jay.Cotton@Sun.COM>
parents:
diff changeset
   120
	    shift
c6afe0d6b651 6727043 Move winsysck to open source tree
Jay Cotton <Jay.Cotton@Sun.COM>
parents:
diff changeset
   121
	    continue;;
c6afe0d6b651 6727043 Move winsysck to open source tree
Jay Cotton <Jay.Cotton@Sun.COM>
parents:
diff changeset
   122
    esac
c6afe0d6b651 6727043 Move winsysck to open source tree
Jay Cotton <Jay.Cotton@Sun.COM>
parents:
diff changeset
   123
done
c6afe0d6b651 6727043 Move winsysck to open source tree
Jay Cotton <Jay.Cotton@Sun.COM>
parents:
diff changeset
   124
c6afe0d6b651 6727043 Move winsysck to open source tree
Jay Cotton <Jay.Cotton@Sun.COM>
parents:
diff changeset
   125
if [ x"$src" = x ]
c6afe0d6b651 6727043 Move winsysck to open source tree
Jay Cotton <Jay.Cotton@Sun.COM>
parents:
diff changeset
   126
then
c6afe0d6b651 6727043 Move winsysck to open source tree
Jay Cotton <Jay.Cotton@Sun.COM>
parents:
diff changeset
   127
	echo "$0: no input file specified" >&2
c6afe0d6b651 6727043 Move winsysck to open source tree
Jay Cotton <Jay.Cotton@Sun.COM>
parents:
diff changeset
   128
	exit 1
c6afe0d6b651 6727043 Move winsysck to open source tree
Jay Cotton <Jay.Cotton@Sun.COM>
parents:
diff changeset
   129
else
c6afe0d6b651 6727043 Move winsysck to open source tree
Jay Cotton <Jay.Cotton@Sun.COM>
parents:
diff changeset
   130
	:
c6afe0d6b651 6727043 Move winsysck to open source tree
Jay Cotton <Jay.Cotton@Sun.COM>
parents:
diff changeset
   131
fi
c6afe0d6b651 6727043 Move winsysck to open source tree
Jay Cotton <Jay.Cotton@Sun.COM>
parents:
diff changeset
   132
c6afe0d6b651 6727043 Move winsysck to open source tree
Jay Cotton <Jay.Cotton@Sun.COM>
parents:
diff changeset
   133
if [ x"$dir_arg" != x ]; then
c6afe0d6b651 6727043 Move winsysck to open source tree
Jay Cotton <Jay.Cotton@Sun.COM>
parents:
diff changeset
   134
	dst=$src
c6afe0d6b651 6727043 Move winsysck to open source tree
Jay Cotton <Jay.Cotton@Sun.COM>
parents:
diff changeset
   135
	src=""
c6afe0d6b651 6727043 Move winsysck to open source tree
Jay Cotton <Jay.Cotton@Sun.COM>
parents:
diff changeset
   136
c6afe0d6b651 6727043 Move winsysck to open source tree
Jay Cotton <Jay.Cotton@Sun.COM>
parents:
diff changeset
   137
	if [ -d "$dst" ]; then
c6afe0d6b651 6727043 Move winsysck to open source tree
Jay Cotton <Jay.Cotton@Sun.COM>
parents:
diff changeset
   138
		instcmd=:
c6afe0d6b651 6727043 Move winsysck to open source tree
Jay Cotton <Jay.Cotton@Sun.COM>
parents:
diff changeset
   139
		chmodcmd=""
c6afe0d6b651 6727043 Move winsysck to open source tree
Jay Cotton <Jay.Cotton@Sun.COM>
parents:
diff changeset
   140
	else
c6afe0d6b651 6727043 Move winsysck to open source tree
Jay Cotton <Jay.Cotton@Sun.COM>
parents:
diff changeset
   141
		instcmd=$mkdirprog
c6afe0d6b651 6727043 Move winsysck to open source tree
Jay Cotton <Jay.Cotton@Sun.COM>
parents:
diff changeset
   142
	fi
c6afe0d6b651 6727043 Move winsysck to open source tree
Jay Cotton <Jay.Cotton@Sun.COM>
parents:
diff changeset
   143
else
c6afe0d6b651 6727043 Move winsysck to open source tree
Jay Cotton <Jay.Cotton@Sun.COM>
parents:
diff changeset
   144
c6afe0d6b651 6727043 Move winsysck to open source tree
Jay Cotton <Jay.Cotton@Sun.COM>
parents:
diff changeset
   145
# Waiting for this to be detected by the "$instcmd $src $dsttmp" command
c6afe0d6b651 6727043 Move winsysck to open source tree
Jay Cotton <Jay.Cotton@Sun.COM>
parents:
diff changeset
   146
# might cause directories to be created, which would be especially bad
c6afe0d6b651 6727043 Move winsysck to open source tree
Jay Cotton <Jay.Cotton@Sun.COM>
parents:
diff changeset
   147
# if $src (and thus $dsttmp) contains '*'.
c6afe0d6b651 6727043 Move winsysck to open source tree
Jay Cotton <Jay.Cotton@Sun.COM>
parents:
diff changeset
   148
c6afe0d6b651 6727043 Move winsysck to open source tree
Jay Cotton <Jay.Cotton@Sun.COM>
parents:
diff changeset
   149
	if [ -f "$src" ] || [ -d "$src" ]
c6afe0d6b651 6727043 Move winsysck to open source tree
Jay Cotton <Jay.Cotton@Sun.COM>
parents:
diff changeset
   150
	then
c6afe0d6b651 6727043 Move winsysck to open source tree
Jay Cotton <Jay.Cotton@Sun.COM>
parents:
diff changeset
   151
		:
c6afe0d6b651 6727043 Move winsysck to open source tree
Jay Cotton <Jay.Cotton@Sun.COM>
parents:
diff changeset
   152
	else
c6afe0d6b651 6727043 Move winsysck to open source tree
Jay Cotton <Jay.Cotton@Sun.COM>
parents:
diff changeset
   153
		echo "$0: $src does not exist" >&2
c6afe0d6b651 6727043 Move winsysck to open source tree
Jay Cotton <Jay.Cotton@Sun.COM>
parents:
diff changeset
   154
		exit 1
c6afe0d6b651 6727043 Move winsysck to open source tree
Jay Cotton <Jay.Cotton@Sun.COM>
parents:
diff changeset
   155
	fi
c6afe0d6b651 6727043 Move winsysck to open source tree
Jay Cotton <Jay.Cotton@Sun.COM>
parents:
diff changeset
   156
c6afe0d6b651 6727043 Move winsysck to open source tree
Jay Cotton <Jay.Cotton@Sun.COM>
parents:
diff changeset
   157
	if [ x"$dst" = x ]
c6afe0d6b651 6727043 Move winsysck to open source tree
Jay Cotton <Jay.Cotton@Sun.COM>
parents:
diff changeset
   158
	then
c6afe0d6b651 6727043 Move winsysck to open source tree
Jay Cotton <Jay.Cotton@Sun.COM>
parents:
diff changeset
   159
		echo "$0: no destination specified" >&2
c6afe0d6b651 6727043 Move winsysck to open source tree
Jay Cotton <Jay.Cotton@Sun.COM>
parents:
diff changeset
   160
		exit 1
c6afe0d6b651 6727043 Move winsysck to open source tree
Jay Cotton <Jay.Cotton@Sun.COM>
parents:
diff changeset
   161
	else
c6afe0d6b651 6727043 Move winsysck to open source tree
Jay Cotton <Jay.Cotton@Sun.COM>
parents:
diff changeset
   162
		:
c6afe0d6b651 6727043 Move winsysck to open source tree
Jay Cotton <Jay.Cotton@Sun.COM>
parents:
diff changeset
   163
	fi
c6afe0d6b651 6727043 Move winsysck to open source tree
Jay Cotton <Jay.Cotton@Sun.COM>
parents:
diff changeset
   164
c6afe0d6b651 6727043 Move winsysck to open source tree
Jay Cotton <Jay.Cotton@Sun.COM>
parents:
diff changeset
   165
# If destination is a directory, append the input filename; if your system
c6afe0d6b651 6727043 Move winsysck to open source tree
Jay Cotton <Jay.Cotton@Sun.COM>
parents:
diff changeset
   166
# does not like double slashes in filenames, you may need to add some logic
c6afe0d6b651 6727043 Move winsysck to open source tree
Jay Cotton <Jay.Cotton@Sun.COM>
parents:
diff changeset
   167
c6afe0d6b651 6727043 Move winsysck to open source tree
Jay Cotton <Jay.Cotton@Sun.COM>
parents:
diff changeset
   168
	if [ -d "$dst" ]
c6afe0d6b651 6727043 Move winsysck to open source tree
Jay Cotton <Jay.Cotton@Sun.COM>
parents:
diff changeset
   169
	then
c6afe0d6b651 6727043 Move winsysck to open source tree
Jay Cotton <Jay.Cotton@Sun.COM>
parents:
diff changeset
   170
		dst=$dst/`basename "$src"`
c6afe0d6b651 6727043 Move winsysck to open source tree
Jay Cotton <Jay.Cotton@Sun.COM>
parents:
diff changeset
   171
	else
c6afe0d6b651 6727043 Move winsysck to open source tree
Jay Cotton <Jay.Cotton@Sun.COM>
parents:
diff changeset
   172
		:
c6afe0d6b651 6727043 Move winsysck to open source tree
Jay Cotton <Jay.Cotton@Sun.COM>
parents:
diff changeset
   173
	fi
c6afe0d6b651 6727043 Move winsysck to open source tree
Jay Cotton <Jay.Cotton@Sun.COM>
parents:
diff changeset
   174
fi
c6afe0d6b651 6727043 Move winsysck to open source tree
Jay Cotton <Jay.Cotton@Sun.COM>
parents:
diff changeset
   175
c6afe0d6b651 6727043 Move winsysck to open source tree
Jay Cotton <Jay.Cotton@Sun.COM>
parents:
diff changeset
   176
## this sed command emulates the dirname command
c6afe0d6b651 6727043 Move winsysck to open source tree
Jay Cotton <Jay.Cotton@Sun.COM>
parents:
diff changeset
   177
dstdir=`echo "$dst" | sed -e 's,[^/]*$,,;s,/$,,;s,^$,.,'`
c6afe0d6b651 6727043 Move winsysck to open source tree
Jay Cotton <Jay.Cotton@Sun.COM>
parents:
diff changeset
   178
c6afe0d6b651 6727043 Move winsysck to open source tree
Jay Cotton <Jay.Cotton@Sun.COM>
parents:
diff changeset
   179
# Make sure that the destination directory exists.
c6afe0d6b651 6727043 Move winsysck to open source tree
Jay Cotton <Jay.Cotton@Sun.COM>
parents:
diff changeset
   180
#  this part is taken from Noah Friedman's mkinstalldirs script
c6afe0d6b651 6727043 Move winsysck to open source tree
Jay Cotton <Jay.Cotton@Sun.COM>
parents:
diff changeset
   181
c6afe0d6b651 6727043 Move winsysck to open source tree
Jay Cotton <Jay.Cotton@Sun.COM>
parents:
diff changeset
   182
# Skip lots of stat calls in the usual case.
c6afe0d6b651 6727043 Move winsysck to open source tree
Jay Cotton <Jay.Cotton@Sun.COM>
parents:
diff changeset
   183
if [ ! -d "$dstdir" ]; then
c6afe0d6b651 6727043 Move winsysck to open source tree
Jay Cotton <Jay.Cotton@Sun.COM>
parents:
diff changeset
   184
defaultIFS='
c6afe0d6b651 6727043 Move winsysck to open source tree
Jay Cotton <Jay.Cotton@Sun.COM>
parents:
diff changeset
   185
	'
c6afe0d6b651 6727043 Move winsysck to open source tree
Jay Cotton <Jay.Cotton@Sun.COM>
parents:
diff changeset
   186
IFS="${IFS-$defaultIFS}"
c6afe0d6b651 6727043 Move winsysck to open source tree
Jay Cotton <Jay.Cotton@Sun.COM>
parents:
diff changeset
   187
c6afe0d6b651 6727043 Move winsysck to open source tree
Jay Cotton <Jay.Cotton@Sun.COM>
parents:
diff changeset
   188
oIFS=$IFS
c6afe0d6b651 6727043 Move winsysck to open source tree
Jay Cotton <Jay.Cotton@Sun.COM>
parents:
diff changeset
   189
# Some sh's can't handle IFS=/ for some reason.
c6afe0d6b651 6727043 Move winsysck to open source tree
Jay Cotton <Jay.Cotton@Sun.COM>
parents:
diff changeset
   190
IFS='%'
c6afe0d6b651 6727043 Move winsysck to open source tree
Jay Cotton <Jay.Cotton@Sun.COM>
parents:
diff changeset
   191
set - `echo "$dstdir" | sed -e 's@/@%@g' -e 's@^%@/@'`
c6afe0d6b651 6727043 Move winsysck to open source tree
Jay Cotton <Jay.Cotton@Sun.COM>
parents:
diff changeset
   192
IFS=$oIFS
c6afe0d6b651 6727043 Move winsysck to open source tree
Jay Cotton <Jay.Cotton@Sun.COM>
parents:
diff changeset
   193
c6afe0d6b651 6727043 Move winsysck to open source tree
Jay Cotton <Jay.Cotton@Sun.COM>
parents:
diff changeset
   194
pathcomp=''
c6afe0d6b651 6727043 Move winsysck to open source tree
Jay Cotton <Jay.Cotton@Sun.COM>
parents:
diff changeset
   195
c6afe0d6b651 6727043 Move winsysck to open source tree
Jay Cotton <Jay.Cotton@Sun.COM>
parents:
diff changeset
   196
while [ $# -ne 0 ] ; do
c6afe0d6b651 6727043 Move winsysck to open source tree
Jay Cotton <Jay.Cotton@Sun.COM>
parents:
diff changeset
   197
	pathcomp=$pathcomp$1
c6afe0d6b651 6727043 Move winsysck to open source tree
Jay Cotton <Jay.Cotton@Sun.COM>
parents:
diff changeset
   198
	shift
c6afe0d6b651 6727043 Move winsysck to open source tree
Jay Cotton <Jay.Cotton@Sun.COM>
parents:
diff changeset
   199
c6afe0d6b651 6727043 Move winsysck to open source tree
Jay Cotton <Jay.Cotton@Sun.COM>
parents:
diff changeset
   200
	if [ ! -d "$pathcomp" ] ;
c6afe0d6b651 6727043 Move winsysck to open source tree
Jay Cotton <Jay.Cotton@Sun.COM>
parents:
diff changeset
   201
        then
c6afe0d6b651 6727043 Move winsysck to open source tree
Jay Cotton <Jay.Cotton@Sun.COM>
parents:
diff changeset
   202
		$mkdirprog "$pathcomp"
c6afe0d6b651 6727043 Move winsysck to open source tree
Jay Cotton <Jay.Cotton@Sun.COM>
parents:
diff changeset
   203
	else
c6afe0d6b651 6727043 Move winsysck to open source tree
Jay Cotton <Jay.Cotton@Sun.COM>
parents:
diff changeset
   204
		:
c6afe0d6b651 6727043 Move winsysck to open source tree
Jay Cotton <Jay.Cotton@Sun.COM>
parents:
diff changeset
   205
	fi
c6afe0d6b651 6727043 Move winsysck to open source tree
Jay Cotton <Jay.Cotton@Sun.COM>
parents:
diff changeset
   206
c6afe0d6b651 6727043 Move winsysck to open source tree
Jay Cotton <Jay.Cotton@Sun.COM>
parents:
diff changeset
   207
	pathcomp=$pathcomp/
c6afe0d6b651 6727043 Move winsysck to open source tree
Jay Cotton <Jay.Cotton@Sun.COM>
parents:
diff changeset
   208
done
c6afe0d6b651 6727043 Move winsysck to open source tree
Jay Cotton <Jay.Cotton@Sun.COM>
parents:
diff changeset
   209
fi
c6afe0d6b651 6727043 Move winsysck to open source tree
Jay Cotton <Jay.Cotton@Sun.COM>
parents:
diff changeset
   210
c6afe0d6b651 6727043 Move winsysck to open source tree
Jay Cotton <Jay.Cotton@Sun.COM>
parents:
diff changeset
   211
if [ x"$dir_arg" != x ]
c6afe0d6b651 6727043 Move winsysck to open source tree
Jay Cotton <Jay.Cotton@Sun.COM>
parents:
diff changeset
   212
then
c6afe0d6b651 6727043 Move winsysck to open source tree
Jay Cotton <Jay.Cotton@Sun.COM>
parents:
diff changeset
   213
	$doit $instcmd "$dst" &&
c6afe0d6b651 6727043 Move winsysck to open source tree
Jay Cotton <Jay.Cotton@Sun.COM>
parents:
diff changeset
   214
c6afe0d6b651 6727043 Move winsysck to open source tree
Jay Cotton <Jay.Cotton@Sun.COM>
parents:
diff changeset
   215
	if [ x"$chowncmd" != x ]; then $doit $chowncmd "$dst"; else : ; fi &&
c6afe0d6b651 6727043 Move winsysck to open source tree
Jay Cotton <Jay.Cotton@Sun.COM>
parents:
diff changeset
   216
	if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd "$dst"; else : ; fi &&
c6afe0d6b651 6727043 Move winsysck to open source tree
Jay Cotton <Jay.Cotton@Sun.COM>
parents:
diff changeset
   217
	if [ x"$stripcmd" != x ]; then $doit $stripcmd "$dst"; else : ; fi &&
c6afe0d6b651 6727043 Move winsysck to open source tree
Jay Cotton <Jay.Cotton@Sun.COM>
parents:
diff changeset
   218
	if [ x"$chmodcmd" != x ]; then $doit $chmodcmd "$dst"; else : ; fi
c6afe0d6b651 6727043 Move winsysck to open source tree
Jay Cotton <Jay.Cotton@Sun.COM>
parents:
diff changeset
   219
else
c6afe0d6b651 6727043 Move winsysck to open source tree
Jay Cotton <Jay.Cotton@Sun.COM>
parents:
diff changeset
   220
c6afe0d6b651 6727043 Move winsysck to open source tree
Jay Cotton <Jay.Cotton@Sun.COM>
parents:
diff changeset
   221
# If we're going to rename the final executable, determine the name now.
c6afe0d6b651 6727043 Move winsysck to open source tree
Jay Cotton <Jay.Cotton@Sun.COM>
parents:
diff changeset
   222
c6afe0d6b651 6727043 Move winsysck to open source tree
Jay Cotton <Jay.Cotton@Sun.COM>
parents:
diff changeset
   223
	if [ x"$transformarg" = x ]
c6afe0d6b651 6727043 Move winsysck to open source tree
Jay Cotton <Jay.Cotton@Sun.COM>
parents:
diff changeset
   224
	then
c6afe0d6b651 6727043 Move winsysck to open source tree
Jay Cotton <Jay.Cotton@Sun.COM>
parents:
diff changeset
   225
		dstfile=`basename "$dst"`
c6afe0d6b651 6727043 Move winsysck to open source tree
Jay Cotton <Jay.Cotton@Sun.COM>
parents:
diff changeset
   226
	else
c6afe0d6b651 6727043 Move winsysck to open source tree
Jay Cotton <Jay.Cotton@Sun.COM>
parents:
diff changeset
   227
		dstfile=`basename "$dst" $transformbasename |
c6afe0d6b651 6727043 Move winsysck to open source tree
Jay Cotton <Jay.Cotton@Sun.COM>
parents:
diff changeset
   228
			sed $transformarg`$transformbasename
c6afe0d6b651 6727043 Move winsysck to open source tree
Jay Cotton <Jay.Cotton@Sun.COM>
parents:
diff changeset
   229
	fi
c6afe0d6b651 6727043 Move winsysck to open source tree
Jay Cotton <Jay.Cotton@Sun.COM>
parents:
diff changeset
   230
c6afe0d6b651 6727043 Move winsysck to open source tree
Jay Cotton <Jay.Cotton@Sun.COM>
parents:
diff changeset
   231
# don't allow the sed command to completely eliminate the filename
c6afe0d6b651 6727043 Move winsysck to open source tree
Jay Cotton <Jay.Cotton@Sun.COM>
parents:
diff changeset
   232
c6afe0d6b651 6727043 Move winsysck to open source tree
Jay Cotton <Jay.Cotton@Sun.COM>
parents:
diff changeset
   233
	if [ x"$dstfile" = x ]
c6afe0d6b651 6727043 Move winsysck to open source tree
Jay Cotton <Jay.Cotton@Sun.COM>
parents:
diff changeset
   234
	then
c6afe0d6b651 6727043 Move winsysck to open source tree
Jay Cotton <Jay.Cotton@Sun.COM>
parents:
diff changeset
   235
		dstfile=`basename "$dst"`
c6afe0d6b651 6727043 Move winsysck to open source tree
Jay Cotton <Jay.Cotton@Sun.COM>
parents:
diff changeset
   236
	else
c6afe0d6b651 6727043 Move winsysck to open source tree
Jay Cotton <Jay.Cotton@Sun.COM>
parents:
diff changeset
   237
		:
c6afe0d6b651 6727043 Move winsysck to open source tree
Jay Cotton <Jay.Cotton@Sun.COM>
parents:
diff changeset
   238
	fi
c6afe0d6b651 6727043 Move winsysck to open source tree
Jay Cotton <Jay.Cotton@Sun.COM>
parents:
diff changeset
   239
c6afe0d6b651 6727043 Move winsysck to open source tree
Jay Cotton <Jay.Cotton@Sun.COM>
parents:
diff changeset
   240
# Make a couple of temp file names in the proper directory.
c6afe0d6b651 6727043 Move winsysck to open source tree
Jay Cotton <Jay.Cotton@Sun.COM>
parents:
diff changeset
   241
c6afe0d6b651 6727043 Move winsysck to open source tree
Jay Cotton <Jay.Cotton@Sun.COM>
parents:
diff changeset
   242
	dsttmp=$dstdir/_inst.$$_
c6afe0d6b651 6727043 Move winsysck to open source tree
Jay Cotton <Jay.Cotton@Sun.COM>
parents:
diff changeset
   243
	rmtmp=$dstdir/_rm.$$_
c6afe0d6b651 6727043 Move winsysck to open source tree
Jay Cotton <Jay.Cotton@Sun.COM>
parents:
diff changeset
   244
c6afe0d6b651 6727043 Move winsysck to open source tree
Jay Cotton <Jay.Cotton@Sun.COM>
parents:
diff changeset
   245
# Trap to clean up temp files at exit.
c6afe0d6b651 6727043 Move winsysck to open source tree
Jay Cotton <Jay.Cotton@Sun.COM>
parents:
diff changeset
   246
c6afe0d6b651 6727043 Move winsysck to open source tree
Jay Cotton <Jay.Cotton@Sun.COM>
parents:
diff changeset
   247
	trap 'status=$?; rm -f "$dsttmp" "$rmtmp" && exit $status' 0
c6afe0d6b651 6727043 Move winsysck to open source tree
Jay Cotton <Jay.Cotton@Sun.COM>
parents:
diff changeset
   248
	trap '(exit $?); exit' 1 2 13 15
c6afe0d6b651 6727043 Move winsysck to open source tree
Jay Cotton <Jay.Cotton@Sun.COM>
parents:
diff changeset
   249
c6afe0d6b651 6727043 Move winsysck to open source tree
Jay Cotton <Jay.Cotton@Sun.COM>
parents:
diff changeset
   250
# Move or copy the file name to the temp name
c6afe0d6b651 6727043 Move winsysck to open source tree
Jay Cotton <Jay.Cotton@Sun.COM>
parents:
diff changeset
   251
c6afe0d6b651 6727043 Move winsysck to open source tree
Jay Cotton <Jay.Cotton@Sun.COM>
parents:
diff changeset
   252
	$doit $instcmd "$src" "$dsttmp" &&
c6afe0d6b651 6727043 Move winsysck to open source tree
Jay Cotton <Jay.Cotton@Sun.COM>
parents:
diff changeset
   253
c6afe0d6b651 6727043 Move winsysck to open source tree
Jay Cotton <Jay.Cotton@Sun.COM>
parents:
diff changeset
   254
# and set any options; do chmod last to preserve setuid bits
c6afe0d6b651 6727043 Move winsysck to open source tree
Jay Cotton <Jay.Cotton@Sun.COM>
parents:
diff changeset
   255
c6afe0d6b651 6727043 Move winsysck to open source tree
Jay Cotton <Jay.Cotton@Sun.COM>
parents:
diff changeset
   256
# If any of these fail, we abort the whole thing.  If we want to
c6afe0d6b651 6727043 Move winsysck to open source tree
Jay Cotton <Jay.Cotton@Sun.COM>
parents:
diff changeset
   257
# ignore errors from any of these, just make sure not to ignore
c6afe0d6b651 6727043 Move winsysck to open source tree
Jay Cotton <Jay.Cotton@Sun.COM>
parents:
diff changeset
   258
# errors from the above "$doit $instcmd $src $dsttmp" command.
c6afe0d6b651 6727043 Move winsysck to open source tree
Jay Cotton <Jay.Cotton@Sun.COM>
parents:
diff changeset
   259
c6afe0d6b651 6727043 Move winsysck to open source tree
Jay Cotton <Jay.Cotton@Sun.COM>
parents:
diff changeset
   260
	if [ x"$chowncmd" != x ]; then $doit $chowncmd "$dsttmp"; else :;fi &&
c6afe0d6b651 6727043 Move winsysck to open source tree
Jay Cotton <Jay.Cotton@Sun.COM>
parents:
diff changeset
   261
	if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd "$dsttmp"; else :;fi &&
c6afe0d6b651 6727043 Move winsysck to open source tree
Jay Cotton <Jay.Cotton@Sun.COM>
parents:
diff changeset
   262
	if [ x"$stripcmd" != x ]; then $doit $stripcmd "$dsttmp"; else :;fi &&
c6afe0d6b651 6727043 Move winsysck to open source tree
Jay Cotton <Jay.Cotton@Sun.COM>
parents:
diff changeset
   263
	if [ x"$chmodcmd" != x ]; then $doit $chmodcmd "$dsttmp"; else :;fi &&
c6afe0d6b651 6727043 Move winsysck to open source tree
Jay Cotton <Jay.Cotton@Sun.COM>
parents:
diff changeset
   264
c6afe0d6b651 6727043 Move winsysck to open source tree
Jay Cotton <Jay.Cotton@Sun.COM>
parents:
diff changeset
   265
# Now remove or move aside any old file at destination location.  We try this
c6afe0d6b651 6727043 Move winsysck to open source tree
Jay Cotton <Jay.Cotton@Sun.COM>
parents:
diff changeset
   266
# two ways since rm can't unlink itself on some systems and the destination
c6afe0d6b651 6727043 Move winsysck to open source tree
Jay Cotton <Jay.Cotton@Sun.COM>
parents:
diff changeset
   267
# file might be busy for other reasons.  In this case, the final cleanup
c6afe0d6b651 6727043 Move winsysck to open source tree
Jay Cotton <Jay.Cotton@Sun.COM>
parents:
diff changeset
   268
# might fail but the new file should still install successfully.
c6afe0d6b651 6727043 Move winsysck to open source tree
Jay Cotton <Jay.Cotton@Sun.COM>
parents:
diff changeset
   269
c6afe0d6b651 6727043 Move winsysck to open source tree
Jay Cotton <Jay.Cotton@Sun.COM>
parents:
diff changeset
   270
{
c6afe0d6b651 6727043 Move winsysck to open source tree
Jay Cotton <Jay.Cotton@Sun.COM>
parents:
diff changeset
   271
	if [ -f "$dstdir/$dstfile" ]
c6afe0d6b651 6727043 Move winsysck to open source tree
Jay Cotton <Jay.Cotton@Sun.COM>
parents:
diff changeset
   272
	then
c6afe0d6b651 6727043 Move winsysck to open source tree
Jay Cotton <Jay.Cotton@Sun.COM>
parents:
diff changeset
   273
		$doit $rmcmd -f "$dstdir/$dstfile" 2>/dev/null ||
c6afe0d6b651 6727043 Move winsysck to open source tree
Jay Cotton <Jay.Cotton@Sun.COM>
parents:
diff changeset
   274
		$doit $mvcmd -f "$dstdir/$dstfile" "$rmtmp" 2>/dev/null ||
c6afe0d6b651 6727043 Move winsysck to open source tree
Jay Cotton <Jay.Cotton@Sun.COM>
parents:
diff changeset
   275
		{
c6afe0d6b651 6727043 Move winsysck to open source tree
Jay Cotton <Jay.Cotton@Sun.COM>
parents:
diff changeset
   276
		  echo "$0: cannot unlink or rename $dstdir/$dstfile" >&2
c6afe0d6b651 6727043 Move winsysck to open source tree
Jay Cotton <Jay.Cotton@Sun.COM>
parents:
diff changeset
   277
		  (exit 1); exit
c6afe0d6b651 6727043 Move winsysck to open source tree
Jay Cotton <Jay.Cotton@Sun.COM>
parents:
diff changeset
   278
		}
c6afe0d6b651 6727043 Move winsysck to open source tree
Jay Cotton <Jay.Cotton@Sun.COM>
parents:
diff changeset
   279
	else
c6afe0d6b651 6727043 Move winsysck to open source tree
Jay Cotton <Jay.Cotton@Sun.COM>
parents:
diff changeset
   280
		:
c6afe0d6b651 6727043 Move winsysck to open source tree
Jay Cotton <Jay.Cotton@Sun.COM>
parents:
diff changeset
   281
	fi
c6afe0d6b651 6727043 Move winsysck to open source tree
Jay Cotton <Jay.Cotton@Sun.COM>
parents:
diff changeset
   282
} &&
c6afe0d6b651 6727043 Move winsysck to open source tree
Jay Cotton <Jay.Cotton@Sun.COM>
parents:
diff changeset
   283
c6afe0d6b651 6727043 Move winsysck to open source tree
Jay Cotton <Jay.Cotton@Sun.COM>
parents:
diff changeset
   284
# Now rename the file to the real destination.
c6afe0d6b651 6727043 Move winsysck to open source tree
Jay Cotton <Jay.Cotton@Sun.COM>
parents:
diff changeset
   285
c6afe0d6b651 6727043 Move winsysck to open source tree
Jay Cotton <Jay.Cotton@Sun.COM>
parents:
diff changeset
   286
	$doit $mvcmd "$dsttmp" "$dstdir/$dstfile"
c6afe0d6b651 6727043 Move winsysck to open source tree
Jay Cotton <Jay.Cotton@Sun.COM>
parents:
diff changeset
   287
c6afe0d6b651 6727043 Move winsysck to open source tree
Jay Cotton <Jay.Cotton@Sun.COM>
parents:
diff changeset
   288
fi &&
c6afe0d6b651 6727043 Move winsysck to open source tree
Jay Cotton <Jay.Cotton@Sun.COM>
parents:
diff changeset
   289
c6afe0d6b651 6727043 Move winsysck to open source tree
Jay Cotton <Jay.Cotton@Sun.COM>
parents:
diff changeset
   290
# The final little trick to "correctly" pass the exit status to the exit trap.
c6afe0d6b651 6727043 Move winsysck to open source tree
Jay Cotton <Jay.Cotton@Sun.COM>
parents:
diff changeset
   291
c6afe0d6b651 6727043 Move winsysck to open source tree
Jay Cotton <Jay.Cotton@Sun.COM>
parents:
diff changeset
   292
{
c6afe0d6b651 6727043 Move winsysck to open source tree
Jay Cotton <Jay.Cotton@Sun.COM>
parents:
diff changeset
   293
	(exit 0); exit
c6afe0d6b651 6727043 Move winsysck to open source tree
Jay Cotton <Jay.Cotton@Sun.COM>
parents:
diff changeset
   294
}