add post install configurable dependency checking.
authorjbj <devnull@localhost>
Fri, 23 Jul 1999 19:19:15 +0000 (19:19 +0000)
committerjbj <devnull@localhost>
Fri, 23 Jul 1999 19:19:15 +0000 (19:19 +0000)
CVS patchset: 3202
CVS date: 1999/07/23 19:19:15

CHANGES
build/files.c
macros.in
po/rpm.pot
rpm.spec

diff --git a/CHANGES b/CHANGES
index 4019ad7..c9b9d22 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -16,6 +16,7 @@
        - print all dependencies for each package at end of build.
        - the death of RPMSENSE_SERIAL, use [epoch:]version[-release] instead.
        - add _mandir/_infodir macro expansions to docdirs (Tomasz Kloczko).
+       - add post install configurable dependency checking.
 
 3.0.1 -> 3.0.2
        - eliminate armv4 entries from rpmrc (Andrew E. Mileski).
index 510ab5e..aef2265 100644 (file)
@@ -1490,7 +1490,7 @@ int processSourceFiles(Spec spec)
 }
 
 static StringBuf getOutputFrom(char *dir, char *argv[],
-                       char *writePtr, int writeBytesLeft,
+                       const char *writePtr, int writeBytesLeft,
                        int failNonZero)
 {
     int progPID;
@@ -1615,22 +1615,50 @@ top:
     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;
@@ -1640,93 +1668,79 @@ static int generateAutoReqProv(Spec spec, Package pkg,
        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)
 {
@@ -1830,7 +1844,7 @@ int processBinaryFiles(Spec spec, int installSpecialDoc, int test)
            res = rc;
        }
 
-       generateAutoReqProv(spec, pkg, pkg->cpioList, pkg->cpioCount);
+       generateDepends(spec, pkg, pkg->cpioList, pkg->cpioCount);
        printDeps(pkg->header);
        
     }
index 5ad702d..acae7fc 100644 (file)
--- a/macros.in
+++ b/macros.in
@@ -1,4 +1,4 @@
-# $Id: macros.in,v 1.31 1999/05/14 18:59:43 jbj Exp $
+# $Id: macros.in,v 1.32 1999/07/23 19:19:15 jbj Exp $
 #==============================================================================
 # Macro naming conventions (preliminary):
 #
 %_dbpath               %{_var}/lib/rpm
 %_defaultdocdir                %{_usr}/doc
 #
+%__find_provides       @FINDPROVIDES@
+%__find_requires       @FINDREQUIRES@
+#%__find_prereq                ???
+#%__find_conflicts     ???
+#%__find_obsoletes     ???
+#
 # XXX fixowner, fixgroup, and fixperms are run at the end of hardcoded setup
 %_fixowner             [ `%{__id} -u` = '0' ] && %{__chown} -Rf root
 %_fixgroup             [ `%{__id} -u` = '0' ] && %{__chgrp} -Rf @ROOT_GROUP@
index e12420f..13c87d9 100644 (file)
@@ -6,7 +6,7 @@
 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"
@@ -1411,48 +1411,42 @@ msgstr ""
 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 ""
index 382455f..1ca75de 100644 (file)
--- a/rpm.spec
+++ b/rpm.spec
@@ -2,7 +2,7 @@ Summary: The Red Hat package management system.
 Name: rpm
 %define version 3.0.3
 Version: %{version}
-Release: 0.7
+Release: 0.8
 Group: System Environment/Base
 Source: ftp://ftp.rpm.org/pub/rpm/dist/rpm-3.0.x/rpm-%{version}.tar.gz
 Copyright: GPL