Function | src_install |
---|---|
Purpose | Install a package to ${D}
|
Sandbox | Enabled |
Privilege | root |
Called for | ebuild |
src_install
For EAPIs 0,1,2, and 3, the default src_install
function is the
following:
src_install()
{
return
}
For EAPIs 4 and later, 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
}
src_install
src_install() {
emake DESTDIR="${D}" install
dodoc README CHANGES
}
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
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. It is usually necessary to include additional
dodoc
statements for the README
, ChangeLog
, etc
in these cases:
einstall
dodoc README CHANGES
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.
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
dobin udevtest
into /
dosbin udev
dosbin udevd
dosbin udevsend
dosbin udevstart
dosbin extras/scsi_id/scsi_id
dosbin extras/volume_id/udev_volume_id
exeinto /etc/udev/scripts
doexe extras/ide-devfs.sh
doexe extras/scsi-devfs.sh
doexe extras/cdsymlinks.sh
doexe extras/dvb.sh
insinto /etc/udev
newins "${FILESDIR}/udev.conf.post_050" udev.conf
doins extras/cdsymlinks.conf
# For devfs style layout
insinto /etc/udev/rules.d/
newins etc/udev/gentoo/udev.rules 50-udev.rules
# scsi_id configuration
insinto /etc
doins extras/scsi_id/scsi_id.config
# set up symlinks in /etc/hotplug.d/default
dodir /etc/hotplug.d/default
dosym ../../../sbin/udevsend /etc/hotplug.d/default/10-udev.hotplug
# set up the /etc/dev.d directory tree
dodir /etc/dev.d/default
dodir /etc/dev.d/net
exeinto /etc/dev.d/net
doexe etc/dev.d/net/hotplug.dev
doman *.8
doman extras/scsi_id/scsi_id.8
dodoc ChangeLog FAQ HOWTO-udev_for_dev README TODO
dodoc docs/{overview,udev-OLS2003.pdf,udev_vs_devfs,RFC-dev.d,libsysfs.txt}
dodoc docs/persistent_naming/* docs/writing_udev_rules/*
newdoc extras/volume_id/README README_volume_id
}
This is, of course, considerably harder to handle than a
simple Makefile
driven install.
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.