a260560bdbc7bd737d59547882cd5e8d77b80d0avboxsync# install - install a program, script, or datafile
a260560bdbc7bd737d59547882cd5e8d77b80d0avboxsync# This comes from X11R5 (mit/util/scripts/install.sh).
a260560bdbc7bd737d59547882cd5e8d77b80d0avboxsync# Copyright 1991 by the Massachusetts Institute of Technology
a260560bdbc7bd737d59547882cd5e8d77b80d0avboxsync# Permission to use, copy, modify, distribute, and sell this software and its
a260560bdbc7bd737d59547882cd5e8d77b80d0avboxsync# documentation for any purpose is hereby granted without fee, provided that
a260560bdbc7bd737d59547882cd5e8d77b80d0avboxsync# the above copyright notice appear in all copies and that both that
a260560bdbc7bd737d59547882cd5e8d77b80d0avboxsync# copyright notice and this permission notice appear in supporting
a260560bdbc7bd737d59547882cd5e8d77b80d0avboxsync# documentation, and that the name of M.I.T. not be used in advertising or
a260560bdbc7bd737d59547882cd5e8d77b80d0avboxsync# publicity pertaining to distribution of the software without specific,
a260560bdbc7bd737d59547882cd5e8d77b80d0avboxsync# written prior permission. M.I.T. makes no representations about the
a260560bdbc7bd737d59547882cd5e8d77b80d0avboxsync# suitability of this software for any purpose. It is provided "as is"
a260560bdbc7bd737d59547882cd5e8d77b80d0avboxsync# without express or implied warranty.
a260560bdbc7bd737d59547882cd5e8d77b80d0avboxsync# Calling this script install-sh is preferred over install.sh, to prevent
a260560bdbc7bd737d59547882cd5e8d77b80d0avboxsync# `make' implicit rules from creating a file called install from it
a260560bdbc7bd737d59547882cd5e8d77b80d0avboxsync# when there is no Makefile.
a260560bdbc7bd737d59547882cd5e8d77b80d0avboxsync# This script is compatible with the BSD install script, but was written
a260560bdbc7bd737d59547882cd5e8d77b80d0avboxsync# from scratch. It can only install one file at a time, a restriction
a260560bdbc7bd737d59547882cd5e8d77b80d0avboxsync# shared with many OS's install programs.
a260560bdbc7bd737d59547882cd5e8d77b80d0avboxsync# set DOITPROG to echo to test this script
a260560bdbc7bd737d59547882cd5e8d77b80d0avboxsync# Don't use :- since 4.3BSD and earlier shells don't like it.
a260560bdbc7bd737d59547882cd5e8d77b80d0avboxsync# put in absolute paths if you don't have them in your path; or use env. vars.
a260560bdbc7bd737d59547882cd5e8d77b80d0avboxsyncwhile [ x"$1" != x ]; do
a260560bdbc7bd737d59547882cd5e8d77b80d0avboxsync *) if [ x"$src" = x ]
a260560bdbc7bd737d59547882cd5e8d77b80d0avboxsync # this colon is to work around a 386BSD /bin/sh bug
a260560bdbc7bd737d59547882cd5e8d77b80d0avboxsyncif [ x"$src" = x ]
a260560bdbc7bd737d59547882cd5e8d77b80d0avboxsync echo "install: no input file specified"
a260560bdbc7bd737d59547882cd5e8d77b80d0avboxsyncif [ x"$dir_arg" != x ]; then
a260560bdbc7bd737d59547882cd5e8d77b80d0avboxsync if [ -d $dst ]; then
a260560bdbc7bd737d59547882cd5e8d77b80d0avboxsync# Waiting for this to be detected by the "$instcmd $src $dsttmp" command
a260560bdbc7bd737d59547882cd5e8d77b80d0avboxsync# might cause directories to be created, which would be especially bad
a260560bdbc7bd737d59547882cd5e8d77b80d0avboxsync# if $src (and thus $dsttmp) contains '*'.
a260560bdbc7bd737d59547882cd5e8d77b80d0avboxsync echo "install: $src does not exist"
a260560bdbc7bd737d59547882cd5e8d77b80d0avboxsync if [ x"$dst" = x ]
a260560bdbc7bd737d59547882cd5e8d77b80d0avboxsync echo "install: no destination specified"
a260560bdbc7bd737d59547882cd5e8d77b80d0avboxsync# If destination is a directory, append the input filename; if your system
a260560bdbc7bd737d59547882cd5e8d77b80d0avboxsync# does not like double slashes in filenames, you may need to add some logic
a260560bdbc7bd737d59547882cd5e8d77b80d0avboxsync## this sed command emulates the dirname command
a260560bdbc7bd737d59547882cd5e8d77b80d0avboxsyncdstdir=`echo $dst | sed -e 's,[^/]*$,,;s,/$,,;s,^$,.,'`
a260560bdbc7bd737d59547882cd5e8d77b80d0avboxsync# Make sure that the destination directory exists.
a260560bdbc7bd737d59547882cd5e8d77b80d0avboxsync# this part is taken from Noah Friedman's mkinstalldirs script
a260560bdbc7bd737d59547882cd5e8d77b80d0avboxsync# Skip lots of stat calls in the usual case.
a260560bdbc7bd737d59547882cd5e8d77b80d0avboxsyncif [ ! -d "$dstdir" ]; then
a260560bdbc7bd737d59547882cd5e8d77b80d0avboxsync# Some sh's can't handle IFS=/ for some reason.
a260560bdbc7bd737d59547882cd5e8d77b80d0avboxsyncset - `echo ${dstdir} | sed -e 's@/@%@g' -e 's@^%@/@'`
a260560bdbc7bd737d59547882cd5e8d77b80d0avboxsync if [ ! -d "${pathcomp}" ] ;
a260560bdbc7bd737d59547882cd5e8d77b80d0avboxsyncif [ x"$dir_arg" != x ]
a260560bdbc7bd737d59547882cd5e8d77b80d0avboxsync if [ x"$chowncmd" != x ]; then $doit $chowncmd $dst; else true ; fi &&
a260560bdbc7bd737d59547882cd5e8d77b80d0avboxsync if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd $dst; else true ; fi &&
a260560bdbc7bd737d59547882cd5e8d77b80d0avboxsync if [ x"$stripcmd" != x ]; then $doit $stripcmd $dst; else true ; fi &&
a260560bdbc7bd737d59547882cd5e8d77b80d0avboxsync if [ x"$chmodcmd" != x ]; then $doit $chmodcmd $dst; else true ; fi
a260560bdbc7bd737d59547882cd5e8d77b80d0avboxsync# If we're going to rename the final executable, determine the name now.
a260560bdbc7bd737d59547882cd5e8d77b80d0avboxsync# don't allow the sed command to completely eliminate the filename
a260560bdbc7bd737d59547882cd5e8d77b80d0avboxsync if [ x"$dstfile" = x ]
a260560bdbc7bd737d59547882cd5e8d77b80d0avboxsync# Make a temp file name in the proper directory.
a260560bdbc7bd737d59547882cd5e8d77b80d0avboxsync# Move or copy the file name to the temp name
a260560bdbc7bd737d59547882cd5e8d77b80d0avboxsync# and set any options; do chmod last to preserve setuid bits
a260560bdbc7bd737d59547882cd5e8d77b80d0avboxsync# If any of these fail, we abort the whole thing. If we want to
a260560bdbc7bd737d59547882cd5e8d77b80d0avboxsync# ignore errors from any of these, just make sure not to ignore
a260560bdbc7bd737d59547882cd5e8d77b80d0avboxsync# errors from the above "$doit $instcmd $src $dsttmp" command.
a260560bdbc7bd737d59547882cd5e8d77b80d0avboxsync if [ x"$chowncmd" != x ]; then $doit $chowncmd $dsttmp; else true;fi &&
a260560bdbc7bd737d59547882cd5e8d77b80d0avboxsync if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd $dsttmp; else true;fi &&
a260560bdbc7bd737d59547882cd5e8d77b80d0avboxsync if [ x"$stripcmd" != x ]; then $doit $stripcmd $dsttmp; else true;fi &&
a260560bdbc7bd737d59547882cd5e8d77b80d0avboxsync if [ x"$chmodcmd" != x ]; then $doit $chmodcmd $dsttmp; else true;fi &&
a260560bdbc7bd737d59547882cd5e8d77b80d0avboxsync# Now rename the file to the real destination.