#!/bin/sh

# This is the regular copy part
while read SOURCE DESTINATION; do
	if [ -f $SOURCE ]; then
		if [ ! -e $DESTINATION ]; then
			cp -a $SOURCE $DESTINATION
			echo "$DESTINATION" >> $1.del
		fi
	fi
done < $1

# This is a fixup section for SLES7/United Linux
# We will create a soft link for libraries we built
# with non-versioned libsnmp.so

LIBSNMP_DESIRED=`ldd /opt/compaq/foundation/bin/cmapeerd 2> /dev/null | grep libsnmp | cut -d ' ' -f 1 | tr -d '\t'`
LIBSNMP_FOUND=`ldd /opt/compaq/foundation/bin/cmapeerd 2> /dev/null | grep libsnmp | cut -d ' ' -f 3 | tr -d '\t'`

if [ -z "$LIBSNMP_DESIRED" ]; then
	exit 0
fi

if [ -f "$LIBSNMP_FOUND" ]; then
	exit 0
fi

LIBSNMP=`ls /usr/lib/libsnmp-*.so 2> /dev/null`
if [ -z "$LIBSNMP" ]; then
	exit 0
fi

for LIBSNMP_REAL in $LIBSNMP; do
	if [ ! -h "$LIBSNMP_REAL" ]; then
		break	
	fi
done
LIBSNMP_REAL=`basename $LIBSNMP_REAL 2> /dev/null`

ln -s $LIBSNMP_REAL /usr/lib/$LIBSNMP_DESIRED 
echo "/usr/lib/$LIBSNMP_DESIRED" >> $1.del 

 
