Gentoo Development Guide
RPM Sources
If a package is supplied as an .rpm file, you should:
inherit rpm
If you don't need to do anything in the unpack phase, then you are
finished as the rpm.eclass exports a default src_unpack
that will unpack the RPM files.
If you do need to apply patches then override src_unpack in a
manner such as:
src_unpack () {
rpm_src_unpack ${A}
cd "${S}"
use ssl && epatch "${FILESDIR}/${PV}/${P}-ssl.patch"
}
Note
${A} can contain non-rpm files since the rpm eclass will call
the normal unpack function for files that are not in the RPM
format.
Notes on Using rpm.eclass
There are two ways to unpack a rpm file
—
using
the rpmoffset program from rpm2targz and cpio, or
by using rpm2cpio from app-arch/rpm. Normally, for
unpacking an RPM file, installing the entire RPM application is
overkill. Because of this, the eclass will only use rpm2cpio
if rpm is already installed on the system. If you want to force
the eclass to only use the RPM offset method, set
USE_RPMOFFSET_ONLY=1.
Another issue that might arise is that rpmoffset and cpio are not able
to unpack the RPM file correctly. If this occurs, then you need to add
app-arch/rpm to the DEPEND variable so
that rpm2cpio will be used instead.
Example RPM Handling
Here is an ebuild snippet that is based upon the fetchmail source RPM
from SuSE 9.2. The ebuild snippet is complete enough to work with the
ebuild unpack command. The ebuild will download the source file from
the OSU SuSE mirror, unpack the file and apply the included
patches. The filename should be suse-fetchmail-6.2.5.54.1.ebuild.
# Copyright 1999-2005 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: $
inherit eutils versionator rpm
MY_PV=$(replace_version_separator 3 '-')
MY_P=fetchmail-${MY_PV}
SRC_URI="http://suse.osuosl.org/suse/i386/9.2/suse/src/${MY_P}.src.rpm"
DESCRIPTION="SuSE 9.2 Fetchmail Source Package"
HOMEPAGE="http://www.suse.com"
LICENSE="GPL-2 public-domain"
SLOT="0"
KEYWORDS="-*"
IUSE=""
RESTRICT="mirror"
# Need to test if the file can be unpacked with rpmoffset and cpio
# If it can't then set:
#DEPEND="app-arch/rpm"
# To force the use of rpmoffset and cpio instead of rpm2cpio from
# app-arch/rpm, then set the following:
#USE_RPMOFFSET_ONLY=1
S=${WORKDIR}/fetchmail-$(get_version_component_range 1-3)
src_unpack () {
rpm_src_unpack ${A}
cd "${S}"
EPATCH_SOURCE="${WORKDIR}" EPATCH_SUFFIX="patch" \
EPATCH_FORCE="yes" epatch
}