install-sh revision a747113422afaa29ce72d2c5ba7f0b7ea9ec2054
f2314fbd7911bacccf87d13562b38fafa1aac9eaMichael Graff# $NetBSD: install-sh.in,v 1.6 2012/01/11 13:07:31 hans Exp $
f2314fbd7911bacccf87d13562b38fafa1aac9eaMichael Graff# This script now also installs multiple files, but might choke on installing
f2314fbd7911bacccf87d13562b38fafa1aac9eaMichael Graff# multiple files with spaces in the file names.
f2314fbd7911bacccf87d13562b38fafa1aac9eaMichael Graff# install - install a program, script, or datafile
f2314fbd7911bacccf87d13562b38fafa1aac9eaMichael Graff# This comes from X11R5 (mit/util/scripts/install.sh).
f2314fbd7911bacccf87d13562b38fafa1aac9eaMichael Graff# Copyright 1991 by the Massachusetts Institute of Technology
f2314fbd7911bacccf87d13562b38fafa1aac9eaMichael Graff# Permission to use, copy, modify, distribute, and sell this software and its
f2314fbd7911bacccf87d13562b38fafa1aac9eaMichael Graff# documentation for any purpose is hereby granted without fee, provided that
f2314fbd7911bacccf87d13562b38fafa1aac9eaMichael Graff# the above copyright notice appear in all copies and that both that
f2314fbd7911bacccf87d13562b38fafa1aac9eaMichael Graff# copyright notice and this permission notice appear in supporting
f2314fbd7911bacccf87d13562b38fafa1aac9eaMichael Graff# documentation, and that the name of M.I.T. not be used in advertising or
bb2d54f1b3654857b8cb0209612ed847afbd9d3cMichael Graff# publicity pertaining to distribution of the software without specific,
9c3531d72aeaad6c5f01efe6a1c82023e1379e4dDavid Lawrence# written prior permission. M.I.T. makes no representations about the
9c3531d72aeaad6c5f01efe6a1c82023e1379e4dDavid Lawrence# suitability of this software for any purpose. It is provided "as is"
bb2d54f1b3654857b8cb0209612ed847afbd9d3cMichael Graff# without express or implied warranty.
bb2d54f1b3654857b8cb0209612ed847afbd9d3cMichael Graff# Calling this script install-sh is preferred over install.sh, to prevent
bb2d54f1b3654857b8cb0209612ed847afbd9d3cMichael Graff# `make' implicit rules from creating a file called install from it
bb2d54f1b3654857b8cb0209612ed847afbd9d3cMichael Graff# when there is no Makefile.
bb2d54f1b3654857b8cb0209612ed847afbd9d3cMichael Graff# This script is compatible with the BSD install script, but was written
bb2d54f1b3654857b8cb0209612ed847afbd9d3cMichael Graff# from scratch.
bb2d54f1b3654857b8cb0209612ed847afbd9d3cMichael Graff# set DOITPROG to echo to test this script
bb2d54f1b3654857b8cb0209612ed847afbd9d3cMichael Graff# Don't use :- since 4.3BSD and earlier shells don't like it.
bb2d54f1b3654857b8cb0209612ed847afbd9d3cMichael Graff# put in absolute paths if you don't have them in your path; or use env. vars.
bb2d54f1b3654857b8cb0209612ed847afbd9d3cMichael Graffwhile [ x"$1" != x ]; do
bb2d54f1b3654857b8cb0209612ed847afbd9d3cMichael Graff *) if [ x"$msrc" = x ]
bb2d54f1b3654857b8cb0209612ed847afbd9d3cMichael Graff if [ ! -d "$dst" ]
bb2d54f1b3654857b8cb0209612ed847afbd9d3cMichael Graff echo "install: destination is not a directory"
bb2d54f1b3654857b8cb0209612ed847afbd9d3cMichael Graff echo "install: no destination specified"
bb2d54f1b3654857b8cb0209612ed847afbd9d3cMichael Graffif [ x"$dir_arg" != x ]; then
bb2d54f1b3654857b8cb0209612ed847afbd9d3cMichael Graff# Waiting for this to be detected by the "$instcmd $srcarg $dsttmp" command
bb2d54f1b3654857b8cb0209612ed847afbd9d3cMichael Graff# might cause directories to be created, which would be especially bad
bb2d54f1b3654857b8cb0209612ed847afbd9d3cMichael Graff# if $src (and thus $dsttmp) contains '*'.
bb2d54f1b3654857b8cb0209612ed847afbd9d3cMichael Graff elif [ -d "$srcarg" ]
bb2d54f1b3654857b8cb0209612ed847afbd9d3cMichael Graff echo "install: $srcarg: not a regular file"
bb2d54f1b3654857b8cb0209612ed847afbd9d3cMichael Graff echo "install: $srcarg does not exist"
bb2d54f1b3654857b8cb0209612ed847afbd9d3cMichael Graff# If destination is a directory, append the input filename; if your system
bb2d54f1b3654857b8cb0209612ed847afbd9d3cMichael Graff# does not like double slashes in filenames, you may need to add some logic
bb2d54f1b3654857b8cb0209612ed847afbd9d3cMichael Graff## this sed command emulates the dirname command
bb2d54f1b3654857b8cb0209612ed847afbd9d3cMichael Graffdstdir=`echo "$dstarg" | sed -e 's,[^/]*$,,;s,/$,,;s,^$,.,'`
bb2d54f1b3654857b8cb0209612ed847afbd9d3cMichael Graff# Make sure that the destination directory exists.
bb2d54f1b3654857b8cb0209612ed847afbd9d3cMichael Graff# this part is taken from Noah Friedman's mkinstalldirs script
bb2d54f1b3654857b8cb0209612ed847afbd9d3cMichael Graff# Skip lots of stat calls in the usual case.
bb2d54f1b3654857b8cb0209612ed847afbd9d3cMichael Graffif [ ! -d "$dstdir" ]; then
bb2d54f1b3654857b8cb0209612ed847afbd9d3cMichael Graff# Some sh's can't handle IFS=/ for some reason.
bb2d54f1b3654857b8cb0209612ed847afbd9d3cMichael Graffset - `echo ${dstdir} | sed -e 's@/@%@g' -e 's@^%@/@'`
bb2d54f1b3654857b8cb0209612ed847afbd9d3cMichael Graff if [ ! -d "${pathcomp}" ] ;
bb2d54f1b3654857b8cb0209612ed847afbd9d3cMichael Graff if [ x"$chowncmd" != x ]; then $doit $chowncmd "${pathcomp}"; else true ; fi &&
bb2d54f1b3654857b8cb0209612ed847afbd9d3cMichael Graff if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd "${pathcomp}"; else true ; fi &&
bb2d54f1b3654857b8cb0209612ed847afbd9d3cMichael Graff if [ x"$pathcompchmodcmd" != x ]; then $doit $pathcompchmodcmd "${pathcomp}"; else true ; fi
bb2d54f1b3654857b8cb0209612ed847afbd9d3cMichael Graff if [ x"$dir_arg" != x ]
bb2d54f1b3654857b8cb0209612ed847afbd9d3cMichael Graff if [ -d "$dstarg" ]; then
bb2d54f1b3654857b8cb0209612ed847afbd9d3cMichael Graff if [ x"$chowncmd" != x ]; then $doit $chowncmd "$dstarg"; else true ; fi &&
bb2d54f1b3654857b8cb0209612ed847afbd9d3cMichael Graff if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd "$dstarg"; else true ; fi &&
bb2d54f1b3654857b8cb0209612ed847afbd9d3cMichael Graff if [ x"$chmodcmd" != x ]; then $doit $chmodcmd "$dstarg"; else true ; fi