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