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);
141 Lurlfn =
_free(Lurlfn);
147 if (strcmp(patch,
"%{__patch}") == 0)
150 flags =
rpmExpand(
"%{?_default_patch_flags}%{!?_default_patch_flags:-s}", NULL);
155 switch (compressed) {
160 zipper =
"%{__gzip}";
163 zipper =
"%{__bzip2}";
166 zipper =
"%{__lzop}";
169 zipper =
"%{__lzma}";
178 "echo \"Patch #%d (%s):\"\n"
179 "%s -d < '%s' | %s -p%d %s %s\n"
181 "if [ $STATUS -ne 0 ]; then\n"
186 (
const char *) basename((
char *)fn),
189 fn, patch, strip, args, flags);
190 zipper =
_free(zipper);
193 "echo \"Patch #%d (%s):\"\n"
194 "%s -p%d %s %s < '%s'", c,
196 (
const char *) basename((
char *)fn),
198 patch, strip, args, flags, fn);
201 patch =
_free(patch);
202 flags =
_free(flags);
203 Lurlfn =
_free(Lurlfn);
220 const char *fn, *Lurlfn;
221 static char buf[BUFSIZ];
230 for (sp = spec->
sources; sp != NULL; sp = sp->
next) {
240 t = strrchr(sp->
source,
'.');
241 if(t && !strcasecmp(t,
".gem"))
244 t =
stpcpy(taropts,
"-x");
254 #if defined(RPM_VENDOR_OPENPKG)
262 Lurlfn =
_free(Lurlfn);
267 urltype =
urlPath(Lurlfn, &fn);
278 Lurlfn =
_free(Lurlfn);
289 fprintf(stderr,
"==> %s: %s\n", fn, t);
296 if (strcmp(tar,
"%{__tar}") == 0)
299 #if defined(RPM_VENDOR_ARK)
309 switch (compressed) {
315 t =
"%{__bzip2} -dc";
330 t =
"%{__lrzip} -dqo-";
337 #if defined(RPM_VENDOR_OPENPKG)
338 t =
"%{__bsdtar} -x -f";
343 t =
"%{__unzip} -qq";
351 zipper =
_free(zipper);
366 "if [ $STATUS -ne 0 ]; then\n"
379 "if [ -f data.tar.gz ]; then\n"
389 Lurlfn =
_free(Lurlfn);
424 if ((rc = poptParseArgvString(line, &argc, &argv))) {
433 optCon = poptGetContext(NULL, argc, argv,
optionsTable, 0);
434 while ((arg = poptGetNextOpt(optCon)) > 0) {
435 optArg = poptGetOptArg(optCon);
441 spec->
lineNum, (optArg ? optArg :
"???"));
442 optCon = poptFreeContext(optCon);
451 (void)
rpmiobAppend((arg ==
'a' ? after : before), chptr, 1);
458 poptBadOption(optCon, POPT_BADOPTION_NOALIAS),
460 optCon = poptFreeContext(optCon);
470 (void)
snprintf(buf,
sizeof(buf),
"%s-%s", N, V);
471 buf[
sizeof(buf)-1] =
'\0';
478 optCon = poptFreeContext(optCon);
483 const char *buildDir;
485 (void)
urlPath(buildDirURL, &buildDir);
487 sprintf(buf,
"cd '%s'", buildDir);
489 buildDirURL =
_free(buildDirURL);
500 for (sp = spec->
sources; sp != NULL; sp = sp->
next) {
506 char *t = strrchr(sp->
source,
'.');
507 if(t && !strcasecmp(t,
".gem"))
515 mkdir_p =
rpmExpand(
"%{?__mkdir_p}%{!?__mkdir_p:mkdir -p}", NULL);
518 sprintf(buf,
"%s '%s'\ncd '%s'",
520 mkdir_p =
_free(mkdir_p);
550 {
static const char *fixmacs[] =
551 {
"%{_fixowner}",
"%{_fixgroup}",
"%{_fixperms}", NULL };
554 for (fm = fixmacs; *fm; fm++) {
557 if (fix && *fix !=
'%')
587 char buf[BUFSIZ], *bp;
591 memset(patch_nums, 0,
sizeof(patch_nums));
592 opt_P = opt_p = opt_R = opt_E = 0;
593 opt_F =
rpmExpandNumeric(
"%{?_default_patch_fuzz}%{!?_default_patch_fuzz:-1}");
598 if (! strchr(
" \t\n", line[6])) {
600 sprintf(buf,
"%%patch -P %s", line + 6);
606 for (bp = buf; (s = strtok(bp,
" \t\n")) != NULL;) {
611 if (!strcmp(s,
"-P")) {
613 }
else if (!strcmp(s,
"-R")) {
615 }
else if (!strcmp(s,
"-E")) {
617 }
else if (!strcmp(s,
"-b")) {
619 opt_b = strtok(NULL,
" \t\n");
622 _(
"line %d: Need arg to %%patch -b: %s\n"),
626 }
else if (!strcmp(s,
"-z")) {
628 opt_b = strtok(NULL,
" \t\n");
631 _(
"line %d: Need arg to %%patch -z: %s\n"),
635 }
else if (!strcmp(s,
"-F")) {
637 const char * fnum = (!strchr(
" \t\n", s[2])
638 ? s+2 : strtok(NULL,
" \t\n"));
641 opt_F = (fnum ? strtol(fnum, &end, 10) : 0);
642 if (! opt_F || *end) {
644 _(
"line %d: Bad arg to %%patch -F: %s\n"),
648 }
else if (!strcmp(s,
"-d")) {
650 opt_d = strtok(NULL,
" \t\n");
653 _(
"line %d: Need arg to %%patch -d: %s\n"),
657 }
else if (!strncmp(s,
"-p",
sizeof(
"-p")-1)) {
659 if (! strchr(
" \t\n", s[2])) {
662 s = strtok(NULL,
" \t\n");
665 _(
"line %d: Need arg to %%patch -p: %s\n"),
672 _(
"line %d: Bad arg to %%patch -p: %s\n"),
678 if (patch_index == 1024) {
682 if (
parseNum(s, &(patch_nums[patch_index]))) {
695 s =
doPatch(spec, 0, opt_p, opt_b, opt_R, opt_E, opt_F, opt_d);
701 for (x = 0; x < patch_index; x++) {
702 s =
doPatch(spec, patch_nums[x], opt_p, opt_b, opt_R, opt_E, opt_F, opt_d);
725 if ((buf = (
char *)malloc(buf_len)) == NULL)
728 for (i = (
int)strlen(buf); i <= 11; i++)
731 i = (int)strlen(buf);
733 xx =
snprintf(buf+i, buf_len-i,
" %9lu Bytes\n", (
unsigned long)st->st_size);
735 xx =
snprintf(buf+i, buf_len-i,
" ...MISSING\n");
748 #if defined(RPM_VENDOR_OPENPKG)
751 const char *Lmacro, *Lurlfn = NULL;
752 const char *Rmacro, *Rurlfn = NULL;
761 Lurlfn =
rpmGenPath(NULL,
"%{?_sourcedir}", NULL);
762 if (Lurlfn != NULL && *Lurlfn !=
'\0')
764 Lurlfn =
_free(Lurlfn);
770 Lurlfn =
rpmGenPath(NULL,
"%{?_patchdir}", NULL);
771 if (Lurlfn != NULL && *Lurlfn !=
'\0')
773 Lurlfn =
_free(Lurlfn);
779 Lurlfn =
rpmGenPath(NULL,
"%{?_icondir}", NULL);
780 if (Lurlfn != NULL && *Lurlfn !=
'\0')
782 Lurlfn =
_free(Lurlfn);
790 for (sp = spec->
sources; sp != NULL; sp = sp->
next) {
792 #if defined(RPM_VENDOR_OPENPKG)
793 Smacro =
"%{?_specdir}/";
795 #if defined(RPM_VENDOR_OPENPKG)
802 Rmacro =
"%{?_Rsourcedir}/";
805 Rmacro =
"%{?_Rpatchdir}/";
808 Rmacro =
"%{?_Ricondir}/";
812 #if defined(RPM_VENDOR_OPENPKG)
817 rc =
Lstat(Lurlfn, &st);
824 rc =
Lstat(Lurlfn, &st);
834 if (
errno != ENOENT) {
844 if (cp != NULL && strcmp(cp,
"/") != 0) {
847 if (!(Rurlfn == NULL || Rurlfn[0] ==
'\0' || !strcmp(Rurlfn,
"/") || !strcmp(Lurlfn, Rurlfn))) {
880 Lurlfn =
_free(Lurlfn);
881 Rurlfn =
_free(Rurlfn);
897 if (spec->
prep != NULL) {
934 for (lines = saveLines; *lines; lines++) {
936 for (cp = *lines; *cp ==
' ' || *cp ==
'\t'; cp++)
938 if (!strncmp(cp,
"%setup",
sizeof(
"%setup")-1)) {
941 }
else if (! strncmp(cp,
"%patch",
sizeof(
"%patch")-1)) {
947 if (res && !spec->
force) {