install-sh revision 1b8adde7ba7d5e04395c141c5400dc2cffd7d809
d9abda6d63cc31c8a81d9c84275c9bd4c8ae8f57Klaus Luettich# install - install a program, script, or datafile
d9abda6d63cc31c8a81d9c84275c9bd4c8ae8f57Klaus Luettich# This originates from X11R5 (mit/util/scripts/install.sh), which was
34bff097c14521b5e57ce37279a34256e1f78aa5Klaus Luettich# later released in X11R6 (xc/config/util/install.sh) with the
d9abda6d63cc31c8a81d9c84275c9bd4c8ae8f57Klaus Luettich# following copyright and license.
d9abda6d63cc31c8a81d9c84275c9bd4c8ae8f57Klaus Luettich# Copyright (C) 1994 X Consortium
d543cf2bb0c810781625c76fe135476d46270d88Till Mossakowski# Permission is hereby granted, free of charge, to any person obtaining a copy
9753523d7bfe7c9413207e8f0c7548bd3dc15322Christian Maeder# of this software and associated documentation files (the "Software"), to
d9abda6d63cc31c8a81d9c84275c9bd4c8ae8f57Klaus Luettich# deal in the Software without restriction, including without limitation the
d9abda6d63cc31c8a81d9c84275c9bd4c8ae8f57Klaus Luettich# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
d9abda6d63cc31c8a81d9c84275c9bd4c8ae8f57Klaus Luettich# sell copies of the Software, and to permit persons to whom the Software is
d9abda6d63cc31c8a81d9c84275c9bd4c8ae8f57Klaus Luettich# furnished to do so, subject to the following conditions:
ad270004874ce1d0697fb30d7309f180553bb315Christian Maeder# The above copyright notice and this permission notice shall be included in
ad270004874ce1d0697fb30d7309f180553bb315Christian Maeder# all copies or substantial portions of the Software.
8b66de47c89e252c907c8ed3a5ccd16dbccbfb3eChristian Maeder# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
d9abda6d63cc31c8a81d9c84275c9bd4c8ae8f57Klaus Luettich# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
e51568cd733ccb83a799f48f0802095e3f3a8d62Christian Maeder# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
d9abda6d63cc31c8a81d9c84275c9bd4c8ae8f57Klaus Luettich# X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
d9abda6d63cc31c8a81d9c84275c9bd4c8ae8f57Klaus Luettich# AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNEC-
d9abda6d63cc31c8a81d9c84275c9bd4c8ae8f57Klaus Luettich# TION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
87ab788adadc73fd49e3c762caee6a88f844a5bcChristian Maeder# Except as contained in this notice, the name of the X Consortium shall not
87ab788adadc73fd49e3c762caee6a88f844a5bcChristian Maeder# be used in advertising or otherwise to promote the sale, use or other deal-
d9abda6d63cc31c8a81d9c84275c9bd4c8ae8f57Klaus Luettich# ings in this Software without prior written authorization from the X Consor-
0a943b3aa43eff8a8d5f42da56fa895e13c7040cKlaus Luettich# FSF changes to this file are in the public domain.
0a943b3aa43eff8a8d5f42da56fa895e13c7040cKlaus Luettich# Calling this script install-sh is preferred over install.sh, to prevent
d9abda6d63cc31c8a81d9c84275c9bd4c8ae8f57Klaus Luettich# `make' implicit rules from creating a file called install from it
d9abda6d63cc31c8a81d9c84275c9bd4c8ae8f57Klaus Luettich# when there is no Makefile.
87ab788adadc73fd49e3c762caee6a88f844a5bcChristian Maeder# This script is compatible with the BSD install script, but was written
e51568cd733ccb83a799f48f0802095e3f3a8d62Christian Maeder# from scratch. It can only install one file at a time, a restriction
d9abda6d63cc31c8a81d9c84275c9bd4c8ae8f57Klaus Luettich# shared with many OS's install programs.
0a943b3aa43eff8a8d5f42da56fa895e13c7040cKlaus Luettich# set DOITPROG to echo to test this script
8b66de47c89e252c907c8ed3a5ccd16dbccbfb3eChristian Maeder# Don't use :- since 4.3BSD and earlier shells don't like it.
427aeade34f2771c0295250e9a94b89489bb9204Christian Maeder# put in absolute paths if you don't have them in your path; or use env. vars.
9753523d7bfe7c9413207e8f0c7548bd3dc15322Christian Maederusage="Usage: $0 [OPTION]... [-T] SRCFILE DSTFILE
9753523d7bfe7c9413207e8f0c7548bd3dc15322Christian Maeder or: $0 [OPTION]... SRCFILES... DIRECTORY
433bc07a43dd58f7ca4c93b6ea5a026a2dcb114dChristian Maeder or: $0 [OPTION]... -t DIRECTORY SRCFILES...
433bc07a43dd58f7ca4c93b6ea5a026a2dcb114dChristian Maeder or: $0 [OPTION]... -d DIRECTORIES...
433bc07a43dd58f7ca4c93b6ea5a026a2dcb114dChristian MaederIn the 1st form, copy SRCFILE to DSTFILE.
d9abda6d63cc31c8a81d9c84275c9bd4c8ae8f57Klaus LuettichIn the 2nd and 3rd, copy all SRCFILES to DIRECTORY.
d9abda6d63cc31c8a81d9c84275c9bd4c8ae8f57Klaus LuettichIn the 4th, create DIRECTORIES.
10a655fc665d418549eefbc09baccbaaff913670Till Mossakowski-d create directories instead of installing files.
10a655fc665d418549eefbc09baccbaaff913670Till Mossakowski-g GROUP $chgrpprog installed files to GROUP.
10a655fc665d418549eefbc09baccbaaff913670Till Mossakowski-m MODE $chmodprog installed files to MODE.
d9abda6d63cc31c8a81d9c84275c9bd4c8ae8f57Klaus Luettich-o USER $chownprog installed files to USER.
d9abda6d63cc31c8a81d9c84275c9bd4c8ae8f57Klaus Luettich-s $stripprog installed files.
d9abda6d63cc31c8a81d9c84275c9bd4c8ae8f57Klaus Luettich-t DIRECTORY install into DIRECTORY.
d9abda6d63cc31c8a81d9c84275c9bd4c8ae8f57Klaus Luettich-T report an error if DSTFILE is a directory.
d9abda6d63cc31c8a81d9c84275c9bd4c8ae8f57Klaus Luettich--help display this help and exit.
c1a0a4f5712942d8ef09bfdb5b8d1e3b576ab438Christian Maeder--version display version info and exit.
d9abda6d63cc31c8a81d9c84275c9bd4c8ae8f57Klaus LuettichEnvironment variables override the default commands:
9753523d7bfe7c9413207e8f0c7548bd3dc15322Christian Maeder CHGRPPROG CHMODPROG CHOWNPROG CPPROG MKDIRPROG MVPROG RMPROG STRIPPROG
d9abda6d63cc31c8a81d9c84275c9bd4c8ae8f57Klaus Luettichwhile test -n "$1"; do
513ec62039bb1028efafff52f0e0e22d57da261eChristian Maeder --version) echo "$0 $scriptversion"; exit 0;;
513ec62039bb1028efafff52f0e0e22d57da261eChristian Maeder *) # When -d is used, all remaining arguments are directories to create.
513ec62039bb1028efafff52f0e0e22d57da261eChristian Maeder # When -t is used, the destination is already specified.
513ec62039bb1028efafff52f0e0e22d57da261eChristian Maeder test -n "$dir_arg$dstarg" && break
513ec62039bb1028efafff52f0e0e22d57da261eChristian Maeder # Otherwise, the last argument is the destination. Remove it from $@.
513ec62039bb1028efafff52f0e0e22d57da261eChristian Maeder if test -n "$dstarg"; then
513ec62039bb1028efafff52f0e0e22d57da261eChristian Maeder # $@ is not empty: it contains at least $arg.
513ec62039bb1028efafff52f0e0e22d57da261eChristian Maeder shift # fnord
513ec62039bb1028efafff52f0e0e22d57da261eChristian Maederif test -z "$1"; then
513ec62039bb1028efafff52f0e0e22d57da261eChristian Maeder if test -z "$dir_arg"; then
513ec62039bb1028efafff52f0e0e22d57da261eChristian Maeder # It's OK to call `install-sh -d' without argument.
513ec62039bb1028efafff52f0e0e22d57da261eChristian Maeder # This can happen when creating conditional directories.
513ec62039bb1028efafff52f0e0e22d57da261eChristian Maeder # Protect names starting with `-'.
513ec62039bb1028efafff52f0e0e22d57da261eChristian Maeder if test -n "$dir_arg"; then
513ec62039bb1028efafff52f0e0e22d57da261eChristian Maeder if test -d "$dst"; then
513ec62039bb1028efafff52f0e0e22d57da261eChristian Maeder # Waiting for this to be detected by the "$cpprog $src $dsttmp" command
513ec62039bb1028efafff52f0e0e22d57da261eChristian Maeder # might cause directories to be created, which would be especially bad
513ec62039bb1028efafff52f0e0e22d57da261eChristian Maeder # if $src (and thus $dsttmp) contains '*'.
513ec62039bb1028efafff52f0e0e22d57da261eChristian Maeder if test ! -f "$src" && test ! -d "$src"; then
513ec62039bb1028efafff52f0e0e22d57da261eChristian Maeder if test -z "$dstarg"; then
513ec62039bb1028efafff52f0e0e22d57da261eChristian Maeder # Protect names starting with `-'.
513ec62039bb1028efafff52f0e0e22d57da261eChristian Maeder # If destination is a directory, append the input filename; won't work
513ec62039bb1028efafff52f0e0e22d57da261eChristian Maeder # if double slashes aren't ignored.
513ec62039bb1028efafff52f0e0e22d57da261eChristian Maeder if test -d "$dst"; then
513ec62039bb1028efafff52f0e0e22d57da261eChristian Maeder if test -n "$no_target_directory"; then
if test ! -d "$dstdir"; then
if test ! -d "$pathcomp"; then
test -d "$pathcomp" || exit
if test -n "$dir_arg"; then