/*
+ * Copyright (c) 2007, Novell Inc.
+ *
+ * This program is licensed under the BSD license, read LICENSE.BSD
+ * for further information
+ */
+
+/*
* repo_rpmdb
*
* convert rpm db to repo
*
*/
-Repo *
-pool_addrepo_rpmdb(Pool *pool, Repo *ref)
+void
+repo_add_rpmdb(Repo *repo, Repo *ref)
{
+ Pool *pool = repo->pool;
unsigned char buf[16];
DB *db = 0;
DBC *dbc = 0;
int i;
int rpmheadsize;
RpmHead *rpmhead;
- Repo *repo;
Solvable *s;
Id id, *refhash;
unsigned int refmask, h;
int asolv;
- repo = pool_addrepo_empty(pool);
+ if (repo->start && repo->start + repo->nsolvables != pool->nsolvables)
+ abort();
+ if (!repo->start || repo->start == repo->end)
+ repo->start = pool->nsolvables;
+ repo->end = pool->nsolvables;
+ if (repo->start != repo->end)
+ abort(); /* FIXME: rpmdbid */
if (ref && !(ref->nsolvables && ref->rpmdbid))
ref = 0;
}
dbidp = (unsigned char *)&dbid;
pool->solvables = xrealloc(pool->solvables, (pool->nsolvables + 256) * sizeof(Solvable));
- memset(pool->solvables + repo->start, 0, 256 * sizeof(Solvable));
+ memset(pool->solvables + pool->nsolvables, 0, 256 * sizeof(Solvable));
repo->rpmdbid = xcalloc(256, sizeof(unsigned int));
asolv = 256;
rpmheadsize = 0;
if (i >= asolv)
{
pool->solvables = xrealloc(pool->solvables, (pool->nsolvables + asolv + 256) * sizeof(Solvable));
- memset(pool->solvables + repo->start + asolv, 0, 256 * sizeof(Solvable));
+ memset(pool->solvables + pool->nsolvables + asolv, 0, 256 * sizeof(Solvable));
repo->rpmdbid = xrealloc(repo->rpmdbid, (asolv + 256) * sizeof(unsigned int));
memset(repo->rpmdbid + asolv, 0, 256 * sizeof(unsigned int));
asolv += 256;
}
- pool->solvables[repo->start + i].repo = repo;
+ pool->solvables[pool->nsolvables + i].repo = repo;
if (key.size != 4)
{
fprintf(stderr, "corrupt Packages database (key size)\n");
memcpy(rpmhead->data, (unsigned char *)data.data + 8, rpmhead->cnt * 16 + rpmhead->dcnt);
rpmhead->dp = rpmhead->data + rpmhead->cnt * 16;
repo->rpmdbid[i] = dbid;
- if (rpm2solv(pool, repo, pool->solvables + repo->start + i, rpmhead))
+ if (rpm2solv(pool, repo, pool->solvables + pool->nsolvables + i, rpmhead))
i++;
}
nrpmids = i;
rpmheadsize = 0;
rpmhead = 0;
- pool->solvables = xrealloc(pool->solvables, (pool->nsolvables + nrpmids) * sizeof(Solvable));
- memset(pool->solvables + repo->start, 0, nrpmids * sizeof(Solvable));
+ pool->solvables = xrealloc2(pool->solvables, (pool->nsolvables + nrpmids), sizeof(Solvable));
+ memset(pool->solvables + pool->nsolvables, 0, nrpmids * sizeof(Solvable));
repo->rpmdbid = calloc(nrpmids, sizeof(unsigned int));
refhash = 0;
refhash[h] = i + 1; /* make it non-zero */
}
}
- s = pool->solvables + repo->start;
+ s = pool->solvables + pool->nsolvables;
for (i = 0; i < nrpmids; i++, rp++, s++)
{
s->repo = repo;
if (rpmhead)
free(rpmhead);
pool->nsolvables += nrpmids;
- repo->nsolvables = nrpmids;
+ repo->nsolvables += nrpmids;
+ repo->end += nrpmids;
if (db)
db->close(db, 0);
- return repo;
}