Skip to content

Commit

Permalink
Unbreak numberless %patch from the autonumering changes
Browse files Browse the repository at this point in the history
Commit 5303626 incorrectly claims
that numberless Patch: and Source: referred to number zero internally,
instead they were special cased to INT_MAX which allowed differentiating
from zero and the cost of ugly hacks here and there, and making referring
to the patch/source by %{PATCH/SOURCE<N>) macro rather impossible.

Undo the rest of the INT_MAX magic too and make numberless %patch really
equal patch number zero. This makes it work for the common case, for
example in Fedora's > 19000 specs there is not a single case where
the former special INT_MAX magic would've been necessary. If this change
breaks somebody's spec, I'll promise to light a candle for it on a
dark and cold winter night, we have plenty of those here in Finland.
  • Loading branch information
pmatilai committed Jun 13, 2018
1 parent d15ea79 commit d4f63df
Showing 1 changed file with 5 additions and 14 deletions.
19 changes: 5 additions & 14 deletions build/parsePrep.c
Expand Up @@ -70,11 +70,7 @@ static char *doPatch(rpmSpec spec, uint32_t c, int strip, const char *db,
}
}
if (sp == NULL) {
if (c != INT_MAX) {
rpmlog(RPMLOG_ERR, _("No patch number %u\n"), c);
} else {
rpmlog(RPMLOG_ERR, _("%%patch without corresponding \"Patch:\" tag\n"));
}
rpmlog(RPMLOG_ERR, _("No patch number %u\n"), c);
goto exit;
}

Expand Down Expand Up @@ -121,15 +117,9 @@ static char *doPatch(rpmSpec spec, uint32_t c, int strip, const char *db,
free(arg_backup);
free(args);

if (c != INT_MAX) {
rasprintf(&buf, "echo \"Patch #%u (%s):\"\n"
rasprintf(&buf, "echo \"Patch #%u (%s):\"\n"
"%s\n",
c, basename(fn), patchcmd);
} else {
rasprintf(&buf, "echo \"Patch (%s):\"\n"
"%s\n",
basename(fn), patchcmd);
}
free(patchcmd);

exit:
Expand Down Expand Up @@ -463,10 +453,11 @@ static rpmRC doPatchMacro(rpmSpec spec, const char *line)
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", INT_MAX, line + 6); /* INT_MAX denotes not numbered %patch */
rasprintf(&buf, "%%patch -P %d %s", 0, line + 6);
else
buf = xstrdup(line); /* it is not numberless patch because -P is present */
buf = xstrdup(line);
}
poptParseArgvString(buf, &argc, &argv);
free(buf);
Expand Down

2 comments on commit d4f63df

@mlschroe
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ohhh, we're going full circle here. In the beginning numberless Source/Patch was the same as number zero.
In 2008 came commit 724b07b that used INT_MAX for Source and Patch. Shortly after that was commit 1a173c4 that made Source equal to Source0 again, but left Patch using INT_MAX. And now we're back at the beginning ;-)

@pmatilai
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I know. And in the intervening ten years I haven't seen a single package that actually benefited from the special INT_MAX treatment, everybody treats Patch: as if it was Patch0:, so having rpm doing something else seems dumb. Especially since we can do something more useful with the unnumbered version...

Please sign in to comment.