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