RPM 源

如果一个软件包以 .rpm 文件的形式提供,您应该

inherit rpm

如果您不需要在解包阶段执行任何操作,那么您就完成了,因为 rpm.eclass 导出一个默认的 src_unpack,它将解包 RPM 文件。

如果您确实需要调用其他解包函数,则以如下方式覆盖 src_unpack

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

RPM 处理示例

这是一个基于 SuSE 9.2 中 fetchmail 源 RPM 的 ebuild 代码片段。该 ebuild 代码片段完整到足以与 ebuild unpack 命令一起使用。该 ebuild 将从 OSU SuSE 镜像下载源文件,解包文件并应用包含的补丁。文件名应为 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
}