RPM Package Manager, CVS Repository
/cvs/
____________________________________________________________________________
Server: rpm5.org Name: Jeff Johnson
Root: /v/rpm/cvs Email: jbj@rpm5.org
Module: rpm Date: 14-Aug-2010 00:33:12
Branch: rpm-5_2 Handle: 2010081322331101
Modified files: (Branch: rpm-5_2)
rpm CHANGES
rpm/lib rpmts.c rpmts.h
Log:
- solve: loop over solve db's in a bag.
Summary:
Revision Changes Path
1.2970.2.61 +1 -0 rpm/CHANGES
2.168.2.4 +128 -52 rpm/lib/rpmts.c
2.118.2.2 +2 -2 rpm/lib/rpmts.h
____________________________________________________________________________
patch -p0 <<'@@ .'
Index: rpm/CHANGES
============================================================================
$ cvs diff -u -r1.2970.2.60 -r1.2970.2.61 CHANGES
--- rpm/CHANGES 13 Aug 2010 22:24:14 -0000 1.2970.2.60
+++ rpm/CHANGES 13 Aug 2010 22:33:11 -0000 1.2970.2.61
@@ -1,4 +1,5 @@
5.2.1 -> 5.2.2:
+ - 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.168.2.3 -r2.168.2.4 rpmts.c
--- rpm/lib/rpmts.c 13 Aug 2010 15:49:41 -0000 2.168.2.3
+++ rpm/lib/rpmts.c 13 Aug 2010 22:33:12 -0000 2.168.2.4
@@ -30,6 +30,7 @@
#include "rpmte.h"
#define _RPMTS_INTERNAL
+#define _RPMBAG_INTERNAL
#include "rpmts.h"
#include <rpmcli.h>
@@ -241,14 +242,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;
}
@@ -256,9 +273,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;
}
@@ -272,19 +307,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)
@@ -309,6 +367,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;
@@ -321,6 +381,7 @@
const char * keyp;
size_t keylen = 0;
int rc = 1; /* assume not found */
+ int i = 0;
int xx;
if (_rpmts_debug)
@@ -345,48 +406,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;
-
- if (rpmtag == RPMTAG_PROVIDENAME && !rpmdsAnyMatchesDep(h, ds, 1))
- continue;
+ sdbp = bag->sdbp;
- 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)
@@ -1403,8 +1480,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.118.2.1 -r2.118.2.2 rpmts.h
--- rpm/lib/rpmts.h 22 May 2009 15:09:18 -0000 2.118.2.1
+++ rpm/lib/rpmts.h 13 Aug 2010 22:33:12 -0000 2.118.2.2
@@ -10,6 +10,7 @@
#include "rpmsw.h"
#include "rpmsx.h"
#include <rpmpgp.h> /* XXX pgpVSFlags */
+#include <rpmbag.h>
/*@-exportlocal@*/
/*@unchecked@*/
@@ -208,8 +209,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. */
@@ .
Received on Sat Aug 14 00:33:12 2010