src_unpack

Function src_unpack
Purpose Extract source packages.
Sandbox Enabled
Privilege user
Called for ebuild

Default src_unpack

src_unpack() {
	if [[ -n ${A} ]]; then
		unpack ${A}
	fi
}

Sample src_unpack

src_unpack() {
	unpack ${P}.tar.xz
	use foo && unpack ${P}-foo-extension.tar.xz
}

Unpacking Tarballs

The unpack function should be used to unpack tarballs, compressed files and so on. Do not use tar, gunzip etc. manually.

The ${A} variable contains all of the SRC_URI components, except for any which are excluded by USE-based conditionals inside SRC_URI itself. If multiple archives require unpacking in a particular order it is usually simpler to avoid working with ${A}.

Known file formats

The unpack function recognizes the following file formats:

  • *.tar
  • *.gz, *.Z, *.tar.gz, *.tgz, *.tar.Z
  • *.bz2, *.bz, *.tar.bz2, *.tbz2, *.tar.bz, *.tbz
  • *.lzma, *.tar.lzma
  • *.xz, *.tar.xz, *.txz
  • *.zip, *.ZIP, *.jar
  • *.a, *.deb

In EAPI 6 and later, filename extensions are matched case-insensitively.

src_unpack Actions

The following subsections cover different topics which often occur when writing src_unpack functions.