Make %autopatch and %patch accept -pg
* parsePrep.c (doPatch): Change strip argument type to const char *. (doPatchMacro, doAutopatchMacro): Change opt_p variable type to char *, change checking of opt_p: it can be either a number or a 'g' symbol assuming that -pg is a valid option for patch command.
This commit is contained in:
parent
b0a545f593
commit
9c18a40269
@ -67,7 +67,7 @@ static int checkOwners(const char * urlfn)
|
|||||||
* @param dir dir to change to (i.e. patch -d argument)
|
* @param dir dir to change to (i.e. patch -d argument)
|
||||||
* @return expanded %patch macro (NULL on error)
|
* @return expanded %patch macro (NULL on error)
|
||||||
*/
|
*/
|
||||||
/*@observer@*/ static char *doPatch(Spec spec, int c, int strip, const char *db,
|
/*@observer@*/ static char *doPatch(Spec spec, int c, const char *strip, const char *db,
|
||||||
int reverse, int removeEmpties, int fuzz, const char *dir, int silent)
|
int reverse, int removeEmpties, int fuzz, const char *dir, int silent)
|
||||||
/*@globals rpmGlobalMacroContext,
|
/*@globals rpmGlobalMacroContext,
|
||||||
fileSystem@*/
|
fileSystem@*/
|
||||||
@ -88,7 +88,7 @@ static int checkOwners(const char * urlfn)
|
|||||||
const char *urlfn = rpmGetPath("%{_sourcedir}/", sp->source, NULL);
|
const char *urlfn = rpmGetPath("%{_sourcedir}/", sp->source, NULL);
|
||||||
|
|
||||||
char args[BUFSIZ];
|
char args[BUFSIZ];
|
||||||
sprintf(args, "%s%s-p%d",
|
sprintf(args, "%s%s-p%s",
|
||||||
arg_patch_flags, *arg_patch_flags ? " ": "", strip);
|
arg_patch_flags, *arg_patch_flags ? " ": "", strip);
|
||||||
if (silent)
|
if (silent)
|
||||||
strcat(args, " -s");
|
strcat(args, " -s");
|
||||||
@ -460,10 +460,10 @@ static int doAutopatchMacro(Spec spec, const char *line)
|
|||||||
int argc = 0, c, rc;
|
int argc = 0, c, rc;
|
||||||
const char **argv = NULL;
|
const char **argv = NULL;
|
||||||
|
|
||||||
int opt_p = 0;
|
char *opt_p = NULL;
|
||||||
int opt_F = rpmExpandNumeric("%{?_default_patch_fuzz}%{?!_default_patch_fuzz:-1}");
|
int opt_F = rpmExpandNumeric("%{?_default_patch_fuzz}%{?!_default_patch_fuzz:-1}");
|
||||||
struct poptOption const autopatchOpts[] = {
|
struct poptOption const autopatchOpts[] = {
|
||||||
{ NULL, 'p', POPT_ARG_INT, &opt_p, 'p', NULL, NULL },
|
{ NULL, 'p', POPT_ARG_STRING, &opt_p, 'p', NULL, NULL },
|
||||||
{ NULL, 'F', POPT_ARG_INT, &opt_F, 'F', NULL, NULL },
|
{ NULL, 'F', POPT_ARG_INT, &opt_F, 'F', NULL, NULL },
|
||||||
{ NULL, 0, 0, NULL, 0, NULL, NULL }
|
{ NULL, 0, 0, NULL, 0, NULL, NULL }
|
||||||
};
|
};
|
||||||
@ -486,6 +486,13 @@ static int doAutopatchMacro(Spec spec, const char *line)
|
|||||||
return RPMERR_BADSPEC;
|
return RPMERR_BADSPEC;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (strcmp(opt_p, "g") && parseNum(opt_p, NULL)) {
|
||||||
|
rpmError(RPMERR_BADSPEC,
|
||||||
|
_("line %d: Bad arg to %%autopatch -p: %s\n"),
|
||||||
|
spec->lineNum, spec->line);
|
||||||
|
return RPMERR_BADSPEC;
|
||||||
|
}
|
||||||
|
|
||||||
optCon = poptFreeContext(optCon);
|
optCon = poptFreeContext(optCon);
|
||||||
_free(argv);
|
_free(argv);
|
||||||
|
|
||||||
@ -531,17 +538,17 @@ static int doPatchMacro(Spec spec, char *line)
|
|||||||
fileSystem@*/
|
fileSystem@*/
|
||||||
/*@modifies spec->prep, rpmGlobalMacroContext, fileSystem @*/
|
/*@modifies spec->prep, rpmGlobalMacroContext, fileSystem @*/
|
||||||
{
|
{
|
||||||
char *opt_b, *opt_d;
|
char *opt_b, *opt_d, *opt_p;
|
||||||
int opt_P, opt_p, opt_R, opt_E, opt_F, opt_s;
|
int opt_P, opt_R, opt_E, opt_F, opt_s;
|
||||||
char *s;
|
char *s;
|
||||||
char buf[BUFSIZ], *bp;
|
char buf[BUFSIZ], *bp;
|
||||||
int patch_nums[1024]; /* XXX - we can only handle 1024 patches! */
|
int patch_nums[1024]; /* XXX - we can only handle 1024 patches! */
|
||||||
int patch_index, x;
|
int patch_index, x;
|
||||||
|
|
||||||
memset(patch_nums, 0, sizeof(patch_nums));
|
memset(patch_nums, 0, sizeof(patch_nums));
|
||||||
opt_P = opt_p = opt_R = opt_E = opt_s = 0;
|
opt_P = opt_R = opt_E = opt_s = 0;
|
||||||
opt_F = rpmExpandNumeric("%{?_default_patch_fuzz}%{?!_default_patch_fuzz:-1}");
|
opt_F = rpmExpandNumeric("%{?_default_patch_fuzz}%{?!_default_patch_fuzz:-1}");
|
||||||
opt_b = opt_d = NULL;
|
opt_p = opt_b = opt_d = NULL;
|
||||||
patch_index = 0;
|
patch_index = 0;
|
||||||
|
|
||||||
if (! strchr(" \t\n", line[6])) {
|
if (! strchr(" \t\n", line[6])) {
|
||||||
@ -595,17 +602,17 @@ static int doPatchMacro(Spec spec, char *line)
|
|||||||
} else if (!strncmp(s, "-p", sizeof("-p")-1)) {
|
} else if (!strncmp(s, "-p", sizeof("-p")-1)) {
|
||||||
/* unfortunately, we must support -pX */
|
/* unfortunately, we must support -pX */
|
||||||
if (! strchr(" \t\n", s[2])) {
|
if (! strchr(" \t\n", s[2])) {
|
||||||
s = s + 2;
|
opt_p = s + 2;
|
||||||
} else {
|
} else {
|
||||||
s = strtok(NULL, " \t\n");
|
opt_p = strtok(NULL, " \t\n");
|
||||||
if (s == NULL) {
|
if (!opt_p) {
|
||||||
rpmError(RPMERR_BADSPEC,
|
rpmError(RPMERR_BADSPEC,
|
||||||
_("line %d: Need arg to %%patch -p: %s\n"),
|
_("line %d: Need arg to %%patch -p: %s\n"),
|
||||||
spec->lineNum, spec->line);
|
spec->lineNum, spec->line);
|
||||||
return RPMERR_BADSPEC;
|
return RPMERR_BADSPEC;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (parseNum(s, &opt_p)) {
|
if (strcmp(opt_p, "g") && parseNum(opt_p, NULL)) {
|
||||||
rpmError(RPMERR_BADSPEC,
|
rpmError(RPMERR_BADSPEC,
|
||||||
_("line %d: Bad arg to %%patch -p: %s\n"),
|
_("line %d: Bad arg to %%patch -p: %s\n"),
|
||||||
spec->lineNum, spec->line);
|
spec->lineNum, spec->line);
|
||||||
|
Loading…
Reference in New Issue
Block a user