mercurial_src_unpack() unpacks the source into ${WORKDIR}/${module}, where ${module} defaults to the basename of EHG_REPO_URI. This is in contrast with the git eclass, whose git_fetch() unpacks the repository to ${S}. The mercurial_src_unpack() behavior means that a post-unpack `cd ${S}` can fail if ${module} is not equal to ${P}. Reproducible: Always Steps to Reproduce: The following ebuild: <snip hooke-9999.ebuild> EAPI="2" PYTHON_DEPEND="2:2.6" SUPPORT_PYTHON_ABIS="1" RESTRICT_PYTHON_ABIS="3.*" inherit eutils distutils scons-utils inherit mercurial EHG_REPO_URI="http://www.physics.drexel.edu/~wking/code/hg/hooke" EHG_REVISION="wtk" SRC_URI="" DESCRIPTION="Force spectroscopy data analysis." HOMEPAGE="http://code.google.com/p/hooke/" LICENSE="LGPL-3" SLOT="0" src_unpack() { mercurial_src_unpack # mercurial eclass doesn't unpack to ${S}, see their use of # ${module}. Uncomment the following line to fix # mv "${WORKDIR}/hooke" "${S}" || die "couldn't rename workdir" cd "${S}" } </snip> Fails with <snip failing commands> $ sudo ebuild ./hooke-9.ebuild digest Appending /home/wking/src/wtk-overlay to PORTDIR_OVERLAY... >>> Creating Manifest for /home/wking/src/wtk-overlay/sci-physics/hooke $ sudo ebuild ./hooke-9.ebuild merge </snip> Actual Results: Disabling noauto in features... merge disables it. (qmerge doesn't) Appending /home/wking/src/wtk-overlay to PORTDIR_OVERLAY... * checking ebuild checksums ;-) ... [ ok ] * checking auxfile checksums ;-) ... [ ok ] * checking miscfile checksums ;-) ... [ ok ] * CPV: sci-physics/hooke-9999 * REPO: * USE: elibc_glibc kernel_linux userland_GNU x86 >>> Unpacking source... * Updating /usr/portage/distfiles/hg-src/hooke/hooke from http://www.physics.drexel.edu/~wking/code/hg/hooke * Creating working directory in /var/tmp/portage/sci-physics/hooke-9999/work/hooke (target revision: wtk) * Work directory: /var/tmp/portage/sci-physics/hooke-9999/work/hooke global id: d70b29fb2eeb branch: wtk /var/tmp/portage/sci-physics/hooke-9/temp/environment: line 4802: cd: /var/tmp/portage/sci-physics/hooke-9/work/hooke-9999: No such file or directory * ERROR: sci-physics/hooke-9 failed: * no source directory? * * Call stack: * ebuild.sh, line 54: Called src_unpack * environment, line 4802: Called die * The specific snippet of code: * cd "${S}" || die "no source directory?" ... Expected Results: Disabling noauto in features... merge disables it. (qmerge doesn't) Appending /home/wking/src/wtk-overlay to PORTDIR_OVERLAY... * checking ebuild checksums ;-) ... [ ok ] * checking auxfile checksums ;-) ... [ ok ] * checking miscfile checksums ;-) ... [ ok ] * CPV: sci-physics/hooke-9999 * REPO: * USE: elibc_glibc kernel_linux userland_GNU x86 >>> Unpacking source... * Updating /usr/portage/distfiles/hg-src/hooke/hooke from http://www.physics.drexel.edu/~wking/code/hg/hooke * Creating working directory in /var/tmp/portage/sci-physics/hooke-9999/work/hooke-9999 (target revision: wtk) * Work directory: /var/tmp/portage/sci-physics/hooke-9999/work/hooke-9999 global id: d70b29fb2eeb branch: wtk ... The benefit of the current approach is that you can check out several mercurial repositories with mercurial_fetch() while building a single package. To preserve that, I suggest we only change function mercurial_src_unpack() to use mercurial_fetch "${EHG_REPO_URI}" "${P}" which assumes S="${WORKDIR}/${P}" (its default value). If that assumption is too risky, then mercurial_fetch should get a third "target directory" option, and the call from mercurial_src_unpack() would be local module="$(basename "${EHG_REPO_URI}")" mercurial_fetch "${EHG_REPO_URI}" "$module" "${S}"
Created attachment 253373 [details, diff] mercurial.eclass-workdir.patch I'll send an e-mail to gentoo-dev to start a discussion and ask for comments about this patch. It has a nasty side effect of breaking every existing ebuild that uses mercurial.eclass currently, fortunately there are only a few of them in main portage tree and a fix is quite trivial: just remove definition of S.
Created attachment 253567 [details, diff] mercurial.eclass-workdir.patch Improved version.
I've committed the improved version.