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.

Signed-off-by: Eli Schwartz <[email protected]>
---
 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
 }
-- 
2.52.0


Reply via email to