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