commit:     26b30e180a4b2583452508d79ebb35d0e97fc696
Author:     Eli Schwartz <eschwartz <AT> gentoo <DOT> org>
AuthorDate: Tue Jan 27 01:59:51 2026 +0000
Commit:     Eli Schwartz <eschwartz <AT> gentoo <DOT> org>
CommitDate: Thu Mar 12 15:21:06 2026 +0000
URL:        https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=26b30e18

rpm.eclass: allow using rpm2archive from rpm itself

It is feature-compatible with rpm2tar but utilizes the rpm codebase. The
first any-of element remains rpm2targz as it's vastly smaller, but for
users who happen to have rpm installed as a dep of some other package,
there is no need to additionally install another package.

rpm 4.19.0 is required because:

- rpm2archive was added in 2014 / rpm 4.12
- it learned -n in 2021 / rpm 4.17
- it learned to write to a pipe in 2022 / rpm 4.19

Signed-off-by: Eli Schwartz <eschwartz <AT> gentoo.org>

 eclass/rpm.eclass | 17 +++++++++++++++--
 1 file changed, 15 insertions(+), 2 deletions(-)

diff --git a/eclass/rpm.eclass b/eclass/rpm.eclass
index b9e1b87a29de..3b7f9e64355b 100644
--- a/eclass/rpm.eclass
+++ b/eclass/rpm.eclass
@@ -17,7 +17,12 @@ _RPM_ECLASS=1
 
 inherit estack
 
-BDEPEND="app-arch/rpm2targz"
+BDEPEND="
+       || (
+               app-arch/rpm2targz
+               >=app-arch/rpm-4.19.0
+       )
+"
 
 # @FUNCTION: rpm_unpack
 # @USAGE: <rpms>
@@ -37,7 +42,15 @@ rpm_unpack() {
                else
                        a="${DISTDIR}/${a}"
                fi
-               rpm2tar -O "${a}" | tar xf -
+
+               if command -v rpm2tar >/dev/null; then
+                       local extracttool=(rpm2tar -O)
+               else
+                       # app-arch/rpm fallback
+                       local extracttool=(rpm2archive -n)
+               fi
+
+               "${extracttool[@]}" "${a}" | tar xf -
                pipestatus || die "failure unpacking ${a}"
        done
 }

Reply via email to