public inbox for git-commits@fedoraproject.org
help / color / mirror / Atom feed
To: git-commits@fedoraproject.org
Subject: [rpms/python3-rpm] epel9-next: Merge epel9-next into epel9
Date: Fri, 13 Nov 2026 19:46:27 GMT	[thread overview]
Message-ID: <179459918792.1.6280821725700486917.rpms-python3-rpm-576fe28657b9@fedoraproject.org> (raw)

A new commit has been pushed.

Repo   : rpms/python3-rpm
Branch : epel9-next
Commit : 576fe28657b9c224e94ebd152c2c24978cadc394
Author : Miro Hrončok <miro@hroncok.cz>
Date   : 2025-07-03T13:38:59+02:00
Stats  : +658/-3 in 7 file(s)
URL    : https://src.fedoraproject.org/rpms/python3-rpm/c/576fe28657b9c224e94ebd152c2c24978cadc394?branch=epel9-next

Log:
Merge epel9-next into epel9

---
diff --git a/0001-Allow-parametric-macros-to-opt-out-of-option-process.patch b/0001-Allow-parametric-macros-to-opt-out-of-option-process.patch
new file mode 100644
index 0000000..52723c3
--- /dev/null
+++ b/0001-Allow-parametric-macros-to-opt-out-of-option-process.patch
@@ -0,0 +1,92 @@
+From 1f9a0e049e2db70e6fc6d630fa3c63f57517dea4 Mon Sep 17 00:00:00 2001
+From: Panu Matilainen <pmatilai@redhat.com>
+Date: Fri, 9 Oct 2020 14:43:14 +0300
+Subject: [PATCH] Allow parametric macros to opt out of option processing
+ (#547)
+MIME-Version: 1.0
+Content-Type: text/plain; charset=UTF-8
+Content-Transfer-Encoding: 8bit
+
+Macros might want to pass along options meant for others while perhaps
+modifying some of them, without exposing it all to users.
+
+Have "-" as the parametric macro opts string disable all options processing
+in rpm, allowing the macro to handle the raw argument list as they place.
+
+Fixes: #547
+
+(cherry picked from commit f9516434dd70cf0d5125e9e997b2c278b4fb4bf2)
+
+Co-Authored-By: Miro Hrončok <miro@hroncok.cz>
+---
+ doc/manual/macros |  3 ++-
+ rpmio/macro.c     |  7 ++++++-
+ tests/rpmmacro.at | 12 ++++++++++++
+ 3 files changed, 20 insertions(+), 2 deletions(-)
+
+diff --git a/doc/manual/macros b/doc/manual/macros
+index 45345d036..a33c54e03 100644
+--- a/doc/manual/macros
++++ b/doc/manual/macros
+@@ -22,7 +22,8 @@ All whitespace surrounding \<body\> is removed.  Name may be composed
+ of alphanumeric characters, and the character `_' and must be at least
+ 3 characters in length. A macro without an (opts) field is "simple" in that
+ only recursive macro expansion is performed. A parameterized macro contains
+-an (opts) field. The opts (i.e. string between parentheses) is passed
++an (opts) field. "-" as opts disables all option processing, otherwise
++the opts (i.e. string between parentheses) are passed
+ exactly as is to getopt(3) for argc/argv processing at the beginning of
+ a macro invocation.  While a parameterized macro is being expanded, the
+ following shell-like macros are available:
+diff --git a/rpmio/macro.c b/rpmio/macro.c
+index 35d896049..490bf9a6a 100644
+--- a/rpmio/macro.c
++++ b/rpmio/macro.c
+@@ -910,6 +910,7 @@ grabArgs(MacroBuf mb, const rpmMacroEntry me, const char * se,
+     ARGV_t argv = NULL;
+     int argc = 0;
+     int c;
++    int run;
+ 
+     /* 
+      * Prepare list of call arguments, starting with macro name as argv[0].
+@@ -960,8 +961,12 @@ grabArgs(MacroBuf mb, const rpmMacroEntry me, const char * se,
+     opts = me->opts;
+     argc = argvCount(argv);
+ 
++    /* If option processing is disabled, the while below will be skipped */
++    run = strcmp(opts, "-");
++    if (!run)
++	optind = 1;
+     /* Define option macros. */
+-    while ((c = getopt(argc, argv, opts)) != -1)
++    while (run && (c = getopt(argc, argv, opts)) != -1)
+     {
+ 	char *name = NULL, *body = NULL;
+ 	if (c == '?' || strchr(opts, c) == NULL) {
+diff --git a/tests/rpmmacro.at b/tests/rpmmacro.at
+index 873783153..faafb170d 100644
+--- a/tests/rpmmacro.at
++++ b/tests/rpmmacro.at
+@@ -198,6 +198,18 @@ bar' \
+ ])
+ AT_CLEANUP
+ 
++AT_SETUP([parametrized macro 6])
++AT_KEYWORDS([macros])
++AT_CHECK([
++runroot rpm \
++    --define '%foo(-) %{*}' \
++    --eval '%foo 5 a -z -b2'
++],
++[0],
++[5 a -z -b2
++])
++AT_CLEANUP
++
+ AT_SETUP([uncompress macro 1])
+ AT_KEYWORDS([macros])
+ AT_CHECK([
+-- 
+2.47.1
+

diff --git a/0001-Replace-uses-of-deprecated-PyEval_CallObject-with-Py.patch b/0001-Replace-uses-of-deprecated-PyEval_CallObject-with-Py.patch
new file mode 100644
index 0000000..0d113c0
--- /dev/null
+++ b/0001-Replace-uses-of-deprecated-PyEval_CallObject-with-Py.patch
@@ -0,0 +1,37 @@
+From 9ef1e790602622ab7d5e3b680b105958ee0199e7 Mon Sep 17 00:00:00 2001
+From: Panu Matilainen <pmatilai@redhat.com>
+Date: Wed, 28 Oct 2020 09:09:47 +0200
+Subject: [PATCH] Replace uses of deprecated PyEval_CallObject() with
+ PyObject_Call()
+
+Python 3.9 has deprecated PyEval_CallObject(), replace with a more
+modern and documented interface (https://bugs.python.org/issue29548).
+---
+ python/rpmts-py.c | 4 ++--
+ 1 file changed, 2 insertions(+), 2 deletions(-)
+
+diff --git a/python/rpmts-py.c b/python/rpmts-py.c
+index c2a4150..fa09220 100644
+--- a/python/rpmts-py.c
++++ b/python/rpmts-py.c
+@@ -244,7 +244,7 @@ rpmts_SolveCallback(rpmts ts, rpmds ds, const void * data)
+     args = Py_BuildValue("(OiNNi)", cbInfo->tso,
+ 		rpmdsTagN(ds), utf8FromString(rpmdsN(ds)),
+ 		utf8FromString(rpmdsEVR(ds)), rpmdsFlags(ds));
+-    result = PyEval_CallObject(cbInfo->cb, args);
++    result = PyObject_Call(cbInfo->cb, args, NULL);
+     Py_DECREF(args);
+ 
+     if (!result) {
+@@ -536,7 +536,7 @@ rpmtsCallback(const void * hd, const rpmCallbackType what,
+ 	Py_INCREF(pkgObj);
+ 
+     args = Py_BuildValue("(iLLOO)", what, amount, total, pkgObj, cbInfo->data);
+-    result = PyEval_CallObject(cbInfo->cb, args);
++    result = PyObject_Call(cbInfo->cb, args, NULL);
+     Py_DECREF(args);
+     Py_DECREF(pkgObj);
+ 
+-- 
+2.50.0
+

diff --git a/0001-Report-unsafe-symlinks-during-installation-as-a-spec.patch b/0001-Report-unsafe-symlinks-during-installation-as-a-spec.patch
new file mode 100644
index 0000000..3da0ec0
--- /dev/null
+++ b/0001-Report-unsafe-symlinks-during-installation-as-a-spec.patch
@@ -0,0 +1,215 @@
+From fb192da52f3f390793dbaffe66c6148f497a8023 Mon Sep 17 00:00:00 2001
+From: Panu Matilainen <pmatilai@redhat.com>
+Date: Mon, 19 Aug 2024 11:03:10 +0300
+Subject: [PATCH 1/2] Report unsafe symlinks during installation as a specific
+ case
+
+RPM refuses to follow non root owned symlinks pointing to files owned by
+another user for security reasons. This case was lumped in with
+O_DIRECTORY behavior, leading to confusing error message as the symlink
+often indeed points at a directory. Emit a more meaningful error message
+when encountering unsafe symlinks.
+
+We already detect the error condition in the main if block here, might
+as well set the error code right there and then so we don't need to
+redetect later. We previously only tested for the unsafe link condition
+when our O_DIRECTORY equivalent was set, but that seems wrong. Probably
+doesn't matter with the existing callers, but we really must not
+follow those unsafe symlinks no matter what.
+
+Co-authored-by: Florian Festi <ffesti@redhat.com>
+
+Backported from commits:
+14516542c113560dc0070df2f9102568a7a71b58
+535eacc96ae6fe5289a2917bb0af43e491b0f4f4
+
+Tests are excluded from this backport since they would need significant
+rework, the use case will be covered by Beaker.
+
+Fixes: RHEL-33393
+---
+ lib/fsm.c   | 70 +++++++++++++++++++++++++++--------------------------
+ lib/rpmfi.c |  1 +
+ 2 files changed, 37 insertions(+), 34 deletions(-)
+
+diff --git a/lib/fsm.c b/lib/fsm.c
+index 9dd50b784..720d4a2ec 100644
+--- a/lib/fsm.c
++++ b/lib/fsm.c
+@@ -65,7 +65,7 @@ struct filedata_s {
+  * things around needlessly 
+  */ 
+ static const char * fileActionString(rpmFileAction a);
+-static int fsmOpenat(int dirfd, const char *path, int flags, int dir);
++static int fsmOpenat(int *fdp, int dirfd, const char *path, int flags, int dir);
+ static int fsmClose(int *wfdp);
+ 
+ /** \ingroup payload
+@@ -98,9 +98,9 @@ static int fsmLink(int odirfd, const char *opath, int dirfd, const char *path)
+ #ifdef WITH_CAP
+ static int cap_set_fileat(int dirfd, const char *path, cap_t fcaps)
+ {
+-    int rc = -1;
+-    int fd = fsmOpenat(dirfd, path, O_RDONLY|O_NOFOLLOW, 0);
+-    if (fd >= 0) {
++    int fd = -1;
++    int rc = fsmOpenat(&fd, dirfd, path, O_RDONLY|O_NOFOLLOW, 0);
++    if (!rc) {
+ 	rc = cap_set_fd(fd, fcaps);
+ 	fsmClose(&fd);
+     }
+@@ -299,12 +299,12 @@ static int fsmMkdir(int dirfd, const char *path, mode_t mode)
+     return rc;
+ }
+ 
+-static int fsmOpenat(int dirfd, const char *path, int flags, int dir)
++static int fsmOpenat(int *wfdp, int dirfd, const char *path, int flags, int dir)
+ {
+     struct stat lsb, sb;
+     int sflags = flags | O_NOFOLLOW;
+     int fd = openat(dirfd, path, sflags);
+-    int ffd = fd;
++    int rc = 0;
+ 
+     /*
+      * Only ever follow symlinks by root or target owner. Since we can't
+@@ -313,7 +313,7 @@ static int fsmOpenat(int dirfd, const char *path, int flags, int dir)
+      * it could've only been the link owner or root.
+      */
+     if (fd < 0 && errno == ELOOP && flags != sflags) {
+-	ffd = openat(dirfd, path, flags);
++	int ffd = openat(dirfd, path, flags);
+ 	if (ffd >= 0) {
+ 	    if (fstatat(dirfd, path, &lsb, AT_SYMLINK_NOFOLLOW) == 0) {
+ 		if (fstat(ffd, &sb) == 0) {
+@@ -322,17 +322,26 @@ static int fsmOpenat(int dirfd, const char *path, int flags, int dir)
+ 		    }
+ 		}
+ 	    }
+-	    if (ffd != fd)
++	    /* Symlink with non-matching owners */
++	    if (ffd != fd) {
+ 		close(ffd);
++		rc = RPMERR_INVALID_SYMLINK;
++	    }
+ 	}
+     }
+ 
+     /* O_DIRECTORY equivalent */
+-    if (dir && ((fd != ffd) || (fd >= 0 && fstat(fd, &sb) == 0 && !S_ISDIR(sb.st_mode)))) {
+-	errno = ENOTDIR;
++    if (!rc && dir && fd >= 0 && fstat(fd, &sb) == 0 && !S_ISDIR(sb.st_mode))
++	rc = RPMERR_ENOTDIR;
++
++    if (!rc && fd < 0)
++	rc = RPMERR_OPEN_FAILED;
++
++    if (rc)
+ 	fsmClose(&fd);
+-    }
+-    return fd;
++
++    *wfdp = fd;
++    return rc;
+ }
+ 
+ static int fsmDoMkDir(rpmPlugins plugins, int dirfd, const char *dn,
+@@ -351,9 +360,7 @@ static int fsmDoMkDir(rpmPlugins plugins, int dirfd, const char *dn,
+ 	rc = fsmMkdir(dirfd, dn, mode);
+ 
+     if (!rc) {
+-	*fdp = fsmOpenat(dirfd, dn, O_RDONLY|O_NOFOLLOW, 1);
+-	if (*fdp == -1)
+-	    rc = RPMERR_ENOTDIR;
++	rc = fsmOpenat(fdp, dirfd, dn, O_RDONLY|O_NOFOLLOW, 1);
+     }
+ 
+     if (!rc) {
+@@ -378,47 +385,44 @@ static int ensureDir(rpmPlugins plugins, const char *p, int owned, int create,
+     char *sp = NULL, *bn;
+     char *apath = NULL;
+     int oflags = O_RDONLY;
+-    int rc = 0;
+ 
+     if (*dirfdp >= 0)
+-	return rc;
++	return 0;
+ 
+-    int dirfd = fsmOpenat(-1, "/", oflags, 1);
++    int dirfd = -1;
++    int rc = fsmOpenat(&dirfd, -1, "/", oflags, 1);
+     int fd = dirfd; /* special case of "/" */
+ 
+     char *path = xstrdup(p);
+     char *dp = path;
+ 
+     while ((bn = strtok_r(dp, "/", &sp)) != NULL) {
+-	fd = fsmOpenat(dirfd, bn, oflags, 1);
++	rc = fsmOpenat(&fd, dirfd, bn, oflags, 1);
+ 	/* assemble absolute path for plugins benefit, sigh */
+ 	apath = rstrscat(&apath, "/", bn, NULL);
+ 
+-	if (fd < 0 && errno == ENOENT && create) {
++	if (rc && errno == ENOENT && create) {
+ 	    mode_t mode = S_IFDIR | (_dirPerms & 07777);
+ 	    rc = fsmDoMkDir(plugins, dirfd, bn, apath, owned, mode, &fd);
+ 	}
+ 
+ 	fsmClose(&dirfd);
+-	if (fd >= 0) {
+-	    dirfd = fd;
+-	} else {
+-	    if (!quiet) {
+-		rpmlog(RPMLOG_ERR, _("failed to open dir %s of %s: %s\n"),
+-			bn, p, strerror(errno));
+-	    }
+-	    rc = RPMERR_OPEN_FAILED;
++	if (rc)
+ 	    break;
+-	}
+ 
++	dirfd = fd;
+ 	dp = NULL;
+     }
+ 
+     if (rc) {
++	if (!quiet) {
++	    char *msg = rpmfileStrerror(rc);
++	    rpmlog(RPMLOG_ERR, _("failed to open dir %s of %s: %s\n"),
++		    bn, p, msg);
++	    free(msg);
++	}
+ 	fsmClose(&fd);
+ 	fsmClose(&dirfd);
+-    } else {
+-	rc = 0;
+     }
+     *dirfdp = dirfd;
+ 
+@@ -1025,10 +1029,8 @@ setmeta:
+ 		/* Only follow safe symlinks, and never on temporary files */
+ 		if (fp->suffix)
+ 		    flags |= AT_SYMLINK_NOFOLLOW;
+-		fd = fsmOpenat(di.dirfd, fp->fpath, flags,
++		rc = fsmOpenat(&fd, di.dirfd, fp->fpath, flags,
+ 				S_ISDIR(fp->sb.st_mode));
+-		if (fd < 0)
+-		    rc = RPMERR_OPEN_FAILED;
+ 	    }
+ 
+ 	    if (!rc && fp->setmeta) {
+diff --git a/lib/rpmfi.c b/lib/rpmfi.c
+index b5223a43f..e8e3ea294 100644
+--- a/lib/rpmfi.c
++++ b/lib/rpmfi.c
+@@ -2436,6 +2436,7 @@ char * rpmfileStrerror(int rc)
+     case RPMERR_DIGEST_MISMATCH: s = _("Digest mismatch");	break;
+     case RPMERR_INTERNAL:	s = _("Internal error");	break;
+     case RPMERR_UNMAPPED_FILE:	s = _("Archive file not in header"); break;
++    case RPMERR_INVALID_SYMLINK: s = _("Unsafe symlink");	break;
+     case RPMERR_ENOENT:	s = strerror(ENOENT); break;
+     case RPMERR_ENOTEMPTY:	s = strerror(ENOTEMPTY); break;
+     case RPMERR_EXIST_AS_DIR:
+-- 
+2.47.1
+

diff --git a/0002-Fix-FA_TOUCH-ed-files-getting-removed-on-failed-upda.patch b/0002-Fix-FA_TOUCH-ed-files-getting-removed-on-failed-upda.patch
new file mode 100644
index 0000000..a690b52
--- /dev/null
+++ b/0002-Fix-FA_TOUCH-ed-files-getting-removed-on-failed-upda.patch
@@ -0,0 +1,46 @@
+From 9eedcd6b770154a8d853db30b49d411823d64c44 Mon Sep 17 00:00:00 2001
+From: Panu Matilainen <pmatilai@redhat.com>
+Date: Fri, 18 Oct 2024 14:50:35 +0300
+Subject: [PATCH 2/2] Fix FA_TOUCH'ed files getting removed on failed update
+
+On install/update, most files are laid down with a temporary suffix
+and if the update fails, removing those at the end of the loop is
+the right thing to do. However FA_TOUCH'ed files were already there,
+we only update their metadata, and we better not remove them!
+
+AFAICS this all versions since rpm >= 4.14 in one way or the other.
+If %_minimize_writes is enabled then it affects way more than just
+unmodified config files.
+
+The test is a simplified version of pam update failing in the original
+report. Technically, --nomtime should not be needed for the test
+verification but we don't even try to restore the metadata on failure,
+and fixing that is way out of scope here.
+
+Backported from commits:
+027ef640b33b38ca257bb301bb302e9c71d43c27
+
+Tests are excluded from this backport since they would need significant
+rework, the use case will be covered by Beaker.
+
+Fixes: RHEL-63070
+---
+ lib/fsm.c | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/lib/fsm.c b/lib/fsm.c
+index 720d4a2ec..91155c13c 100644
+--- a/lib/fsm.c
++++ b/lib/fsm.c
+@@ -1093,7 +1093,7 @@ setmeta:
+ 	    if (ensureDir(NULL, rpmfiDN(fi), 0, 0, 1, &di.dirfd))
+ 		continue;
+ 
+-	    if (fp->stage > FILE_NONE && !fp->skip) {
++	    if (fp->stage > FILE_NONE && !fp->skip && fp->action != FA_TOUCH) {
+ 		(void) fsmRemove(di.dirfd, fp->fpath, fp->sb.st_mode);
+ 	    }
+ 	}
+-- 
+2.47.1
+

diff --git a/gating.yaml b/gating.yaml
index 61de744..864b519 100644
--- a/gating.yaml
+++ b/gating.yaml
@@ -3,4 +3,4 @@ product_versions:
   - rhel-9
 decision_context: osci_compose_gate
 rules:
-  - !PassingTestCaseRule {test_case_name: baseos-ci.brew-build.tier1-gating.functional}
+  - !PassingTestCaseRule {test_case_name: osci.brew-build./plans/internal/CI-Tier-1.functional}

diff --git a/python3-rpm.spec b/python3-rpm.spec
index f7d269c..4d771c7 100644
--- a/python3-rpm.spec
+++ b/python3-rpm.spec
@@ -31,14 +31,14 @@
 
 %global rpmver 4.16.1.3
 #global snapver rc1
-%global rel 34
+%global rel 37
 %global sover 9
 %global rhelrel %{?snapver:0.%{snapver}.}%{rel}
 %global rel_next %{lua:print(tonumber(rpm.expand("%rel")) + 1)}
 %global rhelrel_next %{?snapver:0.%{snapver}.}%{rel_next}
 
 # Bump this for EPEL only rebuilds, reset when %%rel was bumped
-%global baserelease 2
+%global baserelease 1
 
 %global srcver %{rpmver}%{?snapver:-%{snapver}}
 %global srcdir %{?snapver:testing}%{!?snapver:rpm-%(echo %{rpmver} | cut -d'.' -f1-2).x}
@@ -119,6 +119,9 @@ Patch145: 0001-Fix-potential-use-of-uninitialized-pipe-array.patch
 Patch146: 0001-Fix-potential-use-of-uninitialized-pgp-struct.patch
 Patch147: 0001-Add-SourceLicense-tag-to-spec-syntax.patch
 Patch148: 0001-Talk-about-rpmsign-in-the-rpmsign-man-page.patch
+Patch149: 0001-Allow-parametric-macros-to-opt-out-of-option-process.patch
+Patch150: 0001-Report-unsafe-symlinks-during-installation-as-a-spec.patch
+Patch151: 0002-Fix-FA_TOUCH-ed-files-getting-removed-on-failed-upda.patch
 
 # These are not yet upstream
 Patch906: rpm-4.7.1-geode-i686.patch
@@ -142,6 +145,12 @@ Patch1001: rpm-4.16.1.3-find_debuginfo_vendor_opts.patch
 Patch1002: 0001-Macroize-find-debuginfo-script-location.patch
 Patch1003: 0001-Fix-root-relocation-regression.patch
 Patch1004: 0001-Skip-to-hashed-subpacket-data-directly.patch
+Patch1005: rpm-4.16.1.3-fix-patch-zero-semantics.patch
+
+# EPEL-only patches
+# Upstream backport for Python 3.13 compatibility
+# From https://github.com/rpm-software-management/rpm/commit/4821d42abb
+Patch3001: 0001-Replace-uses-of-deprecated-PyEval_CallObject-with-Py.patch
 
 # Partially GPL/LGPL dual-licensed and some bits with BSD
 # SourceLicense: (GPLv2+ and LGPLv2+ with exceptions) and BSD
@@ -226,6 +235,8 @@ programs that will manipulate RPM packages and databases.}
 %python3x_package
 %global python3_pkgversion 3.12
 %python3x_package
+%global python3_pkgversion 3.13
+%python3x_package
 
 %prep
 %autosetup -n rpm-%{srcver} %{?with_int_bdb:-a 1} -p1
@@ -288,6 +299,8 @@ pushd python
 %py3_build
 %global python3_pkgversion 3.12
 %py3_build
+%global python3_pkgversion 3.13
+%py3_build
 popd
 
 %install
@@ -300,6 +313,8 @@ pushd python
 %py3_install
 %global python3_pkgversion 3.12
 %py3_install
+%global python3_pkgversion 3.13
+%py3_install
 popd
 
 cat > $RPM_BUILD_ROOT/%{rpmhome}/debugedit << END
@@ -365,6 +380,8 @@ rm -r %{buildroot}%{_sysconfdir}
 %py3_check_import rpm rpm.transaction
 %global python3_pkgversion 3.12
 %py3_check_import rpm rpm.transaction
+%global python3_pkgversion 3.13
+%py3_check_import rpm rpm.transaction
 %if %{with check}
 make check TESTSUITEFLAGS=-j%{_smp_build_ncpus} || (cat tests/rpmtests.log; exit 1)
 # rpm >= 4.16.0 testsuite leaves a read-only tree behind, clean it up
@@ -383,7 +400,28 @@ make clean
 %{python3_sitearch}/rpm/
 %{python3_sitearch}/rpm-%{rpmver}*.egg-info/
 
+%global python3_pkgversion 3.13
+%files -n python%{python3_pkgversion}-rpm
+%license COPYING
+%{python3_sitearch}/rpm/
+%{python3_sitearch}/rpm-%{rpmver}*.egg-info/
+
 %changelog
+* Thu Jul 03 2025 Miro Hrončok <mhroncok@redhat.com> - 4.16.1.3-37.1
+- Add python3.13-rpm
+
+* Mon Jan 13 2025 Michal Domonkos <mdomonko@redhat.com> - 4.16.1.3-37
+- Allow parametric macros to opt out of option processing (RHEL-67161)
+- Report unsafe symlinks during installation as a specific case (RHEL-33393)
+- Fix FA_TOUCH'ed files getting removed on failed update (RHEL-63070)
+
+* Wed Nov 06 2024 Michal Domonkos <mdomonko@redhat.com> - 4.16.1.3-36
+- Improve newly added %%patch warning/error messages (RHEL-6294)
+
+* Wed Oct 16 2024 Michal Domonkos <mdomonko@redhat.com> - 4.16.1.3-35
+- Fix %%patch N applying Patch0 implicitly (RHEL-6294)
+- Issue deprecation warning for number-less %%patch (RHEL-6294)
+
 * Tue Aug 13 2024 Michal Domonkos <mdomonko@redhat.com> - 4.16.1.3-34
 - Fix discarded const qualifier in previous patch (RHEL-22607)
 

diff --git a/rpm-4.16.1.3-fix-patch-zero-semantics.patch b/rpm-4.16.1.3-fix-patch-zero-semantics.patch
new file mode 100644
index 0000000..63af766
--- /dev/null
+++ b/rpm-4.16.1.3-fix-patch-zero-semantics.patch
@@ -0,0 +1,227 @@
+From 2931047efc31f1288788bcdc8bd1d00b53cb9c76 Mon Sep 17 00:00:00 2001
+From: Panu Matilainen <pmatilai@redhat.com>
+Date: Wed, 30 Mar 2022 11:02:23 +0300
+Subject: [PATCH 1/3] Issue warning on implicit "%patch zero" variants,
+ sanitize semantics
+
+Supporting `%patch` with no number specified, in particular combinations
+like `%patch 1` meaning patches 0 and 1 (!), prevents further progress
+in this area. Dropping support for these is a case of sawing off a limb
+to save the patient, but there's enough history to numberless `%patch`
+that we need to take the long route of deprecating it first.
+
+To be exact:
+- we now issue a warning on `%patch` where no patch numbers have been
+  specified, but assume it to mean Patch0 for now
+- `%patch N' applies patch N and nothing else
+
+While at it, avoid an unnecessary strdup() and a dangling buf after
+free.
+
+(cherry picked from commit 02b8d8dccc0f045b0ebf81785cf6ad1056cf550e)
+---
+ build/parsePrep.c | 19 ++++++++-----------
+ 1 file changed, 8 insertions(+), 11 deletions(-)
+
+diff --git a/build/parsePrep.c b/build/parsePrep.c
+index d92e5cdf0..533de8a2c 100644
+--- a/build/parsePrep.c
++++ b/build/parsePrep.c
+@@ -380,9 +380,7 @@ exit:
+  * - %patchN is equal to %patch -P\<N\>
+  * - -P\<N\> -P\<N+1\>... can be used to apply several patch on a single line
+  * - Any trailing arguments are treated as patch numbers
+- * - Any combination of the above, except unless at least one -P is specified,
+- *   %patch is treated as "numberless patch" so that "%patch 1" actually tries
+- *   to pull in numberless "Patch:" and numbered "Patch1:".
++ * - Any combination of the above
+  *
+  * @param spec		build info
+  * @param line		current line from spec file
+@@ -420,15 +418,8 @@ static rpmRC doPatchMacro(rpmSpec spec, const char *line)
+     /* Convert %patchN to %patch -PN to simplify further processing */
+     if (! strchr(" \t\n", line[6])) {
+ 	rasprintf(&buf, "%%patch -P %s", line + 6);
+-    } else {
+-	/* %patch without a number refers to patch 0 */
+-	if (strstr(line+6, " -P") == NULL)
+-	    rasprintf(&buf, "%%patch -P %d %s", 0, line + 6);
+-	else
+-	    buf = xstrdup(line);
+     }
+-    poptParseArgvString(buf, &argc, &argv);
+-    free(buf);
++    poptParseArgvString(buf ? buf : line, &argc, &argv);
+ 
+     /* 
+      * Grab all -P<N> numbers for later processing. Stored as strings
+@@ -459,6 +450,11 @@ static rpmRC doPatchMacro(rpmSpec spec, const char *line)
+     /* Any trailing arguments are treated as patch numbers */
+     argvAppend(&patchnums, (ARGV_const_t) poptGetArgs(optCon));
+ 
++    if (argvCount(patchnums) == 0) {
++	rpmlog(RPMLOG_WARNING, _("Patch number not specified: %s\n"), line);
++	argvAdd(&patchnums, "0");
++    }
++
+     /* Convert to number, generate patch command and append to %prep script */
+     for (patch = patchnums; *patch; patch++) {
+ 	uint32_t pnum;
+@@ -484,6 +480,7 @@ exit:
+     free(opt_d);
+     free(opt_o);
+     free(argv);
++    free(buf);
+     poptFreeContext(optCon);
+     return rc;
+ }
+-- 
+2.47.0
+
+
+From a8e821ff5c126613e13277bfd8b2050b71d1ea4e Mon Sep 17 00:00:00 2001
+From: Michal Domonkos <mdomonko@redhat.com>
+Date: Fri, 9 Aug 2024 11:57:47 +0200
+Subject: [PATCH 2/3] Safeguard against silent Patch0 omission
+
+Commit 02b8d8dccc0f045b0ebf81785cf6ad1056cf550e fixed %patch so that it
+no longer applies Patch0 implicitly when used without the -P option.  A
+side effect of this is that, if a spec happens to rely on this quirky
+behavior, it will now skip Patch0 silently.
+
+To prevent such silent regressions in existing packages, make explicit
+Patch0 application mandatory unless all %patch lines in the spec use the
+non-ambiguous syntax (i.e. %patchN, %patch -PN or %patch 0).
+
+Basically, this reverts the above commit but replaces the original code
+with an error message.
+
+Resolves: RHEL-6294
+---
+ build/parsePrep.c         | 16 ++++++++++++++++
+ build/rpmbuild_internal.h |  3 +++
+ build/spec.c              |  3 +++
+ 3 files changed, 22 insertions(+)
+
+diff --git a/build/parsePrep.c b/build/parsePrep.c
+index 533de8a2c..9d64c2141 100644
+--- a/build/parsePrep.c
++++ b/build/parsePrep.c
+@@ -418,6 +418,10 @@ static rpmRC doPatchMacro(rpmSpec spec, const char *line)
+     /* Convert %patchN to %patch -PN to simplify further processing */
+     if (! strchr(" \t\n", line[6])) {
+ 	rasprintf(&buf, "%%patch -P %s", line + 6);
++    } else {
++	/* %patch without a number used to refer to patch 0 */
++	if (strstr(line+6, " -P") == NULL)
++	    spec->patch0_implicit = line;
+     }
+     poptParseArgvString(buf ? buf : line, &argc, &argv);
+ 
+@@ -464,6 +468,8 @@ static rpmRC doPatchMacro(rpmSpec spec, const char *line)
+ 		     *patch, line);
+ 	    goto exit;
+ 	}
++	if (pnum == 0)
++	    spec->patch0_explicit = line;
+ 	s = doPatch(spec, pnum, opt_p, opt_b, opt_R, opt_E, opt_F, opt_d, opt_o, opt_Z);
+ 	if (s == NULL) {
+ 	    goto exit;
+@@ -516,8 +522,18 @@ int parsePrep(rpmSpec spec)
+ 	}
+     }
+ 
++    if (spec->patch0_implicit && !spec->patch0_explicit &&
++	    findSource(spec, 0, RPMBUILD_ISPATCH)) {
++	rpmlog(RPMLOG_ERR, _("Patch0 no longer applied implicitly, pass 0 or -P0: %s\n"),
++	       spec->patch0_implicit);
++	res = PART_ERROR;
++	goto exit;
++    }
++
+ exit:
+     argvFree(saveLines);
++    spec->patch0_implicit = NULL;
++    spec->patch0_explicit = NULL;
+ 
+     return res;
+ }
+diff --git a/build/rpmbuild_internal.h b/build/rpmbuild_internal.h
+index 797d27744..545cc1f43 100644
+--- a/build/rpmbuild_internal.h
++++ b/build/rpmbuild_internal.h
+@@ -132,6 +132,9 @@ struct rpmSpec_s {
+     int autonum_patch;
+     int autonum_source;
+ 
++    const char *patch0_implicit;
++    const char *patch0_explicit;
++
+     char * sourceRpmName;
+     unsigned char * sourcePkgId;
+     Package sourcePackage;
+diff --git a/build/spec.c b/build/spec.c
+index 6d402319f..72f0d25bd 100644
+--- a/build/spec.c
++++ b/build/spec.c
+@@ -232,6 +232,9 @@ rpmSpec newSpec(void)
+     spec->autonum_patch = -1;
+     spec->autonum_source = -1;
+ 
++    spec->patch0_implicit = NULL;
++    spec->patch0_explicit = NULL;
++
+     spec->sourceRpmName = NULL;
+     spec->sourcePkgId = NULL;
+     spec->sourcePackage = NULL;
+-- 
+2.47.0
+
+
+From 896c7e37d65b1019cc179abcf9524807ba2006d2 Mon Sep 17 00:00:00 2001
+From: Michal Domonkos <mdomonko@redhat.com>
+Date: Wed, 6 Nov 2024 16:10:53 +0100
+Subject: [PATCH 3/3] Improve newly added %patch warning/error messages
+
+Make it obvious that the numberless %patch syntax is now *deprecated*
+(and thus no longer works in RHEL-10).
+
+Also suggest an actual fix to the user (in both messages), much like we
+have for the %patchN warning in RPM 4.19 (see commit
+eb5ece1267a22330f6116149997cf5cc1c22b21f).
+
+Kudos to Eva Mrakova for noticing & suggesting this.
+
+Related: RHEL-6294
+---
+ build/parsePrep.c | 7 ++++---
+ 1 file changed, 4 insertions(+), 3 deletions(-)
+
+diff --git a/build/parsePrep.c b/build/parsePrep.c
+index 9d64c2141..63014ea89 100644
+--- a/build/parsePrep.c
++++ b/build/parsePrep.c
+@@ -455,7 +455,8 @@ static rpmRC doPatchMacro(rpmSpec spec, const char *line)
+     argvAppend(&patchnums, (ARGV_const_t) poptGetArgs(optCon));
+ 
+     if (argvCount(patchnums) == 0) {
+-	rpmlog(RPMLOG_WARNING, _("Patch number not specified: %s\n"), line);
++	rpmlog(RPMLOG_WARNING, _("%%patch (without a number) is deprecated, "
++				 "add 0 (or -P 0): %s\n"), line);
+ 	argvAdd(&patchnums, "0");
+     }
+ 
+@@ -524,8 +525,8 @@ int parsePrep(rpmSpec spec)
+ 
+     if (spec->patch0_implicit && !spec->patch0_explicit &&
+ 	    findSource(spec, 0, RPMBUILD_ISPATCH)) {
+-	rpmlog(RPMLOG_ERR, _("Patch0 no longer applied implicitly, pass 0 or -P0: %s\n"),
+-	       spec->patch0_implicit);
++	rpmlog(RPMLOG_ERR, _("%%patch N no longer applies Patch0 implicitly, "
++			     "add 0 (or -P 0): %s\n"), spec->patch0_implicit);
+ 	res = PART_ERROR;
+ 	goto exit;
+     }
+-- 
+2.47.0
+

             reply	other threads:[~2026-11-13 19:46 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-13 19:46  [this message]
  -- strict thread matches above, loose matches on Subject: below --
2026-11-13 19:46 [rpms/python3-rpm] epel9-next: Merge epel9-next into epel9 
2026-11-13 19:46 
2026-11-13 19:46 
2026-11-13 19:46 
2026-11-13 19:46 

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=179459918792.1.6280821725700486917.rpms-python3-rpm-576fe28657b9@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