home *** CD-ROM | disk | FTP | other *** search
- #! /bin/sh
-
- # usage: inst FILE DIRECTORY
-
- # Installs FILE in DIRECTORY, printing appropriate messages.
- # For use in binary distribution Makefiles.
-
- path=$1
- dir=$2
- file=`basename $path`
-
- # Make sure $path exists
- if [ ! -r $path ] ; then
- echo "Error: File $path is missing and hence cannot be installed"
- exit 1
- fi
-
- # Make sure $dir is a directory that we have write permission in
- if [ ! -d $dir ] ; then
- echo "Error: $dir does not exist or is not a directory; cannot install file $path"
- exit 1
- fi
- if [ ! -w $dir ] ; then
- echo "Error: Cannot write to directory $dir; cannot install file $path"
- exit 1
- fi
-
-
- # See if $dir/$file already exists, and if so, try to remove it,
- # unless it's the same as $path
- if [ -r $dir/$file ] ; then
- if [ `ls -i $dir/$file | awk '{print $1}'` \
- != `ls -i $path | awk '{print $1}'` ] ; then
- if /bin/rm $dir/$file >&- 2>&- ; then
- echo Removed previously existing $dir/$file
- else
- echo Error: cannot remove previously existing file $dir/$file
- exit 1
- fi
- else
- echo $file is already in $dir
- exit 0
- fi
- fi
-
- # Now attempt to copy $path into $dir
- if cp $path $dir ; then
- echo Installed $path in $dir
- else
- echo Error: could not install file $path in $dir
- exit 1
- fi
-