Partially installed and partially uninstalled mods are the bane of SMF. Almost every "undefined index" error involves one. My impression is that people tend to accept partial actions and don't understand that they need to go back and manually edit the failed files. Therefore, I think that fully automatic installs/uninstalls should either do 100% of the job, or refuse to do any.
It would be nice to give some assistance on mod installs/uninstalls where SMF can handle some of the files itself, but we need to prevent people from walking off with the job half done. It might be enough to refuse to take the forum out of maintenance mode (or otherwise unlock it) until they have answered "yes" or "no" to each "Did you successfully manually edit file ________?" Maybe add, "do you swear upon your mother's grave..."?? There's probably no automated way to check that the work was done (else it could have been done fully automatically). If they answer "no" to any question, refuse to unlock the forum until they agree to uninstall/reinstall the mod, and can answer "yes" to all. Or, save a backup of each file affected by the mod, and restore all of them to completely roll back the action. If they say "yes" to a question, compare the current file to its backup, to see if something was done. There's all sorts of things that could be done.
If I had to do SMF over from scratch, I would not eval templates either. We always have to tell people to turn off eval and come back with the right error messages. Do you suppose it's possible to automatically turn off eval if an error is detected (and "eval" is in the message), and possibly purge the non-eval message?
Add: A related problem is that the package manager allows you to install a mod twice. As part of the pre-install check, it should see if the target code is already installed, and if so, refuse to proceed. This would eliminate all reports of "duplicate function defined".