Gentoo Development Guide
src_install
| Function | src_install |
| Purpose | Install a package to ${D} |
| Sandbox | Enabled |
| Privilege | root |
| Called for | ebuild |
Default src_install
For EAPI < 4, the default src_install function is the following:
src_install()
{
return
}
For EAPI ≥ 4, the default src_install function is the following:
src_install() {
if [[ -f Makefile ]] || [[ -f GNUmakefile]] || [[ -f makefile ]] ; then
emake DESTDIR="${D}" install
fi
if ! declare -p DOCS >/dev/null 2>&1 ; then
local d
for d in README* ChangeLog AUTHORS NEWS TODO CHANGES THANKS BUGS \
FAQ CREDITS CHANGELOG ; do
[[ -s "${d}" ]] && dodoc "${d}"
done
elif declare -p DOCS | grep -q "^declare -a " ; then
dodoc "${DOCS[@]}"
else
dodoc ${DOCS}
fi
}
Sample src_install
src_install() {
emake DESTDIR="${D}" install || die "Install failed"
dodoc README CHANGES || die
}
Easy Installs
Often, especially with autotools-powered packages, there is a Makefile
install target which will honour the DESTDIR variable to tell it to
install to a non-root location. If possible, this should be used:
emake DESTDIR="${D}" install || die "Install failed"
Note
emake should be used to parallelise here. Some installs are
not designed to be parallelised, use emake -j1 or make
if you hit an error.
Sometimes this will end up installing a few things into strange
places. If and only if this is the case, the einstall function
can be used:
einstall || die "einstall failed"
It is usually necessary to include additional dodoc statements for the
README, ChangeLog, etc in these cases.
Note
There is no need to dodoc COPYING! The license belongs
to ${PORTDIR}/licenses. Sometimes though, you might want to
install COPYING regardless, if it explains how different
licenses are applied to different parts of the application, for
example.
Trivial Installs
For some packages with no Makefile that only install a small
number of files, writing a manual install using cp is the
easiest option. For example, to do a simple install of some (no
compilation required) themes:
dodir /usr/share/foo-styles/
cp -R "${S}/" "${D}/" || die "Install failed!"
Or sometimes a combination of insinto and doins (plus related
functions -- see Install Functions Reference)
—
the following is based
upon the sys-fs/udev install:
src_install() {
dobin udevinfo || die
dobin udevtest || die
into /
dosbin udev || die
dosbin udevd || die
dosbin udevsend || die
dosbin udevstart || die
dosbin extras/scsi_id/scsi_id || die
dosbin extras/volume_id/udev_volume_id || die
exeinto /etc/udev/scripts
doexe extras/ide-devfs.sh || die
doexe extras/scsi-devfs.sh || die
doexe extras/cdsymlinks.sh || die
doexe extras/dvb.sh || die
insinto /etc/udev
newins "${FILESDIR}/udev.conf.post_050" udev.conf || die
doins extras/cdsymlinks.conf || die
# For devfs style layout
insinto /etc/udev/rules.d/
newins etc/udev/gentoo/udev.rules 50-udev.rules || die
# scsi_id configuration
insinto /etc
doins extras/scsi_id/scsi_id.config || die
# set up symlinks in /etc/hotplug.d/default
dodir /etc/hotplug.d/default || die
dosym ../../../sbin/udevsend /etc/hotplug.d/default/10-udev.hotplug || die
# set up the /etc/dev.d directory tree
dodir /etc/dev.d/default || die
dodir /etc/dev.d/net || die
exeinto /etc/dev.d/net
doexe etc/dev.d/net/hotplug.dev || die
doman *.8 || die
doman extras/scsi_id/scsi_id.8 || die
dodoc ChangeLog FAQ HOWTO-udev_for_dev README TODO || die
dodoc docs/{overview,udev-OLS2003.pdf,udev_vs_devfs,RFC-dev.d,libsysfs.txt} || die
dodoc docs/persistent_naming/* docs/writing_udev_rules/* || die
newdoc extras/volume_id/README README_volume_id || die
}
This is, of course, considerably harder to handle than a
simple Makefile driven install.
Other Installs
Sometimes, there will be a Makefile that does not
honour DESTDIR and a non-trivial number of files to install. In
these situations, it is best to patch the Makefile and contact
upstream explaining the situation to them.