Files
epics-base/src/tools/installEpics
T
1996-02-20 20:58:44 +00:00

73 lines
1.6 KiB
Bash
Executable File

#!/usr/bin/sh
# InstallEpics
#
# InstallEpics is used within makefiles to copy new versions of
# files into a destination directory.
#
##########################################################
TOOL=`basename $0`
MODE=755
USAGE="Usage:
$TOOL [ -m mode ] file ... directory
-m mode Set the mode for the installed file (0755 by default)
file Name of file
directory Destination directory
"
# get command line options
set -- `getopt m:g:o:csd $*`
for i
do
case $i in
-m) MODE=$2; shift 2;;
-g | -o) echo $USAGE; echo "$i not implemented"; shift 2;;
-c | -s | -d ) echo $USAGE; echo "$i not implemented"; shift;;
--) shift; break;;
esac
done
# at least two args required
if [ $# -lt 2 ]
then
echo "$USAGE"
exit 1
fi
INSTALL_BIN=
FILELIST=
for i
do
FILELIST="${FILELIST} ${INSTALL_BIN}"; INSTALL_BIN=$i; shift;
done
if [ ! -d ${INSTALL_BIN} ] ;then
echo "$USAGE\n Can't find directory '${INSTALL_BIN}'"
exit 1
fi
for FILE in ${FILELIST}
do
if [ ! -f ${FILE} ] ;then
echo "$USAGE\n Can't find file '${FILE}'"
exit 1
fi
TEST=
FILEBASENAME=`basename ${FILE}`
if [ -f ${INSTALL_BIN}/${FILEBASENAME} ] ; then
#Is ${INSTALL_BIN}/${FILEBASENAME} link timestamp newer than ${FILE}
TEST=`find ${INSTALL_BIN} -name "${FILEBASENAME}" -newer ${FILE} -print`
fi
if [ "${TEST}x" = "x" ] ; then
#echo "Installing ${FILEBASENAME}"
/bin/rm -f ${INSTALL_BIN}/${FILEBASENAME}
/bin/cp -p ${FILE} ${INSTALL_BIN}/${FILEBASENAME}
/bin/chmod ${MODE} ${INSTALL_BIN}/${FILEBASENAME}
else
echo "${INSTALL_BIN}/${FILEBASENAME} is up to date"
fi
done
exit 0