RPM Package Manager, CVS Repository
  http://rpm5.org/cvs/
  ____________________________________________________________________________

  Server: rpm5.org                         Name:   Jeff Johnson
  Root:   /v/rpm/cvs                       Email:  j...@rpm5.org
  Module: rpm                              Date:   13-Aug-2010 23:38:39
  Branch: HEAD                             Handle: 2010081321383800

  Modified files:
    rpm                     CHANGES
    rpm/lib                 rpmts.c rpmts.h

  Log:
    - solve: loop over solve db's in a bag.

  Summary:
    Revision    Changes     Path
    1.3414      +1  -0      rpm/CHANGES
    2.185       +128 -52    rpm/lib/rpmts.c
    2.133       +2  -2      rpm/lib/rpmts.h
  ____________________________________________________________________________

  patch -p0 <<'@@ .'
  Index: rpm/CHANGES
  ============================================================================
  $ cvs diff -u -r1.3413 -r1.3414 CHANGES
  --- rpm/CHANGES       13 Aug 2010 21:34:02 -0000      1.3413
  +++ rpm/CHANGES       13 Aug 2010 21:38:38 -0000      1.3414
  @@ -1,4 +1,5 @@
   5.3.2 -> 5.4a1:
  +    - jbj: solve: loop over solve db's in a bag.
       - jbj: solve: stub-in toy add/del methods.
       - jbj: solve: permit multiple solvedb's in a rpmbag.
       - jbj: solve: generalize %_dbpath to permit multiple rpmdb's.
  @@ .
  patch -p0 <<'@@ .'
  Index: rpm/lib/rpmts.c
  ============================================================================
  $ cvs diff -u -r2.184 -r2.185 rpmts.c
  --- rpm/lib/rpmts.c   13 Aug 2010 13:12:15 -0000      2.184
  +++ rpm/lib/rpmts.c   13 Aug 2010 21:38:38 -0000      2.185
  @@ -33,6 +33,7 @@
   #include "rpmte.h"
   
   #define      _RPMTS_INTERNAL
  +#define      _RPMBAG_INTERNAL
   #include "rpmts.h"
   
   #include <rpmcli.h>
  @@ -213,14 +214,30 @@
   
   int rpmtsCloseSDB(rpmts ts)
   {
  +    rpmbag bag = ts->bag;
       int rc = 0;
   
  -    if (ts->sdb != NULL) {
  -     (void) rpmswAdd(rpmtsOp(ts, RPMTS_OP_DBGET), &ts->sdb->db_getops);
  -     (void) rpmswAdd(rpmtsOp(ts, RPMTS_OP_DBPUT), &ts->sdb->db_putops);
  -     (void) rpmswAdd(rpmtsOp(ts, RPMTS_OP_DBDEL), &ts->sdb->db_delops);
  -     rc = rpmdbClose(ts->sdb);
  -     ts->sdb = NULL;
  +    if (bag != NULL) {
  +     rpmsdb * sdbp = bag->sdbp;
  +     int i = bag->nsdbp;
  +     if (sdbp)
  +     while (--i >= 0) {
  +         rpmdb sdb;
  +         if (sdbp[i] == NULL)
  +             continue;
  +         sdb = sdbp[i]->_db;
  +         if (sdb) {
  +             int xx;
  +             (void) rpmswAdd(rpmtsOp(ts, RPMTS_OP_DBGET), &sdb->db_getops);
  +             (void) rpmswAdd(rpmtsOp(ts, RPMTS_OP_DBPUT), &sdb->db_putops);
  +             (void) rpmswAdd(rpmtsOp(ts, RPMTS_OP_DBDEL), &sdb->db_delops);
  +             xx = rpmdbClose(sdb);
  +             if (xx && rc == 0)
  +                 rc = xx;
  +         }
  +         (void) rpmbagDel(bag, i);
  +     }
  +     ts->bag = rpmbagFree(ts->bag);
       }
       return rc;
   }
  @@ -228,9 +245,27 @@
   int rpmtsOpenSDB(rpmts ts, int dbmode)
   {
       static int has_sdbpath = -1;
  +    rpmbag bag = ts->bag;
  +    rpmsdb * sdbp = NULL;
  +    rpmdb sdb = NULL;
  +    int sdbmode = O_RDONLY;
  +    const char * s = NULL;
  +    ARGV_t av = NULL;
  +    int ac = 0;
       int rc = 0;
  +    int xx;
  +    int i;
  +
  +    if (bag == NULL) {
  +     bag = ts->bag = rpmbagNew(NULL, 0);
  +     if (bag == NULL)
  +         goto exit;
  +    }
  +    sdbp = bag->sdbp;
  +    sdb = (sdbp[i] ? sdbp[i]->_db : NULL);
  +    sdbmode = (sdbp[i] ? sdbp[i]->dbmode : O_RDONLY);
   
  -    if (ts->sdb != NULL && ts->sdbmode == dbmode) {
  +    if (sdb != NULL && sdbmode == dbmode) {
        rc = 0;
        goto exit;
       }
  @@ -244,19 +279,42 @@
        goto exit;
       }
   
  -    addMacro(NULL, "_dbpath", NULL, "%{_solve_dbpath}", RMIL_DEFAULT);
  +    s = rpmExpand("%{?_solve_dbpath}", NULL);
  +    xx = argvSplit(&av, s, ":");
  +    ac = argvCount(av);
  +
  +    for (i = 0; i < ac; i++) {
  +     const char * fn;
  +     urltype ut;
   
  -    rc = rpmdbOpen(ts->rootDir, &ts->sdb, ts->sdbmode, (mode_t)0644);
  -    if (rc) {
  -     const char * dn;
  -     dn = rpmGetPath(ts->rootDir, "%{_dbpath}", NULL);
  -     rpmlog(RPMLOG_WARNING,
  -                     _("cannot open Solve database in %s\n"), dn);
  -     dn = _free(dn);
  -     /* XXX only try to open the solvedb once. */
  -     has_sdbpath = 0;
  +     if (av[i] == NULL || *av[i] == '\0')
  +         continue;
  +
  +     fn = NULL;
  +     ut = urlPath(av[i], &fn);
  +
  +     /* XXX Lstat(fn, &sb) to ensure a directory? */
  +     addMacro(NULL, "_dbpath", NULL, fn, RMIL_DEFAULT);
  +     xx = rpmdbOpen(ts->rootDir, &sdb, dbmode, (mode_t)0644);
  +     delMacro(NULL, "_dbpath");
  +
  +     if (xx) {
  +         const char * dn = rpmGetPath(ts->rootDir, fn, NULL);
  +         rpmlog(RPMLOG_WARNING, _("cannot open Solve database in %s\n"), dn);
  +         dn = _free(dn);
  +         if (rc == 0)
  +             rc = xx;
  +
  +         /* XXX only try to open the solvedb once. */
  +         has_sdbpath = 0;
  +         continue;
  +     }
  +
  +     xx = rpmbagAdd(bag, sdb, dbmode);
       }
  -    delMacro(NULL, "_dbpath");
  +
  +    av = argvFree(av);
  +    s = _free(s);
   
   exit:
   if (_rpmts_debug)
  @@ -281,6 +339,8 @@
   int rpmtsSolve(rpmts ts, rpmds ds, /*...@unused@*/ const void * data)
   {
       HE_t he = memset(alloca(sizeof(*he)), 0, sizeof(*he));
  +    rpmbag bag = ts->bag;
  +    rpmsdb * sdbp = NULL;
       const char * errstr;
       const char * str = NULL;
       const char * qfmt;
  @@ -293,6 +353,7 @@
       const char * keyp;
       size_t keylen = 0;
       int rc = 1;              /* assume not found */
  +    int i = 0;
       int xx;
   
   if (_rpmts_debug)
  @@ -317,48 +378,64 @@
       if (keyp == NULL)
        goto exit;
   
  -    if (ts->sdb == NULL) {
  -     xx = rpmtsOpenSDB(ts, ts->sdbmode);
  +    if (bag == NULL) {
  +     xx = rpmtsOpenSDB(ts, O_RDONLY);
        if (xx)
            goto exit;
  +     bag = ts->bag;
  +     if (bag == NULL)
  +         goto exit;
       }
   
  -    /* Look for a matching Provides: in suggested universe. */
  -    rpmtag = (*keyp == '/' ? RPMTAG_BASENAMES : RPMTAG_PROVIDENAME);
  -    mi = rpmmiInit(ts->sdb, rpmtag, keyp, keylen);
  -    while ((h = rpmmiNext(mi)) != NULL) {
  -     size_t hnamelen;
  -     time_t htime;
  +    sdbp = bag->sdbp;
   
  -     if (rpmtag == RPMTAG_PROVIDENAME && !rpmdsAnyMatchesDep(h, ds, 1))
  -         continue;
  -
  -     he->tag = RPMTAG_NAME;
  -     xx = headerGet(h, he, 0);
  -     hnamelen = ((xx && he->p.str) ? strlen(he->p.str) : 0);
  -     he->p.ptr = _free(he->p.ptr);
  +    if (sdbp)
  +    for (i = 0; i < (int)bag->nsdbp; i++) {
  +     rpmdb sdb = NULL;
   
  -     /* XXX Prefer the shortest pkg N for basenames/provides resp. */
  -     if (bhnamelen > 0 && hnamelen > bhnamelen)
  +     if (sdbp[i] == NULL)
            continue;
  -
  -     /* XXX Prefer the newest build if given alternatives. */
  -     he->tag = RPMTAG_BUILDTIME;
  -     xx = headerGet(h, he, 0);
  -     htime = (xx && he->p.ui32p ? he->p.ui32p[0] : 0);
  -     he->p.ptr = _free(he->p.ptr);
  -
  -     if (htime <= bhtime)
  +     sdb = sdbp[i]->_db;
  +     if (sdb == NULL)
            continue;
   
  -     /* Save new "best" candidate. */
  -     (void)headerFree(bh);
  -     bh = NULL;
  -     bh = headerLink(h);
  -     bhtime = htime;
  -     bhnamelen = hnamelen;
  +     /* Look for a matching Provides: in suggested universe. */
  +     rpmtag = (*keyp == '/' ? RPMTAG_BASENAMES : RPMTAG_PROVIDENAME);
  +     mi = rpmmiInit(sdb, rpmtag, keyp, keylen);
  +     while ((h = rpmmiNext(mi)) != NULL) {
  +         size_t hnamelen;
  +         time_t htime;
  +
  +         if (rpmtag == RPMTAG_PROVIDENAME && !rpmdsAnyMatchesDep(h, ds, 1))
  +             continue;
  +
  +         he->tag = RPMTAG_NAME;
  +         xx = headerGet(h, he, 0);
  +         hnamelen = ((xx && he->p.str) ? strlen(he->p.str) : 0);
  +         he->p.ptr = _free(he->p.ptr);
  +
  +         /* XXX Prefer the shortest pkg N for basenames/provides resp. */
  +         if (bhnamelen > 0 && hnamelen > bhnamelen)
  +             continue;
  +
  +         /* XXX Prefer the newest build if given alternatives. */
  +         he->tag = RPMTAG_BUILDTIME;
  +         xx = headerGet(h, he, 0);
  +         htime = (xx && he->p.ui32p ? he->p.ui32p[0] : 0);
  +         he->p.ptr = _free(he->p.ptr);
  +
  +         if (htime <= bhtime)
  +             continue;
  +
  +         /* Save new "best" candidate. */
  +         (void)headerFree(bh);
  +         bh = NULL;
  +         bh = headerLink(h);
  +         bhtime = htime;
  +         bhnamelen = hnamelen;
  +     }
  +     mi = rpmmiFree(mi);
       }
  -    mi = rpmmiFree(mi);
   
       /* Is there a suggested resolution? */
       if (bh == NULL)
  @@ -1384,8 +1461,7 @@
   
       ts->PRCO = NULL;
   
  -    ts->sdb = NULL;
  -    ts->sdbmode = O_RDONLY;
  +    ts->bag = NULL;
   
       ts->rdb = NULL;
       ts->dbmode = O_RDONLY;
  @@ .
  patch -p0 <<'@@ .'
  Index: rpm/lib/rpmts.h
  ============================================================================
  $ cvs diff -u -r2.132 -r2.133 rpmts.h
  --- rpm/lib/rpmts.h   21 May 2010 05:01:02 -0000      2.132
  +++ rpm/lib/rpmts.h   13 Aug 2010 21:38:38 -0000      2.133
  @@ -9,6 +9,7 @@
   #include "rpmps.h"
   #include "rpmsw.h"
   #include <rpmpgp.h>          /* XXX pgpVSFlags */
  +#include <rpmbag.h>
   
   /*...@-exportlocal@*/
   /*...@unchecked@*/
  @@ -211,8 +212,7 @@
       rpmTSType type;          /*!< default, rollback, autorollback */
   
   /*...@refcounted@*/ /*...@null@*/
  -    rpmdb sdb;                       /*!< Solve database handle. */
  -    int sdbmode;             /*!< Solve database open mode. */
  +    rpmbag bag;                      /*!< Solve store collection. */
   /*...@null@*/
       int (*solve) (rpmts ts, rpmds key, const void * data)
        /*...@modifies ts @*/;  /*!< Search for NEVRA key. */
  @@ .
______________________________________________________________________
RPM Package Manager                                    http://rpm5.org
CVS Sources Repository                                rpm-cvs@rpm5.org

Reply via email to