From 7c6c441f7b9b0a0ca3ec909305640bf87c50c101 Mon Sep 17 00:00:00 2001 From: Jakub Kadlcik Date: Aug 07 2024 14:19:41 +0000 Subject: [PATCH 1/2] Use quote from shlex instead of deprecated pipes Fix https://bugzilla.redhat.com/show_bug.cgi?id=2276893 The pipes module is deprecated since Python 3.11 and is removed since Python 3.13. --- diff --git a/preproc/preproc b/preproc/preproc index 4f36e2c..7ae4588 100755 --- a/preproc/preproc +++ b/preproc/preproc @@ -5,7 +5,7 @@ import sys import subprocess import tempfile import argparse -import pipes +import shlex import re @@ -16,7 +16,7 @@ def cmd_repr(cmd): quoted_items = [] for i in range(len(cmd)): - quoted_items.append(pipes.quote(cmd[i])) + quoted_items.append(shlex.quote(cmd[i])) return ' '.join(quoted_items) diff --git a/preproc/preproc-pyparsing b/preproc/preproc-pyparsing index 6b34c7b..777fbc8 100755 --- a/preproc/preproc-pyparsing +++ b/preproc/preproc-pyparsing @@ -5,7 +5,7 @@ import sys import subprocess import tempfile import argparse -import pipes +import shlex from pyparsing import Combine, CharsNotIn, Regex, ZeroOrMore, Suppress, Literal @@ -17,7 +17,7 @@ def cmd_repr(cmd): quoted_items = [] for i in range(len(cmd)): - quoted_items.append(pipes.quote(cmd[i])) + quoted_items.append(shlex.quote(cmd[i])) return ' '.join(quoted_items) diff --git a/rpkglib/rpm_package.py b/rpkglib/rpm_package.py index b14bce5..cff7392 100644 --- a/rpkglib/rpm_package.py +++ b/rpkglib/rpm_package.py @@ -7,7 +7,7 @@ import rpm import shutil import re -from pipes import quote +from shlex import quote from munch import Munch from tempfile import NamedTemporaryFile diff --git a/rpkglib/utils.py b/rpkglib/utils.py index a6d5c6d..593158f 100644 --- a/rpkglib/utils.py +++ b/rpkglib/utils.py @@ -5,7 +5,7 @@ import textwrap import subprocess import tempfile import munch -import pipes +import shlex import fnmatch import argparse import pycurl @@ -90,7 +90,7 @@ def cmd_repr(cmd): quoted_items = [] for i in range(len(cmd)): - quoted_items.append(pipes.quote(cmd[i])) + quoted_items.append(shlex.quote(cmd[i])) return ' '.join(quoted_items) @@ -104,7 +104,7 @@ def macro_helper_cmd(*args): def extract_srpm(srpm_path, destdir): - cmd = 'rpm2cpio {0} | cpio -idm --quiet'.format(pipes.quote(srpm_path)) + cmd = 'rpm2cpio {0} | cpio -idm --quiet'.format(shlex.quote(srpm_path)) run(cmd, cwd=destdir, shell=True) From 55d05bb00449c2816114732e70911b53bbf97c42 Mon Sep 17 00:00:00 2001 From: Jakub Kadlcik Date: Aug 07 2024 14:57:09 +0000 Subject: [PATCH 2/2] Make the INVALID_SPEC_TEMPLATE really invalid In Fedora Rawhide (F41), the following test fails spec_path = self.dump_spec(INVALID_SPEC_TEMPLATE) > with pytest.raises(RpkgError): E Failed: DID NOT RAISE tests/unit/test_rpm_package.py:414: Failed The `setup_source_symlinks` function should raise `RpkgError` because supposedly we call it on a broken specfile. The specfile is broken because it is missing %description. When I debug this on F40, I get: error: Package has no %description: testpkg ValueError: can't parse specfile When trying to build a specfile without %description on F40 it indeed fails with error: Package has no %description: hello However, since F41, this error isn't fatal. It is printed but the package builds successfully. TL;DR I am making the INVALID_SPEC_TEMPLATE more invalid by removing the Name tag. --- diff --git a/tests/unit/spec_templates.py b/tests/unit/spec_templates.py index 68371e6..55524ee 100644 --- a/tests/unit/spec_templates.py +++ b/tests/unit/spec_templates.py @@ -43,7 +43,6 @@ Patch0: $patch0 """) INVALID_SPEC_TEMPLATE = Template(""" -Name: $name Version: $version Release: $release Summary: This is a test package.