Normally, when emerge or ebuild go to download files, they will try to download from the Gentoo mirrors first.
Sometimes, you want to avoid this. There's two scenarios:
- You're developing the ebuild, so the files won't be on the mirrors (yet), so you want to save yourself the time spent checking the mirrors
- Something necessitates always using the SRC_URI source explicitly.
First scenario
To elect to not use the mirrors on a command by command basis, you can do:
$ GENTOO_MIRRORS="" ebuild foo-1.2.3.ebuild manifest
Typically, you define GENTOO_MIRRORS in /etc/make.conf. We can temporary set it to nothing when we invoke ebuild, which results in the SRC_URI being used first.
Second scenario
To prevent the ebuild from ever being populated to the mirrors, you need to add the following to your ebuild:
RESTRICT="mirror"
Technically, this can go anywhere in the file. However, the common convention seems to be to put it after IUSE.
Often enough, something unthinkable will happen while your trying to build an ebuild. Something that is beyond reason. It just doesn't make sense. You could have SWORN you were in the correct directory...
Enter emerge --debug. This will spit out a ton of information, including every command that runs through bash.
This is useful for tracking issues like:
- Not being in the correct directory
- Files not being where you expect them to be
- Using the wrong variable (such that they evaluate to empty string)
- Having incorrect file globs
Here's how you invoke it:
# emerge --debug somepackage
Here's a sample snippet of the output:
+ local retval
+ src_install
+ local bits
+ use x86
+ useq x86
+ local u=x86
+ local found=0
+ [[ x == \! ]]
+ [[ -n ^(alpha|alsa_cards_aoa|alsa_cards_aoa-fabric-layout|alsa_cards_aoa-onyx|alsa_cards_aoa-soundbus|alsa_cards_aoa-soundbus-i2s|alsa_cards_aoa-tas|alsa_cards_aoa-toonie|alsa_cards_armaaci|alsa_cards_at91-soc|alsa_cards_at91-soc-eti-b1-wm8731|alsa_cards_au1x00|alsa_cards_harmony|alsa_cards_powermac|alsa_cards_pxa2xx-i2sound|alsa_cards_pxa2xx-soc|alsa_cards_pxa2xx-soc-corgi|alsa_cards_pxa2xx-soc-poodle|alsa_cards_pxa2xx-soc-spitz|alsa_cards_pxa2xx-soc-tosa|alsa_cards_sa11xx-uda1341ts|alsa_cards_sun-amd7930|alsa_cards_sun-cs4231|alsa_cards_sun-dbri|altivec|amd64|aqua|arm|bmp|bmpx|bootstrap|build|coreaudio|crosscompile_opts_.*|elibc_.*|elibc_Darwin|elibc_DragonFly|elibc_FreeBSD|elibc_NetBSD|elibc_OpenBSD|elibc_glibc|elibc_uclibc|emul-linux-x86|hppa|ia64|ibm|infopipe|kernel_.*|kernel_Darwin|kernel_FreeBSD|kernel_linux|m68k|mips|mplayer-bin|multilib|n32|n64|pam_console|pbbuttonsd|ppc|ppc64|ppcsha1|s390|selinux|sh|sparc|sparc-fbsd|uclibc|ultra1|userland_.*|userland_BSD|userland_Darwin|userland_GNU|video_cards_impact|video_cards_newport|video_cards_sunbw2|video_cards_suncg14|video_cards_suncg3|video_cards_suncg6|video_cards_sunffb|video_cards_sunleo|video_cards_suntcx|vis|x86|x86-fbsd|xmms)$ ]]
+ [[ -n install ]]
+ hasq install config depend info prerm postrm postinst
+ [[ config depend info prerm postrm postinst == *\ \i\n\s\t\a\l\l\ * ]]
+ [[ ebuild != binary ]]
+ [[ x86 =~ ^(alpha|alsa_cards_aoa|alsa_cards_aoa-fabric-layout|alsa_cards_aoa-onyx|alsa_cards_aoa-soundbus|alsa_cards_aoa-soundbus-i2s|alsa_cards_aoa-tas|alsa_cards_aoa-toonie|alsa_cards_armaaci|alsa_cards_at91-soc|alsa_cards_at91-soc-eti-b1-wm8731|alsa_cards_au1x00|alsa_cards_harmony|alsa_cards_powermac|alsa_cards_pxa2xx-i2sound|alsa_cards_pxa2xx-soc|alsa_cards_pxa2xx-soc-corgi|alsa_cards_pxa2xx-soc-poodle|alsa_cards_pxa2xx-soc-spitz|alsa_cards_pxa2xx-soc-tosa|alsa_cards_sa11xx-uda1341ts|alsa_cards_sun-amd7930|alsa_cards_sun-cs4231|alsa_cards_sun-dbri|altivec|amd64|aqua|arm|bmp|bmpx|bootstrap|build|coreaudio|crosscompile_opts_.*|elibc_.*|elibc_Darwin|elibc_DragonFly|elibc_FreeBSD|elibc_NetBSD|elibc_OpenBSD|elibc_glibc|elibc_uclibc|emul-linux-x86|hppa|ia64|ibm|infopipe|kernel_.*|kernel_Darwin|kernel_FreeBSD|kernel_linux|m68k|mips|mplayer-bin|multilib|n32|n64|pam_console|pbbuttonsd|ppc|ppc64|ppcsha1|s390|selinux|sh|sparc|sparc-fbsd|uclibc|ultra1|userland_.*|userland_BSD|userland_Darwin|userland_GNU|video_cards_impact|video_cards_newport|video_cards_sunbw2|video_cards_suncg14|video_cards_suncg3|video_cards_suncg6|video_cards_sunffb|video_cards_sunleo|video_cards_suntcx|vis|x86|x86-fbsd|xmms)$ ]]
+ hasq x86 elibc_glibc kernel_linux userland_GNU x86
+ [[ elibc_glibc kernel_linux userland_GNU x86 == *\ \x\8\6\ * ]]
+ return 0
+ bits=32
+ dobin release32/glsldb
+ dolib release32/libs/libdlsym.so-32 release32/libs/libglsldebug.so-32 release32/libs/plugins32
install: omitting directory `release32/libs/plugins32'
+ die 'dolib failed'
In this snippet, we see dolib fails because it trying to work on a directory. The specific cause was a bad glob in the dolib call that was catching said directory, instead of just the .so files.
I've often seen people submit ebuilds with src_unpack() like:
src_unpack() {
unpack ${A}
cd ${S}
}
This is not needed because there is a default src_unpack() that effectively does this for you. Take a look at /usr/lib/portage/bin/ebuild.sh and see for yourself.
Update: Diego pointed out one case where you would want to override src_compile with the default: you inherit an eclass that provides a src_compile that you don't want to be used. This is probably a pretty rare case though.