# Save the library files before overwriting with Green Hills Pascal.
# Doing a removepkg of the GHPAS package will restore the original libs.

if [ -f /usr/options/GHPAS.name ]; then
	echo
	echo "Green Hills Pascal Compiler is already installed."
	echo
	exit 255
fi

if [ ! -d /lib/lib.sav ]; then
	mkdir /lib/lib.sav > /dev/null 2>&1
fi
echo
echo "Saving the following library files in /lib/lib.sav :"
echo '/lib/crt0.o
/lib/crt1.o
/lib/crtn.o
/lib/libc.a
/lib/libm.a
/lib/mcrt0.o
/lib/mcrt1.o
/usr/lib/libmalloc.a
/usr/lib/libp/libc.a
/usr/lib/libp/libm.a
/usr/lib/libp/libmalloc.a' > /tmp/ghpas1$$

# Make sure this file list is really there.
>/tmp/ghpas2$$
for i in `cat /tmp/ghpas1$$`
do
	if [ -f $i ]; then
		echo $i >> /tmp/ghpas2$$
	fi
done

if [ -s /tmp/ghpas2$$ ]; then
	cat /tmp/ghpas2$$ | cpio -pdmuv /lib/lib.sav
	for i in `cat /tmp/ghpas$$`
	do
		rm $i > /dev/null 2>&1
	done
fi
rm /tmp/ghpas1$$ /tmp/ghpas2$$

exit 0
