Remove rpmdbFindByFile from API (and fix RPMDBI_FILE iterator).
authorjbj <devnull@localhost>
Thu, 13 Apr 2000 12:43:49 +0000 (12:43 +0000)
committerjbj <devnull@localhost>
Thu, 13 Apr 2000 12:43:49 +0000 (12:43 +0000)
CVS patchset: 3676
CVS date: 2000/04/13 12:43:49

lib/depends.c
lib/rpmdb.c
lib/rpmlib.h
po/rpm.pot

index f6a3728..464d576 100644 (file)
@@ -526,6 +526,7 @@ int headerMatchesDepFlags(Header h, const char *reqName, const char * reqEVR, in
 
 }
 
+#ifdef DYING
 static inline int dbrecMatchesDepFlags(rpmTransactionSet rpmdep, int recOffset,
                                const char * reqName, const char * reqEVR,
                                int reqFlags, dbrecMatch_t matchDepFlags)
@@ -545,6 +546,7 @@ static inline int dbrecMatchesDepFlags(rpmTransactionSet rpmdep, int recOffset,
 
     return rc;
 }
+#endif
 
 rpmTransactionSet rpmtransCreateSet(rpmdb db, const char * root)
 {
@@ -611,8 +613,8 @@ int rpmtransAddPackage(rpmTransactionSet rpmdep, Header h, FD_t fd,
 {
     /* this is an install followed by uninstalls */
     dbiIndexSet matches = NULL;
-    char * name;
-    int count, i, j;
+    const char * name;
+    int count;
     const char ** obsoletes;
     int alNum;
     int * caps;
@@ -661,6 +663,7 @@ int rpmtransAddPackage(rpmTransactionSet rpmdep, Header h, FD_t fd,
     if (headerGetEntry(h, RPMTAG_OBSOLETENAME, NULL, (void **) &obsoletes, &count)) {
        const char **obsoletesEVR;
        int_32 *obsoletesFlags;
+       int j;
 
        headerGetEntry(h, RPMTAG_OBSOLETEVERSION, NULL, (void **) &obsoletesEVR, NULL);
        headerGetEntry(h, RPMTAG_OBSOLETEFLAGS, NULL, (void **) &obsoletesFlags, NULL);
@@ -865,7 +868,9 @@ static int unsatisfiedDepend(rpmTransactionSet rpmdep,
        const char * keyName, const char * keyEVR, int keyFlags,
        /*@out@*/ struct availablePackage ** suggestion)
 {
-    dbiIndexSet matches = NULL;                /* XXX DYING */
+#ifdef DYING
+    dbiIndexSet matches = NULL;
+#endif
     int rc = 0;        /* assume dependency is satisfied */
     int i;
 
@@ -893,7 +898,7 @@ static int unsatisfiedDepend(rpmTransactionSet rpmdep,
     if (rpmdep->db != NULL) {
        if (*keyName == '/') {
            /* keyFlags better be 0! */
-#ifndef DYING  /* XXX more to do here */
+#ifdef DYING
            if (!rpmdbFindByFile(rpmdep->db, keyName, &matches)) {
                for (i = 0; i < dbiIndexSetCount(matches); i++) {
                    unsigned int recOffset = dbiIndexRecordOffset(matches, i);
@@ -914,7 +919,7 @@ static int unsatisfiedDepend(rpmTransactionSet rpmdep,
            {   rpmdbMatchIterator mi;
                Header h2;
 
-               mi = rpmdbInitIterator(rpmdep->db, RPMDBI_PROVIDES, keyName, 0);
+               mi = rpmdbInitIterator(rpmdep->db, RPMDBI_FILE, keyName, 0);
                while ((h2 = rpmdbNextIterator(mi)) != NULL) {
                    unsigned int recOffset = rpmdbGetIteratorOffset(mi);
                    if (bsearch(&recOffset,
@@ -932,36 +937,13 @@ static int unsatisfiedDepend(rpmTransactionSet rpmdep,
            }
 #endif
        }
-       if (matches) {
-           dbiFreeIndexSet(matches);
-           matches = NULL;
-       }
-
 #ifdef DYING
-       if (!rpmdbFindByProvides(rpmdep->db, keyName, &matches)) {
-           for (i = 0; i < dbiIndexSetCount(matches); i++) {
-               unsigned int recOffset = dbiIndexRecordOffset(matches, i);
-               if (bsearch(&recOffset,
-                           rpmdep->removedPackages,
-                           rpmdep->numRemovedPackages,
-                           sizeof(int), intcmp))
-                   continue;
-               if (dbrecMatchesDepFlags(rpmdep, recOffset,
-                        keyName, keyEVR, keyFlags, rangeMatchesDepFlags)) {
-                   break;
-               }
-           }
-
-           if (i < dbiIndexSetCount(matches)) {
-               rpmMessage(RPMMESS_DEBUG, _("%s: %s satisfied by db provides.\n"), keyType, keyDepend);
-               goto exit;
-           }
-       }
        if (matches) {
            dbiFreeIndexSet(matches);
            matches = NULL;
        }
-#else
+#endif
+
        {   rpmdbMatchIterator mi;
            Header h2;
 
@@ -973,7 +955,7 @@ static int unsatisfiedDepend(rpmTransactionSet rpmdep,
                            rpmdep->numRemovedPackages,
                            sizeof(int), intcmp))
                    continue;
-               if (headerMatchesDepFlags(h2, keyName, keyEVR, keyFlags))
+               if (rangeMatchesDepFlags(h2, keyName, keyEVR, keyFlags))
                    break;
            }
            rpmdbFreeIterator(mi);
@@ -982,7 +964,6 @@ static int unsatisfiedDepend(rpmTransactionSet rpmdep,
                goto exit;
            }
        }
-#endif
 
        {   rpmdbMatchIterator mi;
            Header h2;
@@ -1027,10 +1008,12 @@ static int unsatisfiedDepend(rpmTransactionSet rpmdep,
     rc = 1;    /* dependency is unsatisfied */
 
 exit:
-    if (matches) {     /* XXX DYING */
+#ifdef DYING
+    if (matches) {
        dbiFreeIndexSet(matches);
        matches = NULL;
     }
+#endif
     return rc;
 }
 
@@ -1177,41 +1160,12 @@ static int checkPackageDeps(rpmTransactionSet rpmdep, struct problemsSet * psp,
 
 /* Adding: check name/provides key against each conflict match. */
 /* Erasing: check name/provides/filename key against each requiredby match. */
-#ifdef DYING
-static int checkPackageSet(rpmTransactionSet rpmdep, struct problemsSet * psp,
-       const char * key, dbiIndexSet matches)
-#else
 static int checkPackageSet(rpmTransactionSet rpmdep, struct problemsSet * psp,
        const char * key, /*@only@*/ rpmdbMatchIterator mi)
-#endif
 {
     Header h;
     int rc = 0;
-#ifdef DYING
-    int i;
-
-    for (i = 0; i < dbiIndexSetCount(matches); i++) {
-       unsigned int recOffset = dbiIndexRecordOffset(matches, i);
-       if (bsearch(&recOffset, rpmdep->removedPackages,
-                   rpmdep->numRemovedPackages, sizeof(int), intcmp))
-           continue;
-
-       h = rpmdbGetRecord(rpmdep->db, recOffset);
-       if (h == NULL) {
-           rpmError(RPMERR_DBCORRUPT,
-                     _("cannot read header at %d for dependency check"),
-                    rpmdep->removedPackages[i]);
-           return 1;
-       }
-
-       if (checkPackageDeps(rpmdep, psp, h, key)) {
-           headerFree(h);
-           return 1;
-       }
 
-       headerFree(h);
-    }
-#else
     while ((h = rpmdbNextIterator(mi)) != NULL) {
        unsigned int recOffset = rpmdbGetIteratorOffset(mi);
        if (bsearch(&recOffset, rpmdep->removedPackages,
@@ -1224,7 +1178,6 @@ static int checkPackageSet(rpmTransactionSet rpmdep, struct problemsSet * psp,
        }
     }
     rpmdbFreeIterator(mi);
-#endif
 
     return rc;
 }
@@ -1233,20 +1186,9 @@ static int checkPackageSet(rpmTransactionSet rpmdep, struct problemsSet * psp,
 static int checkDependentPackages(rpmTransactionSet rpmdep,
                        struct problemsSet * psp, const char * key)
 {
-#ifdef DYING
-    dbiIndexSet matches = NULL;
-    int rc = 0;
-
-    if (!rpmdbFindByRequiredBy(rpmdep->db, key, &matches))
-       rc = checkPackageSet(rpmdep, psp, key, matches);
-    if (matches)
-       dbiFreeIndexSet(matches);
-    return rc;
-#else
     rpmdbMatchIterator mi;
     mi = rpmdbInitIterator(rpmdep->db, RPMDBI_REQUIREDBY, key, 0);
     return checkPackageSet(rpmdep, psp, key, mi);
-#endif
 }
 
 /* Adding: check name/provides key against conflicts matches. */
@@ -1256,17 +1198,9 @@ static int checkDependentConflicts(rpmTransactionSet rpmdep,
     int rc = 0;
 
     if (rpmdep->db) {  /* XXX is this necessary? */
-#ifdef DYING
-       dbiIndexSet matches = NULL;
-       if (!rpmdbFindByConflicts(rpmdep->db, key, &matches))
-           rc = checkPackageSet(rpmdep, psp, key, matches);
-       if (matches)
-           dbiFreeIndexSet(matches);
-#else
        rpmdbMatchIterator mi;
        mi = rpmdbInitIterator(rpmdep->db, RPMDBI_CONFLICTS, key, 0);
        rc = checkPackageSet(rpmdep, psp, key, mi);
-#endif
     }
 
     return rc;
index f1d2934..bf0aef6 100644 (file)
@@ -271,7 +271,7 @@ Header rpmdbGetRecord(rpmdb db, unsigned int offset)
     return headerLoad(uh);
 }
 
-int rpmdbFindByFile(rpmdb db, const char * filespec, dbiIndexSet * matches)
+static int rpmdbFindByFile(rpmdb db, const char * filespec, dbiIndexSet * matches)
 {
     const char * dirName;
     const char * baseName;
@@ -372,20 +372,6 @@ int rpmdbFindByFile(rpmdb db, const char * filespec, dbiIndexSet * matches)
     return 0;
 }
 
-#ifdef DYING
-int rpmdbFindByProvides(rpmdb db, const char * filespec, dbiIndexSet * matches) {
-    return dbiSearchIndex(db->_dbi[RPMDBI_PROVIDES], filespec, 0, matches);
-}
-
-int rpmdbFindByRequiredBy(rpmdb db, const char * filespec, dbiIndexSet * matches) {
-    return dbiSearchIndex(db->_dbi[RPMDBI_REQUIREDBY], filespec, 0, matches);
-}
-
-int rpmdbFindByConflicts(rpmdb db, const char * filespec, dbiIndexSet * matches) {
-    return dbiSearchIndex(db->_dbi[RPMDBI_CONFLICTS], filespec, 0, matches);
-}
-#endif
-
 int rpmdbFindPackage(rpmdb db, const char * name, dbiIndexSet * matches) {
     return dbiSearchIndex(db->_dbi[RPMDBI_NAME], name, 0, matches);
 }
@@ -565,10 +551,14 @@ rpmdbMatchIterator rpmdbInitIterator(rpmdb db, int dbix, const void * key, size_
 
     if (key) {
        int rc;
-       rc = dbiSearchIndex(dbi, key, keylen, &set);
+       if (dbix == RPMDBI_FILE) {
+           rc = rpmdbFindByFile(db, key, &set);
+       } else {
+           rc = dbiSearchIndex(dbi, key, keylen, &set);
+       }
        switch (rc) {
        default:
-       case -1:                /* error */
+       case -1:        /* error */
        case 1:         /* not found */
            if (set)
                dbiFreeIndexSet(set);
index 827db50..e4a6851 100644 (file)
@@ -383,33 +383,18 @@ int rpmdbOpenForTraversal(const char * prefix, /*@out@*/ rpmdb * dbp);
  */
 Header rpmdbGetRecord(rpmdb db, unsigned int offset);
 
+#ifdef DYING
 /**
  * @param db           rpm database
  */
 int rpmdbFindByFile(rpmdb db, const char * filespec,
        /*@out@*/ dbiIndexSet * matches);
+#endif
 /**
  * @param db           rpm database
  */
 int rpmdbFindPackage(rpmdb db, const char * name,
        /*@out@*/ dbiIndexSet * matches);
-#ifdef DYING
-/**
- * @param db           rpm database
- */
-int rpmdbFindByProvides(rpmdb db, const char * provides,
-       /*@out@*/ dbiIndexSet * matches);
-/**
- * @param db           rpm database
- */
-int rpmdbFindByRequiredBy(rpmdb db, const char * requires,
-       /*@out@*/ dbiIndexSet * matches);
-/**
- * @param db           rpm database
- */
-int rpmdbFindByConflicts(rpmdb db, const char * conflicts,
-       /*@out@*/ dbiIndexSet * matches);
-#endif
 
 /* these are just convenience functions */
 /**
@@ -558,10 +543,10 @@ typedef enum rpmProblemType_e { RPMPROB_BADARCH,
 
 typedef /*@abstract@*/ struct rpmProblem_s {
     Header h, altH;
-    /*@dependent@*/ const void * key;
+/*@dependent@*/ const void * key;
     rpmProblemType type;
     int ignoreProblem;
-    /*@only@*/ const char * str1;
+/*@only@*/ const char * str1;
     unsigned long ulong1;
 } rpmProblem;
 
@@ -811,6 +796,7 @@ typedef     struct rpmQVArguments QVA_t;
  * @param db           rpm database
  */
 typedef        int (*QVF_t) (QVA_t *qva, rpmdb db, Header h);
+
 /**
  * @param db           rpm database
  */
index dfd449c..44b0ad2 100644 (file)
@@ -6,7 +6,7 @@
 msgid ""
 msgstr ""
 "Project-Id-Version: PACKAGE VERSION\n"
-"POT-Creation-Date: 2000-04-13 06:27-0400\n"
+"POT-Creation-Date: 2000-04-13 08:44-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"
@@ -2032,75 +2032,75 @@ msgstr ""
 msgid "  %s    A %s\tB %s\n"
 msgstr ""
 
-#: lib/depends.c:538
+#: lib/depends.c:539
 msgid "dbrecMatchesDepFlags() failed to read header"
 msgstr ""
 
-#: lib/depends.c:794
+#: lib/depends.c:797
 #, c-format
 msgid "%s: %s satisfied by added file list.\n"
 msgstr ""
 
-#: lib/depends.c:833
+#: lib/depends.c:836
 #, c-format
 msgid "%s: %s satisfied by added package.\n"
 msgstr ""
 
-#: lib/depends.c:850
+#: lib/depends.c:853
 #, c-format
 msgid "%s: %s satisfied by added provide.\n"
 msgstr ""
 
-#: lib/depends.c:881
+#: lib/depends.c:886
 #, c-format
 msgid "%s: %s satisfied by rpmrc provides.\n"
 msgstr ""
 
-#: lib/depends.c:909 lib/depends.c:929
+#: lib/depends.c:914 lib/depends.c:934
 #, c-format
 msgid "%s: %s satisfied by db file lists.\n"
 msgstr ""
 
-#: lib/depends.c:956 lib/depends.c:981
+#: lib/depends.c:963
 #, c-format
 msgid "%s: %s satisfied by db provides.\n"
 msgstr ""
 
-#: lib/depends.c:1003
+#: lib/depends.c:984
 #, c-format
 msgid "%s: %s satisfied by db packages.\n"
 msgstr ""
 
-#: lib/depends.c:1016
+#: lib/depends.c:997
 #, c-format
 msgid "%s: %s satisfied by rpmlib version.\n"
 msgstr ""
 
-#: lib/depends.c:1026
+#: lib/depends.c:1007
 #, c-format
 msgid "%s: %s unsatisfied.\n"
 msgstr ""
 
 #. requirements are not satisfied.
-#: lib/depends.c:1078
+#: lib/depends.c:1061
 #, c-format
 msgid "package %s require not satisfied: %s\n"
 msgstr ""
 
 #. conflicts exist.
-#: lib/depends.c:1140
+#: lib/depends.c:1123
 #, c-format
 msgid "package %s conflicts: %s\n"
 msgstr ""
 
-#: lib/depends.c:1202 lib/depends.c:1523
+#: lib/depends.c:1253
 #, c-format
-msgid "cannot read header at %d for dependency check"
+msgid "loop in prerequisite chain: %s"
 msgstr ""
 
-#: lib/depends.c:1319
+#: lib/depends.c:1457
 #, c-format
-msgid "loop in prerequisite chain: %s"
+msgid "cannot read header at %d for dependency check"
 msgstr ""
 
 #: lib/falloc.c:135
@@ -2865,61 +2865,61 @@ msgid ""
 msgstr ""
 
 #. error
-#: lib/rpmdb.c:403
+#: lib/rpmdb.c:389
 #, c-format
 msgid "cannot retrieve package \"%s\" from db"
 msgstr ""
 
-#: lib/rpmdb.c:622
+#: lib/rpmdb.c:612
 #, c-format
 msgid "package not found with key \"%s\" in %s"
 msgstr ""
 
-#: lib/rpmdb.c:631
+#: lib/rpmdb.c:621
 #, c-format
 msgid "key \"%s\" not found in %s"
 msgstr ""
 
-#: lib/rpmdb.c:649
+#: lib/rpmdb.c:639
 #, c-format
 msgid "rpmdbRemove: cannot read header at 0x%x"
 msgstr ""
 
-#: lib/rpmdb.c:674
+#: lib/rpmdb.c:664
 #, c-format
 msgid "removing 0 %s entries.\n"
 msgstr ""
 
-#: lib/rpmdb.c:680
+#: lib/rpmdb.c:670
 #, c-format
 msgid "removing \"%s\" from %s index.\n"
 msgstr ""
 
-#: lib/rpmdb.c:688
+#: lib/rpmdb.c:678
 #, c-format
 msgid "removing %d entries in %s index:\n"
 msgstr ""
 
-#: lib/rpmdb.c:692 lib/rpmdb.c:889
+#: lib/rpmdb.c:682 lib/rpmdb.c:879
 #, c-format
 msgid "\t%6d %s\n"
 msgstr ""
 
-#: lib/rpmdb.c:827
+#: lib/rpmdb.c:817
 msgid "cannot allocate new instance in database"
 msgstr ""
 
-#: lib/rpmdb.c:866
+#: lib/rpmdb.c:856
 #, c-format
 msgid "adding 0 %s entries.\n"
 msgstr ""
 
-#: lib/rpmdb.c:878
+#: lib/rpmdb.c:868
 #, c-format
 msgid "adding \"%s\" to %s index.\n"
 msgstr ""
 
-#: lib/rpmdb.c:885
+#: lib/rpmdb.c:875
 #, c-format
 msgid "adding %d entries to %s index:\n"
 msgstr ""