#ident	"@(#)pkg4.i386:scde/postremove	1.2"
#-------
# postremove - restore the CCS that was made "coresident",
# if there was one.
#
# Take care of /usr/lib/cpp.
#
# CORESIDENT set by request script
#-------

if	[ -h /usr/lib/cpp -a ! -f /usr/ccs/lib/cpp ]
then	rm -f /usr/lib/cpp
fi

#-------
# unmvci4 - relocate the header files for CI4 from /usr/occs/include
# to /usr/include, and restore the old cc.
#-------
unmvci4()
{
(
	BIN=/usr/bin
	INC=/usr/include
	SAV=/usr/occs

	#-------
	# If there is no save directory, then give up.
	#-------
	if	[ ! -d "$SAV" ]
	then	exit 0
	fi
	if	[ ! -d "$SAV/include" ]
	then	exit 0
	fi
	if	[ ! -d "$SAV/bin" ]
	then	exit 0
	fi

	cd $SAV/include
	echo "Restoring 4.2 headers to /usr/include"
	find . -depth -print | cpio -plmud $INC 2>/dev/null	|| exit 1

	echo "Restoring 4.2 cc to /bin/cc"
	if	[ -f "$SAV/bin/cc" ]
	then
		mv -f "$SAV/bin/cc" "$BIN/cc" 	|| exit 1
		chmod 755 "$BIN/cc"		|| exit 1
		chgrp bin "$BIN/cc"		|| exit 1
		chown bin "$BIN/cc"		|| exit 1
	fi

	cd $INC
	rm -rf $SAV
)
}

#-------
# This is where the action is.
#-------
if	[ "$CORESIDENT" = y ]
then	unmvci4
fi

#-------
# Take care of libcrypt.a
#-------
rm -f /usr/lib/libcrypt.a
if	[ -f /usr/lib/libcrypt_d.a ]
then	ln /usr/lib/libcrypt_d.a /usr/lib/libcrypt.a
fi
exit 0
