I stumbled upon a weird behavior I coudn't completely trace back to where it comes from. I'm not too familiar with the internals of portage, maybe someone here can point me in the right direction. When installing into a different ROOT, portage needs to install DEPENDS into the local ROOT to satisfy build dependencies. If a package happens to be the first to get merged, and is also going to be merged to ROOT, and the source tarball is already in distfiles, the first package will fail (Sorry if that isn't very well formulated). It seems to be caused by parallel-fetch somehow. If I delete the sourcefile (libgcrypt-1.4.0.tar.bz2 in this example) everything works as expected. I had the same issue with a couple of other packages as well. Please see the following logs for more details.
Created attachment 184428 [details] emerge --info ROOT=/home/build/work/components/gpg PORTAGE_CONFIGROOT=/home/build/config emerge --info > emerge-info.log
Created attachment 184430 [details] emerge log ROOT=/home/build/work/components/gpg PORTAGE_CONFIGROOT=/home/build/config emerge -vtN -k app-crypt/gnupg > emerge-gnupg.log 2>&1
Created attachment 184431 [details] emerge log with --debug ROOT=/home/build/work/components/gpg PORTAGE_CONFIGROOT=/home/build/config emerge --debug -vtN -k app-crypt/gnupg > emerge-debug-gnupg.log 2>&1
Oh, and if I run the whole commandline with FEATURES=-parallel-fetch, everything works as expected.
This is fixed in svn r12558.
This is fixed in 2.1.6.8 and 2.2_rc24.