Isn't there a log-file of your installation process?
Then you should be able to extract that information and only remove the stuff your script did install.
That way your uninstall script want remove stuff which is required by other packages which have been present before.