Currently packages can install any file anywhere, there thus a real danger of the same file being installed by different packages. Even more complicated is that some files should be possible to install by several packages, like /bin/mail.
One solution could be karltk's tinderbox that has to succeed for every ebuild that's submitted. The tinderbox could keep track of which files are installed by all the packages and prevent a new package from being validated if there are conflicts.
I think the best solution is to have a unified firebird database for all filesystem objects installed. With a unified database, it is easy to check for/track duplicate files and deal with them appropriately -- either with a warning, backing up the original, etc. A unified db will also allow us to effectively "tweak" the equivalent of CONTENTS files, so if we back up a file, we can record its new filename so if the original package is unmerged, "foo.backup" gets unmerged as well. It also allows us to track directory ownership better and thus remove the dreaded .keep files and pkg_postinst() dir creation tricks eventually.
Some months ago I added a "chkcontents" script that verifies the integrity of already-installed packages. My guess is that until we switch to a db there's no good to prevent file clobbering, but at least it can be detected. I really need to upgrade this script so that, at least by default, it doesn't report files in /etc (or similar) that are expected to differ from what was originally installed.
*** Bug 2971 has been marked as a duplicate of this bug. ***
db fix