}
static StringBuf getOutputFrom(char *dir, char *argv[],
- char *writePtr, int writeBytesLeft,
+ const char *writePtr, int writeBytesLeft,
int failNonZero)
{
int progPID;
return readBuff;
}
-static int generateAutoReqProv(Spec spec, Package pkg,
+typedef struct {
+ const char *msg;
+ const char *argv[4];
+ int ntag;
+ int vtag;
+ int ftag;
+ int mask;
+ int xor;
+} DepMsg_t;
+
+DepMsg_t depMsgs[] = {
+ { "Provides", { "%{__find_provides}", NULL, NULL, NULL },
+ RPMTAG_PROVIDENAME, RPMTAG_PROVIDEVERSION, RPMTAG_PROVIDEFLAGS,
+ 0, -1 },
+ { "PreReq", { "%{__find_prereq}", NULL, NULL, NULL },
+ RPMTAG_REQUIRENAME, RPMTAG_REQUIREVERSION, RPMTAG_REQUIREFLAGS,
+ RPMSENSE_PREREQ, 0 },
+ { "Requires", { "%{__find_requires}", NULL, NULL, NULL },
+ -1, -1, RPMTAG_REQUIREFLAGS, /* XXX inherit name/version arrays */
+ RPMSENSE_PREREQ, RPMSENSE_PREREQ },
+ { "Conflicts", { "%{__find_conflicts}", NULL, NULL, NULL },
+ RPMTAG_CONFLICTNAME, RPMTAG_CONFLICTVERSION, RPMTAG_CONFLICTFLAGS,
+ 0, -1 },
+ { "Obsoletes", { "%{__find_obsoletes}", NULL, NULL, NULL },
+ RPMTAG_OBSOLETENAME, RPMTAG_OBSOLETEVERSION, RPMTAG_OBSOLETEFLAGS,
+ 0, -1 },
+ { NULL, { NULL, NULL, NULL, NULL }, 0, 0, 0, 0, 0 }
+};
+
+static int generateDepends(Spec spec, Package pkg,
struct cpioFileMapping *cpioList, int cpioCount)
{
StringBuf writeBuf;
int writeBytes;
StringBuf readBuf;
- char *argv[2];
- char **f, **fsave;
+ DepMsg_t *dm;
+ char *myargv[4];
+ int rc = 0;
- if (!cpioCount) {
+ if (cpioCount <= 0)
return 0;
- }
- if (! (pkg->autoReq || pkg->autoProv)) {
+ if (! (pkg->autoReq || pkg->autoProv))
return 0;
- }
writeBuf = newStringBuf();
writeBytes = 0;
cpioList++;
}
- /*** Do Provides ***/
+ for (dm = depMsgs; dm->msg != NULL; dm++) {
+ int i, tag, failnonzero;
+
+ tag = (dm->ftag > 0) ? dm->ftag : dm->ntag;
- if (pkg->autoProv) {
- rpmMessage(RPMMESS_NORMAL, _("Finding provides...\n"));
-
- argv[0] = FINDPROVIDES;
- argv[1] = NULL;
- readBuf = getOutputFrom(NULL, argv,
- getStringBuf(writeBuf), writeBytes, 1);
- if (readBuf == NULL) {
- rpmError(RPMERR_EXEC, _("Failed to find provides"));
- freeStringBuf(writeBuf);
- return RPMERR_EXEC;
+ switch(tag) {
+ case RPMTAG_PROVIDEFLAGS:
+ if (!pkg->autoProv)
+ continue;
+ failnonzero = 1;
+ break;
+ case RPMTAG_REQUIREFLAGS:
+ if (!pkg->autoReq)
+ continue;
+ failnonzero = 0;
+ break;
+ default:
+ continue;
+ break;
}
-
- fsave = splitString(getStringBuf(readBuf),
- strlen(getStringBuf(readBuf)), '\n');
- freeStringBuf(readBuf);
- for (f = fsave; *f != NULL; f++) {
- if (**f) {
- addReqProv(spec, pkg->header, RPMSENSE_PROVIDES, *f, NULL, 0);
- }
+
+ /* Get the script name to run */
+ myargv[0] = rpmExpand(dm->argv[0], NULL);
+
+ if (!(myargv[0] && *myargv[0] != '%'))
+ continue;
+
+ rpmMessage(RPMMESS_NORMAL, _("Finding %s: (using %s)...\n"),
+ dm->msg, myargv[0]);
+
+#if 0
+ if (*myargv[0] != '/') { /* XXX FIXME: stat script here */
+ free(myargv[0]);
+ myargv[0] = NULL;
+ continue;
}
- freeSplitString(fsave);
- }
+#endif
- /*** Do Requires ***/
+ /* Expand rest of script arguments (if any) */
+ for (i = 1; i < 4; i++) {
+ myargv[i] = dm->argv[i] ? rpmExpand(dm->argv[i], NULL) : NULL;
+ }
- if (pkg->autoReq) {
- rpmMessage(RPMMESS_NORMAL, _("Finding requires...\n"));
+ readBuf = getOutputFrom(NULL, myargv,
+ getStringBuf(writeBuf), writeBytes, failnonzero);
+
+ /* Free expanded args */
+ for (i = 0; i < 4; i++) {
+ if (myargv[i] == NULL) continue;
+ free(myargv[i]);
+ myargv[i] = NULL;
+ }
- argv[0] = FINDREQUIRES;
- argv[1] = NULL;
- readBuf = getOutputFrom(NULL, argv,
- getStringBuf(writeBuf), writeBytes, 0);
if (readBuf == NULL) {
- rpmError(RPMERR_EXEC, _("Failed to find requires"));
- freeStringBuf(writeBuf);
- return RPMERR_EXEC;
+ rc = RPMERR_EXEC;
+ rpmError(rc, _("Failed to find %s:"), dm->msg);
+ break;
}
- fsave = splitString(getStringBuf(readBuf),
- strlen(getStringBuf(readBuf)), '\n');
+ /* Parse dependencies into header */
+ rc = parseRCPOT(spec, pkg, getStringBuf(readBuf), tag, 0);
freeStringBuf(readBuf);
- for (f = fsave; *f != NULL; f++) {
- if (**f) {
- addReqProv(spec, pkg->header, RPMSENSE_ANY, *f, NULL, 0);
- }
+
+ if (rc) {
+ rpmError(rc, _("Failed to find %s:"), dm->msg);
+ break;
}
- freeSplitString(fsave);
}
- /*** Clean Up ***/
-
freeStringBuf(writeBuf);
-
- return 0;
+ return rc;
}
-typedef struct {
- const char *msg;
- int ntag;
- int vtag;
- int ftag;
- int mask;
- int xor;
-} DepMsg_t;
-
-DepMsg_t depMsgs[] = {
- { "Provides",
- RPMTAG_PROVIDENAME, RPMTAG_PROVIDEVERSION, RPMTAG_PROVIDEFLAGS,
- 0, -1 },
- { "PreReq",
- RPMTAG_REQUIRENAME, RPMTAG_REQUIREVERSION, RPMTAG_REQUIREFLAGS,
- RPMSENSE_PREREQ, 0 },
- { "Requires",
- -1, -1, -1, /* XXX inherit previous arrays */
- RPMSENSE_PREREQ, RPMSENSE_PREREQ },
- { "Conflicts",
- RPMTAG_CONFLICTNAME, RPMTAG_CONFLICTVERSION, RPMTAG_CONFLICTFLAGS,
- 0, -1 },
- { "Obsoletes",
- RPMTAG_OBSOLETENAME, RPMTAG_OBSOLETEVERSION, RPMTAG_OBSOLETEFLAGS,
- 0, -1 },
- { NULL, 0, 0, 0, 0, 0 }
-};
-
static void printDepMsg(DepMsg_t *dm, int count, const char **names,
const char **versions, int *flags)
{
res = rc;
}
- generateAutoReqProv(spec, pkg, pkg->cpioList, pkg->cpioCount);
+ generateDepends(spec, pkg, pkg->cpioList, pkg->cpioCount);
printDeps(pkg->header);
}
msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
-"POT-Creation-Date: 1999-07-22 18:58-0400\n"
+"POT-Creation-Date: 1999-07-23 15:16-0400\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
msgid "line: %s"
msgstr ""
-#: ../build/files.c:1470 ../build/parsePrep.c:31
+#: ../build/files.c:1472 ../build/parsePrep.c:31
#, c-format
msgid "Bad owner/group: %s"
msgstr ""
-#: ../build/files.c:1523
+#: ../build/files.c:1525
#, c-format
msgid "Couldn't exec %s"
msgstr ""
-#: ../build/files.c:1527
+#: ../build/files.c:1529
#, c-format
msgid "Couldn't fork %s"
msgstr ""
-#: ../build/files.c:1606
+#: ../build/files.c:1608
#, c-format
msgid "%s failed"
msgstr ""
-#: ../build/files.c:1610
+#: ../build/files.c:1612
#, c-format
msgid "failed to write all data to %s"
msgstr ""
-#: ../build/files.c:1644
-msgid "Finding provides...\n"
-msgstr ""
-
-#: ../build/files.c:1651
-msgid "Failed to find provides"
-msgstr ""
-
-#: ../build/files.c:1670
-msgid "Finding requires...\n"
+#: ../build/files.c:1698
+#, c-format
+msgid "Finding %s: (using %s)...\n"
msgstr ""
-#: ../build/files.c:1677
-msgid "Failed to find requires"
+#: ../build/files.c:1726 ../build/files.c:1735
+#, c-format
+msgid "Failed to find %s:"
msgstr ""
-#: ../build/files.c:1825
+#: ../build/files.c:1841
#, c-format
msgid "Processing files: %s\n"
msgstr ""