"install" command

Dave Burton daveb at laidbak.UUCP
Fri Apr 15 16:04:32 AEST 1988


In article <QWMbkNy00VoDEdflM8 at andrew.cmu.edu> jl42+ at andrew.cmu.edu (Jay Mathew Libove) writes:
|There is a command on Berkeley systems called "install" which copies
|a file, changes its modes, does careful copying, maybe even does owner
|changes, and which some software distributions use. In such cases, it
|is necessary to hand edit every use of the "install" command in a
|makefile to the appropriate cp, mv, chown, chmod, chgrp, etc...
|commands. What a nuisance.
|Anyone got such a command for Xenix (or SysV in general?)

The following is my rendition of install.
Near as I can tell, it works just like Berkeley's install.
I don't thinks it has any bugs, but you never know... :-)

cat >install <<'EOF'
:
#
# @(#)install	1.1 1/31/88
#
# install - install executables
#

PATH=/bin:/usr/bin
IFS=" 	
"

PROGNAME=`basename $0`
USAGE="usage: $PROGNAME [-cs] [-m mode] [-o owner] [-g group] binary location"
cmd=/bin/mv
mode=755
owner=bin
group=bin
strip=false

set -- `getopt 'csm:o:g:' $*`
if [ $? -ne 0 ]
then echo $USAGE >&2;exit 1
fi

for option
do
	case $option in
	-c)	cmd=/bin/cp;	shift;;
	-s)	strip=true;	shift;;
	-m)	mode=$2;	shift;shift;;
	-o)	owner=$2;	shift;shift;;
	-g)	group=$2;	shift;shift;;
	--)	shift;break;;
	esac
done

if [ $# -ne 2 ]
then echo $USAGE >&2;exit 1
fi

file=`basename $1`
loc=$2

if [ ! -f $file ]
then	echo "$PROGNAME: cannot access '$file'" >&2; exit 2
fi

set -- `ls -ldi $file`
finode=$1

if [ -d $loc ]
then	loc=${loc}/$file
fi

if [ -f $loc ]
then
	set -- `ls -ldi $loc`
	linode=$1
	if [ $file = $loc -o $finode = $linode ]
	then	echo "$PROGNAME: '$file' would copy onto itself" >&2; exit 2
	fi
fi

rm -f $loc

if $cmd $file $loc
then	:
else	echo "$PROGNAME: cannot put '$file' at '$lo



More information about the Comp.unix.xenix mailing list