From b557bf160fed9050eccb0f1de4eb833a8ca77b60 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lubom=C3=ADr=20Sedl=C3=A1=C5=99?= Date: Thu, 20 Aug 2020 10:19:17 +0200 Subject: [PATCH] Fall back to rpm2cpio MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit JIRA: RHELCMP-2030 Signed-off-by: Lubomír Sedlář --- pungi/util.py | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/pungi/util.py b/pungi/util.py index f10fbc61..68b192be 100644 --- a/pungi/util.py +++ b/pungi/util.py @@ -189,11 +189,19 @@ def explode_rpm_package(pkg_path, target_dir): """Explode a rpm package into target_dir.""" pkg_path = os.path.abspath(pkg_path) makedirs(target_dir) - # rpm2archive writes to stdout only if reading from stdin, thus the redirect - run( - "rpm2archive - <%s | tar xfz - && chmod -R a+rX ." % shlex_quote(pkg_path), - workdir=target_dir, - ) + try: + # rpm2archive writes to stdout only if reading from stdin, thus the redirect + run( + "rpm2archive - <%s | tar xfz - && chmod -R a+rX ." % shlex_quote(pkg_path), + workdir=target_dir, + ) + except RuntimeError: + # Fall back to rpm2cpio in case rpm2archive failed (most likely due to + # not being present on the system). + run( + "rpm2cpio %s | cpio -iuvmd && chmod -R a+rX ." % shlex_quote(pkg_path), + workdir=target_dir, + ) def pkg_is_rpm(pkg_obj):