michael@0: #!/bin/sh michael@0: # This Source Code Form is subject to the terms of the Mozilla Public michael@0: # License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: # file, You can obtain one at http://mozilla.org/MPL/2.0/. michael@0: michael@0: michael@0: # michael@0: # install - install a program, script, or datafile michael@0: # This comes from X11R5; it is not part of GNU. michael@0: # michael@0: # $XConsortium: install.sh,v 1.2 89/12/18 14:47:22 jim Exp $ michael@0: # michael@0: # This script is compatible with the BSD install script, but was written michael@0: # from scratch. michael@0: # michael@0: michael@0: michael@0: # set DOITPROG to echo to test this script michael@0: michael@0: # Don't use :- since 4.3BSD and earlier shells don't like it. michael@0: doit="${DOITPROG-}" michael@0: michael@0: michael@0: # put in absolute paths if you don't have them in your path; or use env. vars. michael@0: michael@0: mvprog="${MVPROG-mv}" michael@0: cpprog="${CPPROG-cp}" michael@0: chmodprog="${CHMODPROG-chmod}" michael@0: chownprog="${CHOWNPROG-chown}" michael@0: chgrpprog="${CHGRPPROG-chgrp}" michael@0: stripprog="${STRIPPROG-strip}" michael@0: rmprog="${RMPROG-rm}" michael@0: michael@0: instcmd="$mvprog" michael@0: chmodcmd="" michael@0: chowncmd="" michael@0: chgrpcmd="" michael@0: stripcmd="" michael@0: rmcmd="$rmprog -f" michael@0: mvcmd="$mvprog" michael@0: src="" michael@0: dst="" michael@0: michael@0: while [ x"$1" != x ]; do michael@0: case $1 in michael@0: -c) instcmd="$cpprog" michael@0: shift michael@0: continue;; michael@0: michael@0: -m) chmodcmd="$chmodprog $2" michael@0: shift michael@0: shift michael@0: continue;; michael@0: michael@0: -o) chowncmd="$chownprog $2" michael@0: shift michael@0: shift michael@0: continue;; michael@0: michael@0: -g) chgrpcmd="$chgrpprog $2" michael@0: shift michael@0: shift michael@0: continue;; michael@0: michael@0: -s) stripcmd="$stripprog" michael@0: shift michael@0: continue;; michael@0: michael@0: *) if [ x"$src" = x ] michael@0: then michael@0: src=$1 michael@0: else michael@0: dst=$1 michael@0: fi michael@0: shift michael@0: continue;; michael@0: esac michael@0: done michael@0: michael@0: if [ x"$src" = x ] michael@0: then michael@0: echo "install: no input file specified" michael@0: exit 1 michael@0: fi michael@0: michael@0: if [ x"$dst" = x ] michael@0: then michael@0: echo "install: no destination specified" michael@0: exit 1 michael@0: fi michael@0: michael@0: michael@0: # If destination is a directory, append the input filename; if your system michael@0: # does not like double slashes in filenames, you may need to add some logic michael@0: michael@0: if [ -d $dst ] michael@0: then michael@0: dst="$dst"/`basename $src` michael@0: fi michael@0: michael@0: # Make a temp file name in the proper directory. michael@0: michael@0: dstdir=`dirname $dst` michael@0: dsttmp=$dstdir/#inst.$$# michael@0: michael@0: # Move or copy the file name to the temp name michael@0: michael@0: $doit $instcmd $src $dsttmp michael@0: michael@0: # and set any options; do chmod last to preserve setuid bits michael@0: michael@0: if [ x"$chowncmd" != x ]; then $doit $chowncmd $dsttmp; fi michael@0: if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd $dsttmp; fi michael@0: if [ x"$stripcmd" != x ]; then $doit $stripcmd $dsttmp; fi michael@0: if [ x"$chmodcmd" != x ]; then $doit $chmodcmd $dsttmp; fi michael@0: michael@0: # Now rename the file to the real destination. michael@0: michael@0: $doit $rmcmd $dst michael@0: $doit $mvcmd $dsttmp $dst michael@0: michael@0: michael@0: exit 0