src_install

Function src_install
Purpose Install a package to ${D}
Sandbox Enabled
Privilege root
Called for ebuild

Default 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
}

For EAPIs 6 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
	einstalldocs
}

Sample src_install

src_install() {
	emake DESTDIR="${D}" install
	dodoc README CHANGES
}

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

Usually the package's build system will not install the README, ChangeLog, etc. files, so it is necessary to include additional dodoc statements for them:

    emake DESTDIR="${D}" install
    dodoc README CHANGES

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
	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.

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.