2N/A# install - install a program, script, or datafile 2N/A# following copyright and license. 2N/A# Copyright (C) 1994 X Consortium 2N/A# Permission is hereby granted, free of charge, to any person obtaining a copy 2N/A# of this software and associated documentation files (the "Software"), to 2N/A# deal in the Software without restriction, including without limitation the 2N/A# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or 2N/A# sell copies of the Software, and to permit persons to whom the Software is 2N/A# furnished to do so, subject to the following conditions: 2N/A# The above copyright notice and this permission notice shall be included in 2N/A# all copies or substantial portions of the Software. 2N/A# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 2N/A# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 2N/A# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 2N/A# X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN 2N/A# AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNEC- 2N/A# TION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 2N/A# Except as contained in this notice, the name of the X Consortium shall not 2N/A# be used in advertising or otherwise to promote the sale, use or other deal- 2N/A# ings in this Software without prior written authorization from the X Consor- 2N/A# FSF changes to this file are in the public domain. 2N/A# Calling this script install-sh is preferred over install.sh, to prevent 2N/A# `make' implicit rules from creating a file called install from it 2N/A# when there is no Makefile. 2N/A# This script is compatible with the BSD install script, but was written 2N/A# set DOITPROG to echo to test this script 2N/A# Don't use :- since 4.3BSD and earlier shells don't like it. 2N/A# Put in absolute file names if you don't have them in your path; 2N/A# or use environment vars. 2N/A# Desired mode of installed file. 2N/Ausage=
"Usage: $0 [OPTION]... [-T] SRCFILE DSTFILE 2N/A or: $0 [OPTION]... SRCFILES... DIRECTORY 2N/A or: $0 [OPTION]... -t DIRECTORY SRCFILES... 2N/A or: $0 [OPTION]... -d DIRECTORIES... 2N/AIn the 1st form, copy SRCFILE to DSTFILE. 2N/AIn the 2nd and 3rd, copy all SRCFILES to DIRECTORY. 2N/AIn the 4th, create DIRECTORIES. 2N/A-d create directories instead of installing files. 2N/A-t DIRECTORY install into DIRECTORY. 2N/A-T report an error if DSTFILE is a directory. 2N/A--help display this help and exit. 2N/A--version display version info and exit. 2N/AEnvironment variables override the default commands: 2N/A CHGRPPROG CHMODPROG CHOWNPROG CPPROG MKDIRPROG MVPROG RMPROG STRIPPROG 2N/A'* | *
'*'* | *
'?'* | *
'['*)
2N/A -*)
echo "$0: invalid option: $1" >&
2 2N/A # When -d is used, all remaining arguments are directories to create. 2N/A # When -t is used, the destination is already specified. 2N/A # Otherwise, the last argument is the destination. Remove it from $@. 2N/A # $@ is not empty: it contains at least $arg. 2N/A echo "$0: no input file specified." >&
2 2N/A # It's OK to call `install-sh -d' without argument. 2N/A # This can happen when creating conditional directories. 2N/A trap '(exit $?); exit' 1 2 13 15 2N/A # Set umask so as not to create temps with too-generous modes. 2N/A # However, 'strip' requires both read and write access to temps. 2N/A # Optimize common cases. 2N/A # Protect names starting with `-'. 2N/A # Waiting for this to be detected by the "$cpprog $src $dsttmp" command 2N/A # might cause directories to be created, which would be especially bad 2N/A # if $src (and thus $dsttmp) contains '*'. 2N/A echo "$0: $src does not exist." >&
2 2N/A echo "$0: no destination specified." >&
2 2N/A # Protect names starting with `-'. 2N/A # If destination is a directory, append the input filename; won't work 2N/A # if double slashes aren't ignored. 2N/A # Prefer dirname, but fall back on a substitute if dirname fails. 2N/A sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ 2N/A # Create intermediate dirs using mode 755 as modified by the umask. 2N/A # This is like FreeBSD 'install' as of 1997-10-28. 2N/A # Optimize common cases. 2N/A # With -d, create the new directory with the user-specified mode. 2N/A # Otherwise, rely on $mkdir_umask. 2N/A *[
123567][
0-
7][
0-
7])
2N/A # POSIX mkdir -p sets u+wx bits regardless of umask, which 2N/A # is incompatible with FreeBSD 'install' when (umask & 300) != 0. 2N/A trap 'ret=$?; rmdir "$tmpdir/d" "$tmpdir" 2>/dev/null; exit $ret' 0 2N/A # Check for POSIX incompatibilities with -m. 2N/A # HP-UX 11.23 and IRIX 6.5 mkdir -m -p sets group- or 2N/A # other-writeable bit of parent directory when it shouldn't. 2N/A # FreeBSD 6.1 mkdir -m -p sets mode of existing directory. 2N/A # Remove any dirs left behind by ancient mkdir implementations. 2N/A # The umask is ridiculous, or mkdir does not conform to POSIX, 2N/A # or it failed possibly due to a race condition. Create the 2N/A # directory the slow way, step by step, checking for races as we go. 2N/A test -z
"$d" &&
continue 2N/A # Don't fail if two instances are running concurrently. 2N/A # Don't fail if two instances are running concurrently. 2N/A # Make a couple of temp file names in the proper directory. 2N/A # Trap to clean up those temp files at exit. 2N/A trap 'ret=$?; rm -f "$dsttmp" "$rmtmp" && exit $ret' 0 2N/A # Copy the file name to the temp name. 2N/A # and set any options; do chmod last to preserve setuid bits. 2N/A # If any of these fail, we abort the whole thing. If we want to 2N/A # ignore errors from any of these, just make sure not to ignore 2N/A # errors from the above "$doit $cpprog $src $dsttmp" command. 2N/A # Now rename the file to the real destination. 2N/A # The rename failed, perhaps because mv can't rename something else 2N/A # to itself, or perhaps because mv is so ancient that it does not 2N/A # Now remove or move aside any old file at destination location. 2N/A # We try this two ways since rm can't unlink itself on some 2N/A # systems and the destination file might be busy for other 2N/A # reasons. In this case, the final cleanup might fail but the new 2N/A # file should still install successfully. 2N/A echo "$0: cannot unlink or rename $dst" >&2 2N/A # Now rename the file to the real destination. 2N/A# eval: (add-hook 'write-file-hooks 'time-stamp) 2N/A# time-stamp-start: "scriptversion=" 2N/A# time-stamp-format: "%:y-%02m-%02d.%02H" 2N/A# time-stamp-end: "$"