From 6c17e2fbee8ae2aa7ab960a4ede380dfba55e610 Mon Sep 17 00:00:00 2001 From: Michal Domonkos Date: Tue, 21 Feb 2023 14:21:14 +0100 Subject: 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 --- build/parsePrep.c | 9 ++++++--- build/rpmbuild_internal.h | 2 ++ build/spec.c | 1 + 3 files changed, 9 insertions(+), 3 deletions(-) (limited to 'build') diff --git a/build/parsePrep.c b/build/parsePrep.c index cc97303d3..f8e09a8c7 100644 --- a/build/parsePrep.c +++ b/build/parsePrep.c @@ -346,10 +346,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); @@ -449,6 +447,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 cc3afc0a7..3094b9217 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; -- cgit v1.2.1