Remove solvedb API and other related stuff
authorPanu Matilainen <pmatilai@redhat.com>
Fri, 4 Jul 2008 11:22:06 +0000 (14:22 +0300)
committerPanu Matilainen <pmatilai@redhat.com>
Fri, 4 Jul 2008 11:22:06 +0000 (14:22 +0300)
- nobody has used the solvedb for anything in years
- the mechanism + rpmcache are horribly broken on multilib
- solvedb is way too heavyweight to be really usable as a general mechanism
- solver callback hook left in place as that could in theory be usable still
- we need something better to replace this all, getting rid of it now
  so we're not stuck with the API forever

Makefile.am
lib/rpmgi.c
lib/rpminstall.c
lib/rpmts.c
lib/rpmts.h
lib/rpmts_internal.h
macros.in
python/rpmts-py.c
tools/rpmgraph.c

index 36268f2..cbc4083 100644 (file)
@@ -119,10 +119,6 @@ rpmlibexec_PROGRAMS +=     javadeps
 javadeps_SOURCES =     tools/javadeps.c
 javadeps_LDADD =
 
-rpmlibexec_PROGRAMS += rpmcache
-rpmcache_SOURCES =     tools/rpmcache.c
-rpmcache_LDADD =       lib/librpm.la
-
 rpmlibexec_PROGRAMS += rpmdeps
 rpmdeps_SOURCES =      tools/rpmdeps.c
 rpmdeps_LDADD =                build/librpmbuild.la
index 12fea23..882a4ca 100644 (file)
@@ -627,11 +627,6 @@ enditer:
            rpmlog(RPMLOG_INFO, _("Failed dependencies:\n"));
            if (rpmIsVerbose())
                rpmpsPrint(NULL, ps);
-
-
-            if (!(rpmtsFlags(ts) & RPMTRANS_FLAG_NOSUGGEST))
-                rpmtsPrintSuggests(ts);
-
        }
        ps = rpmpsFree(ps);
        rpmtsCleanProblems(ts);
index e63b8d8..fd60637 100644 (file)
@@ -526,10 +526,6 @@ maybe_manifest:
            rpmpsPrint(NULL, ps);
            eiu->numFailed = eiu->numPkgs;
            stopInstall = 1;
-
-           if (!(rpmtsFlags(ts) & RPMTRANS_FLAG_NOSUGGEST))
-               rpmtsPrintSuggests(ts);
-
        }
        ps = rpmpsFree(ps);
     }
index 9f4b4ed..772e758 100644 (file)
@@ -499,216 +499,6 @@ exit:
     return rc;
 }
 
-int rpmtsCloseSDB(rpmts ts)
-{
-    int rc = 0;
-
-    if (ts->sdb != NULL) {
-       (void) rpmswAdd(rpmtsOp(ts, RPMTS_OP_DBGET), 
-                       rpmdbOp(ts->sdb, RPMDB_OP_DBGET));
-       (void) rpmswAdd(rpmtsOp(ts, RPMTS_OP_DBPUT),
-                       rpmdbOp(ts->sdb, RPMDB_OP_DBPUT));
-       (void) rpmswAdd(rpmtsOp(ts, RPMTS_OP_DBDEL),
-                       rpmdbOp(ts->sdb, RPMDB_OP_DBDEL));
-       rc = rpmdbClose(ts->sdb);
-       ts->sdb = NULL;
-    }
-    return rc;
-}
-
-int rpmtsOpenSDB(rpmts ts, int dbmode)
-{
-    static int has_sdbpath = -1;
-    int rc = 0;
-
-    if (ts->sdb != NULL && ts->sdbmode == dbmode)
-       return 0;
-
-    if (has_sdbpath < 0)
-       has_sdbpath = rpmExpandNumeric("%{?_solve_dbpath:1}");
-
-    /* If not configured, don't try to open. */
-    if (has_sdbpath <= 0)
-       return 1;
-
-    addMacro(NULL, "_dbpath", NULL, "%{_solve_dbpath}", RMIL_DEFAULT);
-
-    rc = rpmdbOpen(ts->rootDir, &ts->sdb, ts->sdbmode, 0644);
-    if (rc) {
-       char * dn = rpmGetPath(ts->rootDir, "%{_dbpath}", NULL);
-       rpmlog(RPMLOG_WARNING,
-                       _("cannot open Solve database in %s\n"), dn);
-       dn = _free(dn);
-    }
-    delMacro(NULL, "_dbpath");
-
-    return rc;
-}
-
-/**
- * Compare suggested package resolutions (qsort/bsearch).
- * @param a            1st instance address
- * @param b            2nd instance address
- * @return             result of comparison
- */
-static int sugcmp(const void * a, const void * b)
-{
-    const char * astr = *(const char **)a;
-    const char * bstr = *(const char **)b;
-    return strcmp(astr, bstr);
-}
-
-int rpmtsSolve(rpmts ts, rpmds ds, const void * data)
-{
-    const char * errstr;
-    char * str;
-    char * qfmt;
-    rpmdbMatchIterator mi;
-    Header bh;
-    Header h;
-    size_t bhnamelen;
-    time_t bhtime;
-    rpmTag rpmtag;
-    const char * keyp;
-    size_t keylen;
-    int rc = 1;        /* assume not found */
-    int xx;
-
-    if (rpmdsTagN(ds) != RPMTAG_REQUIRENAME)
-       return rc;
-
-    keyp = rpmdsN(ds);
-    if (keyp == NULL)
-       return rc;
-
-    if (ts->sdb == NULL) {
-       xx = rpmtsOpenSDB(ts, ts->sdbmode);
-       if (xx) return rc;
-    }
-
-    /* Look for a matching Provides: in suggested universe. */
-    rpmtag = (*keyp == '/' ? RPMTAG_BASENAMES : RPMTAG_PROVIDENAME);
-    keylen = 0;
-    mi = rpmdbInitIterator(ts->sdb, rpmtag, keyp, keylen);
-    bhnamelen = 0;
-    bhtime = 0;
-    bh = NULL;
-    while ((h = rpmdbNextIterator(mi)) != NULL) {
-       struct rpmtd_s name, btime;
-       size_t hnamelen;
-       time_t htime;
-
-       if (rpmtag == RPMTAG_PROVIDENAME && !rpmdsAnyMatchesDep(h, ds, 1))
-           continue;
-
-       /* XXX Prefer the shortest name if given alternatives. */
-       hnamelen = 0;
-       if (headerGet(h, RPMTAG_NAME, &name, HEADERGET_MINMEM)) {
-           const char * hname = rpmtdGetString(&name);
-           if (hname)
-               hnamelen = strlen(hname);
-           rpmtdFreeData(&name);
-       }
-       if (bhnamelen > 0 && hnamelen > bhnamelen)
-           continue;
-
-       /* XXX Prefer the newest build if given alternatives. */
-       htime = 0;
-       if (headerGet(h, RPMTAG_BUILDTIME, &btime, HEADERGET_MINMEM)) {
-           rpm_time_t *bt = rpmtdGetUint32(&btime);
-           htime = bt ? (time_t)*bt : 0;
-           rpmtdFreeData(&btime);
-       }
-
-       if (htime <= bhtime)
-           continue;
-
-       bh = headerFree(bh);
-       bh = headerLink(h);
-       bhtime = htime;
-       bhnamelen = hnamelen;
-    }
-    mi = rpmdbFreeIterator(mi);
-
-    /* Is there a suggested resolution? */
-    if (bh == NULL)
-       goto exit;
-
-    /* Format the suggestion. */
-    qfmt = rpmExpand("%{?_solve_name_fmt}", NULL);
-    if (qfmt == NULL || *qfmt == '\0')
-       goto exit;
-    str = headerFormat(bh, qfmt, &errstr);
-    bh = headerFree(bh);
-    qfmt = _free(qfmt);
-    if (str == NULL) {
-       rpmlog(RPMLOG_ERR, _("incorrect format: %s\n"), errstr);
-       goto exit;
-    }
-
-    if (ts->transFlags & RPMTRANS_FLAG_ADDINDEPS) {
-       FD_t fd;
-       rpmRC rpmrc;
-
-       h = headerFree(h);
-       fd = Fopen(str, "r.ufdio");
-       if (fd == NULL || Ferror(fd)) {
-           rpmlog(RPMLOG_ERR, _("open of %s failed: %s\n"), str,
-                       Fstrerror(fd));
-            if (fd != NULL) {
-                xx = Fclose(fd);
-                fd = NULL;
-            }
-           str = _free(str);
-           goto exit;
-       }
-       rpmrc = rpmReadPackageFile(ts, fd, str, &h);
-       xx = Fclose(fd);
-       switch (rpmrc) {
-       default:
-           str = _free(str);
-           break;
-       case RPMRC_NOTTRUSTED:
-       case RPMRC_NOKEY:
-       case RPMRC_OK:
-           if (h != NULL &&
-               !rpmtsAddInstallElement(ts, h, (fnpyKey)str, 1, NULL))
-           {
-               rpmlog(RPMLOG_DEBUG, "Adding: %s\n", str);
-               rc = -1;
-               /* XXX str memory leak */
-               break;
-           }
-           str = _free(str);
-           break;
-       }
-       h = headerFree(h);
-       goto exit;
-    }
-
-    rpmlog(RPMLOG_DEBUG, "Suggesting: %s\n", str);
-    /* If suggestion is already present, don't bother. */
-    if (ts->suggests != NULL && ts->nsuggests > 0) {
-       if (bsearch(&str, ts->suggests, ts->nsuggests,
-                       sizeof(*ts->suggests), sugcmp))
-           goto exit;
-    }
-
-    /* Add a new (unique) suggestion. */
-    ts->suggests = xrealloc(ts->suggests,
-                       sizeof(*ts->suggests) * (ts->nsuggests + 2));
-    ts->suggests[ts->nsuggests] = str;
-    ts->nsuggests++;
-    ts->suggests[ts->nsuggests] = NULL;
-
-    if (ts->nsuggests > 1)
-       qsort(ts->suggests, ts->nsuggests, sizeof(*ts->suggests), sugcmp);
-
-exit:
-/* FIX: ts->suggests[] may be NULL */
-    return rc;
-}
-
 int rpmtsSetSolveCallback(rpmts ts,
                int (*solve) (rpmts ts, rpmds key, const void * data),
                const void * solveData)
@@ -722,23 +512,6 @@ int rpmtsSetSolveCallback(rpmts ts,
     return rc;
 }
 
-void rpmtsPrintSuggests(rpmts ts)
-{
-    if (ts->suggests != NULL && ts->nsuggests > 0) {
-       int i;
-       rpmlog(RPMLOG_NOTICE, _("    Suggested resolutions:\n"));
-       for (i = 0; i < ts->nsuggests; i++) {
-           const char * str = ts->suggests[i];
-
-           if (str == NULL)
-               break;
-
-           rpmlog(RPMLOG_NOTICE, "\t%s\n", str);
-       }
-    }
-}
-
-
 rpmps rpmtsProblems(rpmts ts)
 {
     rpmps ps = NULL;
@@ -759,7 +532,6 @@ void rpmtsCleanProblems(rpmts ts)
 void rpmtsClean(rpmts ts)
 {
     rpmtsi pi; rpmte p;
-    int i;
 
     if (ts == NULL)
        return;
@@ -773,14 +545,6 @@ void rpmtsClean(rpmts ts)
     ts->addedPackages = rpmalFree(ts->addedPackages);
     ts->numAddedPackages = 0;
 
-    for (i = 0; i < ts->nsuggests; i++) {
-       const char * str = ts->suggests[i];
-       ts->suggests[i] = NULL;
-       _constfree(str);
-    }
-    ts->suggests = _free(ts->suggests);
-    ts->nsuggests = 0;
-
     rpmtsCleanProblems(ts);
 }
 
@@ -847,8 +611,6 @@ rpmts rpmtsFree(rpmts ts)
 
     (void) rpmtsCloseDB(ts);
 
-    (void) rpmtsCloseSDB(ts);
-
     ts->removedPackages = _free(ts->removedPackages);
 
     ts->dsi = _free(ts->dsi);
@@ -1360,12 +1122,8 @@ rpmts rpmtsCreate(void)
     ts->filesystems = NULL;
     ts->dsi = NULL;
 
-    ts->solve = rpmtsSolve;
+    ts->solve = NULL;
     ts->solveData = NULL;
-    ts->nsuggests = 0;
-    ts->suggests = NULL;
-    ts->sdb = NULL;
-    ts->sdbmode = O_RDONLY;
 
     ts->rdb = NULL;
     ts->dbmode = O_RDONLY;
index 44fcc95..da97d0f 100644 (file)
@@ -313,30 +313,6 @@ rpmKeyring rpmtsGetKeyring(rpmts ts, int autoload);
 int rpmtsSetKeyring(rpmts ts, rpmKeyring keyring);
 
 /** \ingroup rpmts
- * Close the database used by the transaction to solve dependencies.
- * @param ts           transaction set
- * @return             0 on success
- */
-int rpmtsCloseSDB(rpmts ts);
-
-/** \ingroup rpmts
- * Open the database used by the transaction to solve dependencies.
- * @param ts           transaction set
- * @param dbmode       O_RDONLY or O_RDWR
- * @return             0 on success
- */
-int rpmtsOpenSDB(rpmts ts, int dbmode);
-
-/** \ingroup rpmts
- * Attempt to solve a needed dependency using the solve database.
- * @param ts           transaction set
- * @param ds           dependency set
- * @param data         opaque data associated with callback
- * @return             -1 retry, 0 ignore, 1 not found
- */
-int rpmtsSolve(rpmts ts, rpmds ds, const void * data);
-
-/** \ingroup rpmts
  * Set dependency solver callback.
  * @param ts           transaction set
  * @param (*solve)     dependency solver callback
@@ -348,15 +324,6 @@ int rpmtsSetSolveCallback(rpmts ts,
                const void * solveData);
 
 /** \ingroup rpmts
- * Print possible suggestions for current transaction set, assuming
- * solvedb exists etc.
- * @todo               The whole suggests handling needs rework, this
- *                     is just a temporary measure...
- * @param ts           transaction set
- */
-void rpmtsPrintSuggests(rpmts ts);
-
-/** \ingroup rpmts
  * Return current transaction set problems.
  * @param ts           transaction set
  * @return             current problem set (or NULL)
index 43e6039..249ea63 100644 (file)
@@ -36,13 +36,9 @@ struct diskspaceInfo_s {
 struct rpmts_s {
     rpmtransFlags transFlags;  /*!< Bit(s) to control operation. */
 
-    rpmdb sdb;                 /*!< Solve database handle. */
-    int sdbmode;               /*!< Solve database open mode. */
     int (*solve) (rpmts ts, rpmds key, const void * data);
                                 /*!< Search for NEVRA key. */
     const void * solveData;    /*!< Solve callback data */
-    int nsuggests;             /*!< No. of depCheck suggestions. */
-    const void ** suggests;    /*!< Possible depCheck suggestions. */
 
     rpmCallbackFunction notify;        /*!< Callback function. */
     rpmCallbackData notifyData;        /*!< Callback private data. */
index 3295dea..6ba83fb 100644 (file)
--- a/macros.in
+++ b/macros.in
@@ -688,22 +688,6 @@ print (t)\
 #              2       Elf64 permitted
 %_transaction_color    @RPMCANONCOLOR@
 
-#      The path to the dependency universe database. The default value
-#      is the rpmdb-redhat location. The macro is usually defined in
-#      /etc/rpm/macros.solve, installed with the rpmdb-redhat package.
-#%_solve_dbpath        /usr/lib/rpmdb/%{_arch}-%{_vendor}-%{_os}/redhat
-
-#      The path to the dependency universe packages. This should
-#      be a path to the packages contained in the solve database.
-#%_solve_pkgsdir       /mnt/redhat/test/latest-i386/RedHat/RPMS/
-
-#      The output binary package file name template used when suggesting
-#      binary packages that solve a dependency. The macro is usually defined
-#      in /etc/rpm/macros.solve, installed with the rpmdb-redhat package.
-#
-# XXX  Note: escaped %% for use in headerSprintf()
-#%_solve_name_fmt      %{?_solve_pkgsdir}%%{NAME}-%%{VERSION}-%%{RELEASE}.%%{ARCH}.rpm
-
 #      Verify digest/signature flags for various rpm modes:
 #      0x30300 (_RPMVSF_NODIGESTS)    --nohdrchk      if set, don't check digest(s)
 #      0xc0c00 (_RPMVSF_NOSIGNATURES) --nosignature   if set, don't check signature(s)
@@ -769,23 +753,6 @@ print (t)\
 %_rpmlock_path %{_dbpath}/__db.000
 
 #==============================================================================
-# ---- Cache configuration macros.
-#      Macro(s) used to configure the universe of headers used to
-#      solve dependencies using rpmcache(8).
-#
-#      Note: These values are specific to my machine, and most certainly
-#      are incorrect for any non-redhat.com machine. The macros are
-#      included here only to document the macro names and usage.
-%_bhpath        file://localhost/mnt/dist
-%_bhcoll        @(7.3|7.2|7.1|7.1sbe|7.1k|7.0|7.01j|7.0j|7.0sbe|7.0tc|6.2|6.2ha|6.2ee|6.1|6.0|5.2|5.1|5.0)
-%_bhN           @(SRPMS|i386|alpha|sparc|s390|ia64)
-%_bhVR          RedHat
-%_bhA           RPMS
-
-#      The cache database directory.
-%_cache_dbpath         /var/spool/up2date/cache
-
-#==============================================================================
 # ---- per-platform macros.
 #      Macros that are specific to an individual platform. The values here
 #      will be used if the per-platform macro file does not exist..
index 8846334..cf7e4a3 100644 (file)
@@ -347,9 +347,6 @@ fprintf(stderr, "*** rpmts_Check(%p) ts %p cb %p\n", s, s->ts, cbInfo.cb);
     xx = rpmtsCheck(s->ts);
     ps = rpmtsProblems(s->ts);
 
-    if (cbInfo.cb)
-       xx = rpmtsSetSolveCallback(s->ts, rpmtsSolve, NULL);
-
     PyEval_RestoreThread(cbInfo._save);
 
     if (ps != NULL) {
index 0f9e8b2..7477222 100644 (file)
@@ -194,10 +194,6 @@ maybe_manifest:
            rpmlog(RPMLOG_ERR, _("Failed dependencies:\n"));
            rpmpsPrint(NULL, ps);
            numFailed += numPkgs;
-
-            if (!(rpmtsFlags(ts) & RPMTRANS_FLAG_NOSUGGEST))
-                rpmtsPrintSuggests(ts);
-
        }
        ps = rpmpsFree(ps);
     }