public inbox for git-commits@fedoraproject.org
help / color / mirror / Atom feed
To: git-commits@fedoraproject.org
Subject: [rpms/rpkg] 1.70-1: Patch: Extract source RPMs with rpm2archive if possible
Date: Mon, 10 Aug 2026 21:44:29 GMT	[thread overview]
Message-ID: <178639826905.1.9572083147718606215.rpms-rpkg-5a3755498b80@fedoraproject.org> (raw)

            A new commit has been pushed.

            Repo   : rpms/rpkg
            Branch : 1.70-1
            Commit : 5a3755498b805c1cb3409167cccb1b947a52f713
            Author : Ondřej Nosek <onosek@redhat.com>
            Date   : 2022-08-19T14:32:03+00:00
            Stats  : +88/-3 in 2 file(s)
            URL    : https://src.fedoraproject.org/rpms/rpkg/c/5a3755498b805c1cb3409167cccb1b947a52f713?branch=1.70-1

            Log:
            Patch: Extract source RPMs with rpm2archive if possible

Signed-off-by: Ondřej Nosek <onosek@redhat.com>

---
diff --git a/0009-Extract-source-RPMs-with-rpm2archive-if-possible.patch b/0009-Extract-source-RPMs-with-rpm2archive-if-possible.patch
new file mode 100644
index 0000000..cf7ddc7
--- /dev/null
+++ b/0009-Extract-source-RPMs-with-rpm2archive-if-possible.patch
@@ -0,0 +1,81 @@
+From e4fd6dae0fad2be998e3708856eabdfba90624dd Mon Sep 17 00:00:00 2001
+From: Pavel Raiskup <praiskup@redhat.com>
+Date: Fri, 24 Jun 2022 09:41:08 +0200
+Subject: [PATCH] Extract source RPMs with rpm2archive if possible
+MIME-Version: 1.0
+Content-Type: text/plain; charset=UTF-8
+Content-Transfer-Encoding: 8bit
+
+The output format from rpm2archive is not bound with the 4GB file size
+limit, like the rpm2cpio is.
+
+Unfortunately, rpm2archive doesn'ŧ exist on EL7, and still doesn't
+support the -n option on EL8.
+
+Related: https://pagure.io/copr/copr/issue/2225
+Signed-off-by: Pavel Raiskup <praiskup@redhat.com>
+---
+ pyrpkg/utils.py | 40 +++++++++++++++++++++++++++++++++-------
+ 1 file changed, 33 insertions(+), 7 deletions(-)
+
+diff --git a/pyrpkg/utils.py b/pyrpkg/utils.py
+index d754d78..d3f7877 100644
+--- a/pyrpkg/utils.py
++++ b/pyrpkg/utils.py
+@@ -245,6 +245,21 @@ def is_file_in_directory(file_path, dir_path):
+     return
+ 
+ 
++def check_rpm2archive():
++    """
++    Check if rpm2archive exists, and if it supports the required argument.
++    """
++
++    try:
++        popen = subprocess.Popen(["rpm2archive", "--help"],
++                                 stdout=subprocess.PIPE,
++                                 stderr=subprocess.PIPE)
++        return "--nocompression" in popen.communicate()[0].decode("utf8")
++    except OSError:
++        pass
++    return False
++
++
+ def extract_srpm(srpm_path, target_dir=None):
+     """
+     Extract srpm file into target directory. Target directory is a current
+@@ -255,13 +270,24 @@ def extract_srpm(srpm_path, target_dir=None):
+     if target_dir and not os.path.isdir(target_dir):
+         raise IOError("Target directory doesn't exist: {0}".format(target_dir))
+ 
+-    # rpm2cpio <srpm> | cpio -iud --quiet
+-    cmd = ['rpm2cpio', srpm_path]
+-    # We have to force cpio to copy out (u) because git messes with timestamps
+-    cmd2 = ['cpio', '-iud', '--quiet']
+-    rpmcall = subprocess.Popen(cmd, stdout=subprocess.PIPE, universal_newlines=True)
+-    cpiocall = subprocess.Popen(cmd2, stdin=rpmcall.stdout, universal_newlines=True, cwd=target_dir)
+-    output, err = cpiocall.communicate()
++    # We prefer using the newer rpm2archive utility over rpm2cpio for extraction
++    # because it supports SRPMs >= 4GB (as long as it is available, i.e. epel8+)
++    use_rpm2archive = check_rpm2archive()
++
++    # Use one of those:
++    # rpm2archive -n - < SRPM_PATH | tar xf -
++    # rpm2cpio - < SRPM_PATH | cpio -iud --quiet
++    cmd = ['rpm2archive', '-n', '-'] if use_rpm2archive else ['rpm2cpio', '-']
++    # Overwrite existing files (tar's default, cpio -u), because git messes with
++    # timestamps.
++    cmd2 = ['tar', 'xf', '-'] if use_rpm2archive else ['cpio', '-iud', '--quiet']
++
++    with open(srpm_path, 'r') as stdin:
++        rpmcall = subprocess.Popen(cmd, stdout=subprocess.PIPE, stdin=stdin,
++                                   universal_newlines=True)
++        cpiocall = subprocess.Popen(cmd2, stdin=rpmcall.stdout,
++                                    universal_newlines=True, cwd=target_dir)
++        output, err = cpiocall.communicate()
+     return output, err
+ 
+ 
+-- 
+2.37.1
+

diff --git a/rpkg.spec b/rpkg.spec
index 8dac005..6c9ac6a 100644
--- a/rpkg.spec
+++ b/rpkg.spec
@@ -1,6 +1,6 @@
 Name:           rpkg
 Version:        1.64
-Release:        8%{?dist}
+Release:        9%{?dist}
 
 Summary:        Python library for interacting with rpm+git
 License:        GPLv2+ and LGPLv2
@@ -40,8 +40,9 @@ Patch3:         0003-Remove-Environment-Markers-syntax.patch
 Patch4:         0004-Add-custom-user-metadata-to-build-command.patch
 Patch5:         0005-Better-exit-code-for-connection-error.patch
 Patch6:         0006-add-background-option-for-container-build-which-allo.patch
-Patch7:         0007-Repair-flake8-complaints.patch
-Patch8:         0008-follow-redirects-for-lookaside.patch
+Patch7:         0009-Extract-source-RPMs-with-rpm2archive-if-possible.patch
+Patch8:         0007-Repair-flake8-complaints.patch
+Patch9:         0008-follow-redirects-for-lookaside.patch
 
 %description
 Python library for interacting with rpm+git
@@ -254,6 +255,9 @@ example_cli_dir=$RPM_BUILD_ROOT%{_datadir}/%{name}/examples/cli
 
 
 %changelog
+* Fri Aug 19 2022 Ondřej Nosek <onosek@redhat.com> - 1.64-9
+- Patch: Extract source RPMs with rpm2archive if possible
+
 * Thu Aug 18 2022 Ondřej Nosek <onosek@redhat.com> - 1.64-8
 - Patch: Repair flake8 complaints
 - Patch: follow redirects for lookaside

                 reply	other threads:[~2026-08-10 21:44 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=178639826905.1.9572083147718606215.rpms-rpkg-5a3755498b80@fedoraproject.org \
    --to=git-commits@fedoraproject.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox