When using gentoo for building packages for distribution, many licenses burden us with the requirement to provide all source used to generate that distribution. At present this is somewhat challenging as there are several places "source" could come from (eg $FILESDIR, http download, git, etc) It would be helpful if portage were enhanced with a function, eg "buildsrcpkg" that can capture all source files used to build an ebuild On the surface it seems that this can be performed by capturing everything in $A and ${PORTDIR}/${CATEGORY}/${PN}. However, this may possibly miss some unusual sources (git?). Additionally it will often include "too much" since often patches are downloaded but not applied, or apply only to other ebuilds. Perhaps we can do better by eg, tracking the files used by the epatch hook, and files copied in/deleted out of the source tree?
If you're trying to fulfill this kind of license requirement, I think the most reasonable approach is to keep a snapshot of the portage tree, and copy of $DISTDIR containing $A for all of your built packages. That's all that would be required to enable anyone to reproduce the build from scratch. Using live vcs/git sources makes it basically impossible to reproduce the build, so you should instead create snapshots if you need the build to be reproducible.