summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichal Domonkos <mdomonko@redhat.com>2023-02-21 14:21:14 +0100
committerMichal Domonkos <mdomonko@redhat.com>2023-03-13 15:32:25 +0100
commite5592b233c1fe4d3e66597055e40f0b5ff043b47 (patch)
tree66aff6ef81191268b12d97847378a04990fcd226
parent67b6660d7ed862e5203695e2a401023a6a00e9b6 (diff)
downloadrpm-e5592b233c1fe4d3e66597055e40f0b5ff043b47.tar.gz
Don't repeat %patchN deprecation warning
Avoid flooding the build log for SPECs that contain a lot of these lines, one warning should be enough. Just mention how many were found. Including the line itself in the message is no longer relevant so remove that, too. The cost we pay for having the total count is that we'll no longer log the warning when an RPMLOG_ERR occurs somewhere in the process. Moving it below the exit label would fix that but also cause the warning to always be printed *last*, possibly confusing the user if there's an actual error further up in the output... so just go with the former. Note that we may want to revert this in the future and replace it with a proper rpmlog-native suppression mechanism for duplicate warnings. Fixes: #2383 (backported from commit 6c17e2fbee8ae2aa7ab960a4ede380dfba55e610)
-rw-r--r--build/parsePrep.c9
-rw-r--r--build/rpmbuild_internal.h2
-rw-r--r--build/spec.c1
-rw-r--r--tests/Makefile.am1
-rw-r--r--tests/data/SPECS/hello-patch.spec20
-rw-r--r--tests/rpmbuild.at5
6 files changed, 32 insertions, 6 deletions
diff --git a/build/parsePrep.c b/build/parsePrep.c
index 7b80f82c1..da7e33bfd 100644
--- a/build/parsePrep.c
+++ b/build/parsePrep.c
@@ -345,10 +345,8 @@ static rpmRC doPatchMacro(rpmSpec spec, const char *line)
/* Convert %patchN to %patch -PN to simplify further processing */
if (! strchr(" \t\n", line[6])) {
- rpmlog(RPMLOG_WARNING,
- _("%%patchN is deprecated, use %%patch N (or %%patch -P N):\n%s"),
- line);
rasprintf(&buf, "%%patch -P %s", line + 6);
+ spec->numConverted++;
}
poptParseArgvString(buf ? buf : line, &argc, &argv);
@@ -448,6 +446,11 @@ int parsePrep(rpmSpec spec)
}
}
+ if (spec->numConverted)
+ rpmlog(RPMLOG_WARNING,
+ _("%%patchN is deprecated (%i usages found), "
+ "use %%patch N (or %%patch -P N)\n"), spec->numConverted);
+
exit:
argvFree(saveLines);
diff --git a/build/rpmbuild_internal.h b/build/rpmbuild_internal.h
index a93b339a1..09baee2fa 100644
--- a/build/rpmbuild_internal.h
+++ b/build/rpmbuild_internal.h
@@ -151,6 +151,8 @@ struct rpmSpec_s {
StringBuf parsed; /*!< parsed spec contents */
Package packages; /*!< Package list. */
+
+ int numConverted; /*!< no. of automatic %patchN conversions */
};
#define PACKAGE_NUM_DEPS 12
diff --git a/build/spec.c b/build/spec.c
index 1a59266ac..c43124c49 100644
--- a/build/spec.c
+++ b/build/spec.c
@@ -231,6 +231,7 @@ rpmSpec newSpec(void)
spec->numSources = 0;
spec->autonum_patch = -1;
spec->autonum_source = -1;
+ spec->numConverted = 0;
spec->sourceRpmName = NULL;
spec->sourcePkgId = NULL;
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 733eaca90..fa9406bc1 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -127,6 +127,7 @@ EXTRA_DIST += data/SPECS/source_space.spec
EXTRA_DIST += data/SOURCES/source_space.tar.gz
EXTRA_DIST += data/SPECS/fifo.spec
EXTRA_DIST += data/SPECS/dev.spec
+EXTRA_DIST += data/SPECS/hello-patch.spec
EXTRA_DIST += data/keys/rpm.org-rsa-2048-test.pgp
EXTRA_DIST += data/keys/rpm.org-rsa-2048-test.pub
EXTRA_DIST += data/keys/rpm.org-rsa-2048-test.pgp
diff --git a/tests/data/SPECS/hello-patch.spec b/tests/data/SPECS/hello-patch.spec
new file mode 100644
index 000000000..9f5b6cef2
--- /dev/null
+++ b/tests/data/SPECS/hello-patch.spec
@@ -0,0 +1,20 @@
+Name: hello
+Version: 1.0
+Release: 1
+Group: Testing
+License: GPL
+Summary: Simple rpm demonstration.
+
+Source0: hello-1.0.tar.gz
+Patch0: hello-1.0-install.patch
+Patch1: hello-1.0-modernize.patch
+
+%description
+Simple rpm demonstration.
+
+%prep
+%setup -q
+%patch0 -p1 -b .install
+%patch1 -p1 -b .modernize
+
+%changelog
diff --git a/tests/rpmbuild.at b/tests/rpmbuild.at
index 0e250023f..c7a1c7e89 100644
--- a/tests/rpmbuild.at
+++ b/tests/rpmbuild.at
@@ -302,12 +302,11 @@ AT_SETUP([rpmbuild with deprecated patch])
AT_KEYWORDS([build])
RPMDB_INIT
AT_CHECK([
-runroot rpmbuild -bp --quiet /data/SPECS/hello2-suid.spec
+runroot rpmbuild -bp --quiet /data/SPECS/hello-patch.spec
],
[0],
[ignore],
-[warning: %patchN is deprecated, use %patch N (or %patch -P N):
-%patch0 -p1 -b .modernize
+[warning: %patchN is deprecated (2 usages found), use %patch N (or %patch -P N)
])
AT_CLEANUP