install-sh revision 87
2521N/A# install - install a program, script, or datafile 2521N/A# following copyright and license. 2521N/A# Copyright (C) 1994 X Consortium 2521N/A# Permission is hereby granted, free of charge, to any person obtaining a copy 2521N/A# of this software and associated documentation files (the "Software"), to 2521N/A# deal in the Software without restriction, including without limitation the 2521N/A# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or 2521N/A# sell copies of the Software, and to permit persons to whom the Software is 2521N/A# furnished to do so, subject to the following conditions: 2521N/A# The above copyright notice and this permission notice shall be included in 2521N/A# all copies or substantial portions of the Software. 2521N/A# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 2521N/A# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 2521N/A# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 2521N/A# X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN 2521N/A# AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNEC- 2521N/A# TION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 2521N/A# Except as contained in this notice, the name of the X Consortium shall not 2521N/A# be used in advertising or otherwise to promote the sale, use or other deal- 2521N/A# ings in this Software without prior written authorization from the X Consor- 3998N/A# FSF changes to this file are in the public domain. 3998N/A# `make' implicit rules from creating a file called install from it 6852N/A# when there is no Makefile. 6029N/A# This script is compatible with the BSD install script, but was written 6029N/A# from scratch. It can only install one file at a time, a restriction 6029N/A# shared with many OS's install programs. 2521N/A# set DOITPROG to echo to test this script 2521N/A# Don't use :- since 4.3BSD and earlier shells don't like it. 2892N/A# put in absolute paths if you don't have them in your path; or use env. vars. 2521N/A or: $0 [OPTION]... SRCFILES... DIRECTORY 2521N/AIn the first form, install SRCFILE to DSTFILE, removing SRCFILE by default. 2521N/AIn the second, create the directory path DIR. 2521N/A-d create directories instead of installing files. 2521N/A--help display this help and exit. 2521N/A--version display version info and exit. 2521N/AEnvironment variables override the default commands: 2521N/A CHGRPPROG CHMODPROG CHOWNPROG CPPROG MKDIRPROG MVPROG RMPROG STRIPPROG *)
# When -d is used, all remaining arguments are directories to create. # Otherwise, the last argument is the destination. Remove it from $@. # $@ is not empty: it contains at least $arg. echo "$0: no input file specified." >&
2 # It's OK to call `install-sh -d' without argument. # This can happen when creating conditional directories. # Protect names starting with `-'. # Waiting for this to be detected by the "$instcmd $src $dsttmp" command # might cause directories to be created, which would be especially bad # if $src (and thus $dsttmp) contains '*'. if test ! -f
"$src" &&
test ! -d
"$src";
then echo "$0: $src does not exist." >&
2 echo "$0: no destination specified." >&
2 # Protect names starting with `-'. # If destination is a directory, append the input filename; won't work # if double slashes aren't ignored. # This sed command emulates the dirname command. # Make sure that the destination directory exists. # Skip lots of stat calls in the usual case. # Some sh's can't handle IFS=/ for some reason. set -
`echo "$dstdir" | sed -e 's@/@%@g' -e 's@^%@/@'` # mkdir can fail with a `File exist' error in case several # install-sh are creating the directory concurrently. This *.
la)
doit=
"echo SKIPPING " ;;
*)
doit=
"${DOITPROG-}" ;;
# If we're going to rename the final executable, determine the name now. # don't allow the sed command to completely eliminate the filename. # Make a couple of temp file names in the proper directory. # Trap to clean up those temp files at exit. trap 'status=$?; rm -f "$dsttmp" "$rmtmp" && exit $status' 0 trap '(exit $?); exit' 1 2 13 15 # Move or copy the file name to the temp name # and set any options; do chmod last to preserve setuid bits. # If any of these fail, we abort the whole thing. If we want to # ignore errors from any of these, just make sure not to ignore # errors from the above "$doit $instcmd $src $dsttmp" command. # Now remove or move aside any old file at destination location. We # try this two ways since rm can't unlink itself on some systems and # the destination file might be busy for other reasons. In this case, # the final cleanup might fail but the new file should still install # Now rename the file to the real destination. fi ||
{ (exit 1); exit; } # The final little trick to "correctly" pass the exit status to the exit trap. # eval: (add-hook 'write-file-hooks 'time-stamp) # time-stamp-start: "scriptversion=" # time-stamp-format: "%:y-%02m-%02d.%02H"