31 { NULL,
'a', POPT_ARG_STRING, NULL,
'a', NULL, NULL},
32 { NULL,
'b', POPT_ARG_STRING, NULL,
'b', NULL, NULL},
33 { NULL,
'c', 0, &
createDir, 0, NULL, NULL},
34 { NULL,
'D', 0, &
leaveDirs, 0, NULL, NULL},
35 { NULL,
'n', POPT_ARG_STRING, &
dirName, 0, NULL, NULL},
37 { NULL,
'q', 0, &
quietly, 0, NULL, NULL},
38 { 0, 0, 0, 0, 0, NULL, NULL}
52 if (
Lstat(urlfn, &sb)) {
54 urlfn, strerror(
errno));
80 int reverse,
int removeEmpties,
int fuzz,
const char *subdir)
84 const char *fn, *Lurlfn;
85 static char buf[BUFSIZ];
86 char args[BUFSIZ], *t = args;
90 const char *patch, *
flags;
95 #if defined(RPM_VENDOR_OPENPKG)
98 t =
stpcpy(t,
"-b --suffix .orig ");
104 sprintf(t,
"%10.10d", fuzz);
112 for (sp = spec->
sources; sp != NULL; sp = sp->
next) {
125 Lurlfn =
_free(Lurlfn);
130 urltype =
urlPath(Lurlfn, &fn);
140 Lurlfn =
_free(Lurlfn);
146 if (strcmp(patch,
"%{__patch}") == 0)
149 flags =
rpmExpand(
"%{?_default_patch_flags}%{!?_default_patch_flags:-s}", NULL);
154 switch (compressed) {
159 zipper =
"%{__gzip}";
162 zipper =
"%{__bzip2}";
165 zipper =
"%{__lzop}";
168 zipper =
"%{__lzma}";
177 "echo \"Patch #%d (%s):\"\n"
178 "%s -d < '%s' | %s -p%d %s %s\n"
180 "if [ $STATUS -ne 0 ]; then\n"
185 (
const char *) basename((
char *)fn),
188 fn, patch, strip, args, flags);
189 zipper =
_free(zipper);
192 "echo \"Patch #%d (%s):\"\n"
193 "%s -p%d %s %s < '%s'", c,
195 (
const char *) basename((
char *)fn),
197 patch, strip, args, flags, fn);
200 patch =
_free(patch);
201 flags =
_free(flags);
202 Lurlfn =
_free(Lurlfn);
219 const char *fn, *Lurlfn;
220 static char buf[BUFSIZ];
228 for (sp = spec->
sources; sp != NULL; sp = sp->
next) {
242 #if defined(RPM_VENDOR_OPENPKG)
250 Lurlfn =
_free(Lurlfn);
255 urltype =
urlPath(Lurlfn, &fn);
265 Lurlfn =
_free(Lurlfn);
276 fprintf(stderr,
"==> %s: %s\n", fn, t);
283 if (strcmp(tar,
"%{__tar}") == 0)
286 #if defined(RPM_VENDOR_ARK)
296 switch (compressed) {
302 t =
"%{__bzip2} -dc";
314 #if defined(RPM_VENDOR_OPENPKG)
315 t =
"%{__bsdtar} -x -f";
320 t =
"%{__unzip} -qq";
328 zipper =
_free(zipper);
343 "if [ $STATUS -ne 0 ]; then\n"
356 Lurlfn =
_free(Lurlfn);
390 if ((rc = poptParseArgvString(line, &argc, &argv))) {
399 optCon = poptGetContext(NULL, argc, argv,
optionsTable, 0);
400 while ((arg = poptGetNextOpt(optCon)) > 0) {
401 optArg = poptGetOptArg(optCon);
407 spec->
lineNum, (optArg ? optArg :
"???"));
410 optCon = poptFreeContext(optCon);
419 (void)
rpmiobAppend((arg ==
'a' ? after : before), chptr, 1);
426 poptBadOption(optCon, POPT_BADOPTION_NOALIAS),
430 optCon = poptFreeContext(optCon);
440 (void)
snprintf(buf,
sizeof(buf),
"%s-%s", N, V);
441 buf[
sizeof(buf)-1] =
'\0';
448 optCon = poptFreeContext(optCon);
453 const char *buildDir;
455 (void)
urlPath(buildDirURL, &buildDir);
457 sprintf(buf,
"cd '%s'", buildDir);
459 buildDirURL =
_free(buildDirURL);
471 mkdir_p =
rpmExpand(
"%{?__mkdir_p}%{!?__mkdir_p:mkdir -p}", NULL);
474 sprintf(buf,
"%s '%s'\ncd '%s'",
476 mkdir_p =
_free(mkdir_p);
508 {
static const char *fixmacs[] =
509 {
"%{_fixowner}",
"%{_fixgroup}",
"%{_fixperms}", NULL };
512 for (fm = fixmacs; *fm; fm++) {
515 if (fix && *fix !=
'%')
541 char buf[BUFSIZ], *bp;
545 memset(patch_nums, 0,
sizeof(patch_nums));
546 opt_P = opt_p = opt_R = opt_E = 0;
547 opt_F =
rpmExpandNumeric(
"%{?_default_patch_fuzz}%{!?_default_patch_fuzz:-1}");
552 if (! strchr(
" \t\n", line[6])) {
554 sprintf(buf,
"%%patch -P %s", line + 6);
560 for (bp = buf; (s = strtok(bp,
" \t\n")) != NULL;) {
565 if (!strcmp(s,
"-P")) {
567 }
else if (!strcmp(s,
"-R")) {
569 }
else if (!strcmp(s,
"-E")) {
571 }
else if (!strcmp(s,
"-b")) {
573 opt_b = strtok(NULL,
" \t\n");
576 _(
"line %d: Need arg to %%patch -b: %s\n"),
580 }
else if (!strcmp(s,
"-z")) {
582 opt_b = strtok(NULL,
" \t\n");
585 _(
"line %d: Need arg to %%patch -z: %s\n"),
589 }
else if (!strcmp(s,
"-F")) {
591 const char * fnum = (!strchr(
" \t\n", s[2])
592 ? s+2 : strtok(NULL,
" \t\n"));
595 opt_F = (fnum ? strtol(fnum, &end, 10) : 0);
596 if (! opt_F || *end) {
598 _(
"line %d: Bad arg to %%patch -F: %s\n"),
602 }
else if (!strcmp(s,
"-d")) {
604 opt_d = strtok(NULL,
" \t\n");
607 _(
"line %d: Need arg to %%patch -d: %s\n"),
611 }
else if (!strncmp(s,
"-p",
sizeof(
"-p")-1)) {
613 if (! strchr(
" \t\n", s[2])) {
616 s = strtok(NULL,
" \t\n");
619 _(
"line %d: Need arg to %%patch -p: %s\n"),
626 _(
"line %d: Bad arg to %%patch -p: %s\n"),
632 if (patch_index == 1024) {
636 if (
parseNum(s, &(patch_nums[patch_index]))) {
649 s =
doPatch(spec, 0, opt_p, opt_b, opt_R, opt_E, opt_F, opt_d);
655 for (x = 0; x < patch_index; x++) {
656 s =
doPatch(spec, patch_nums[x], opt_p, opt_b, opt_R, opt_E, opt_F, opt_d);
679 if ((buf = (
char *)malloc(buf_len)) == NULL)
682 for (i = (
int)strlen(buf); i <= 11; i++)
685 i = (int)strlen(buf);
687 xx =
snprintf(buf+i, buf_len-i,
" %9lu Bytes\n", (
unsigned long)st->st_size);
689 xx =
snprintf(buf+i, buf_len-i,
" ...MISSING\n");
702 #if defined(RPM_VENDOR_OPENPKG)
705 const char *Lmacro, *Lurlfn = NULL;
706 const char *Rmacro, *Rurlfn = NULL;
715 Lurlfn =
rpmGenPath(NULL,
"%{?_sourcedir}", NULL);
716 if (Lurlfn != NULL && *Lurlfn !=
'\0')
718 Lurlfn =
_free(Lurlfn);
724 Lurlfn =
rpmGenPath(NULL,
"%{?_patchdir}", NULL);
725 if (Lurlfn != NULL && *Lurlfn !=
'\0')
727 Lurlfn =
_free(Lurlfn);
733 Lurlfn =
rpmGenPath(NULL,
"%{?_icondir}", NULL);
734 if (Lurlfn != NULL && *Lurlfn !=
'\0')
736 Lurlfn =
_free(Lurlfn);
744 for (sp = spec->
sources; sp != NULL; sp = sp->
next) {
746 #if defined(RPM_VENDOR_OPENPKG)
747 Smacro =
"%{?_specdir}/";
749 #if defined(RPM_VENDOR_OPENPKG)
756 Rmacro =
"%{?_Rsourcedir}/";
759 Rmacro =
"%{?_Rpatchdir}/";
762 Rmacro =
"%{?_Ricondir}/";
766 #if defined(RPM_VENDOR_OPENPKG)
771 rc =
Lstat(Lurlfn, &st);
778 rc =
Lstat(Lurlfn, &st);
788 if (
errno != ENOENT) {
798 if (cp != NULL && strcmp(cp,
"/") != 0) {
801 if (!(Rurlfn == NULL || Rurlfn[0] ==
'\0' || !strcmp(Rurlfn,
"/") || !strcmp(Lurlfn, Rurlfn))) {
834 Lurlfn =
_free(Lurlfn);
835 Rurlfn =
_free(Rurlfn);
851 if (spec->
prep != NULL) {
888 for (lines = saveLines; *lines; lines++) {
890 for (cp = *lines; *cp ==
' ' || *cp ==
'\t'; cp++)
892 if (!strncmp(cp,
"%setup",
sizeof(
"%setup")-1)) {
895 }
else if (! strncmp(cp,
"%patch",
sizeof(
"%patch")-1)) {
901 if (res && !spec->
force) {