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