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 call additional unpack functions then override src_unpack in a manner such as:

src_unpack() {
	unpack ${A}
	rpm_unpack "${S}/rpm/intel-openclrt-${PV}-${ALT_PV}.x86_64.rpm"
}

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-2021 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2

EAPI=7

inherit rpm

MY_PV=$(ver_rs 3 '-')
MY_P=fetchmail-${MY_PV}

DESCRIPTION="SuSE 9.2 Fetchmail Source Package"
HOMEPAGE="https://www.suse.com"
SRC_URI="https://suse.osuosl.org/suse/i386/9.2/suse/src/${MY_P}.src.rpm"
S=${WORKDIR}/fetchmail-$(ver_cut 1-3)

LICENSE="GPL-2 public-domain"
SLOT="0"
KEYWORDS="-*"

RESTRICT="mirror"

# Need to test if the file can be unpacked with rpmoffset and cpio
# If it can't then set:

#BDEPEND="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

src_unpack() {
    rpm_src_unpack ${A}
}

src_prepare() {
    for i in "${WORKDIR}"/*.patch ; do
        eapply "${i}"
    done
    eapply_user
}