Portage currently has issues when it tries to merge a file where the destination has an immutable flag set (see http://www.freebsd.org/cgi/man.cgi?query=chflags&sektion=2 for some info on said flags). I've got a patch that should deal with these flags transparently as far as ebuilds are concerned, assuming that securelevel < 1 and immutable flags can be unset. Obviously, the other case (flags can't be unset) requires more work, but as per jstubbs' request I'm filing a bug with this patch. The basic idea is to implement a python module in C that provides two functions: lchflags and lgetflags, to set and get flags. Obviously, that won't work on Linux (where the filesystems don't support them), so in that case it just assumes flags are always 0 (which is functionally correct). That way, the python code can just call lchflags() without worrying about whether or not it's actually implemented. That's the theory; it's been tested on FreeBSD, and works, and compile tested on Linux, where it passes.
Created attachment 42909 [details, diff] Patch against portage-2.0.51
Created attachment 46932 [details, diff] Updated patch Updated patch, addresses a few issues that carpaski had with the original.
Created attachment 47987 [details, diff] Updated patch OK, new patch. The previous version didn't take into account directories that had immutable flags, since it didn't cross my mind that they could be immutable. However, they can, and so we need to deal with it.
Created attachment 48610 [details, diff] New patch As carpaski suggested, move the problem flags check into the C module. Makes for marginally cleaner python code and reduces a 200+-character line.
Created attachment 48777 [details, diff] Updated (again) patch OK, so last patch was dud, probably due to being made + uploaded at 3AM. This one's been tested a bit more on linux + freebsd platforms.
In 2.0.51.19, now stable. Marking fixed.