#include <string.h>
#include "pool.h"
+#include "repo.h"
#include "poolid.h"
#include "poolid_private.h"
#include "poolarch.h"
#include "pooltypes.h"
#include "poolid.h"
-#include "repo.h"
#include "solvable.h"
#include "queue.h"
#include "strpool.h"
//-----------------------------------------------
+struct _Repo;
+
struct _Pool {
int verbose; // pool is used everywhere, so put the verbose flag here
Hashtable relhashtbl; // hash table: (name,evr,op ->) Hash -> Id
Hashmask relhashmask;
- Repo **repos;
+ struct _Repo **repos;
int nrepos;
Solvable *solvables;
*/
extern void pool_free(Pool *pool);
+/**
+ * Solvable management
+ */
extern Id pool_add_solvable(Pool *pool);
extern Id pool_add_solvable_block(Pool *pool, int count);
extern void pool_free_solvable_block(Pool *pool, Id start, int count, int reuseids);
+static inline Solvable *pool_id2solvable(Pool *pool, Id p)
+{
+ return pool->solvables + p;
+}
+
/**
* Prepares a pool for solving
#define REPO_H
#include "pooltypes.h"
+#include "pool.h"
typedef struct _Repo {
const char *name;
{
repo->start = p;
repo->end = p + 1;
- return p;
}
- if (p < repo->start)
- repo->start = p;
- if (p + 1 > repo->end)
- repo->end = p + 1;
+ else
+ {
+ if (p < repo->start)
+ repo->start = p;
+ if (p + 1 > repo->end)
+ repo->end = p + 1;
+ }
+ repo->nsolvables++;
+ repo->pool->solvables[p].repo = repo;
return p;
}
{
extern Id pool_add_solvable_block(Pool *pool, int count);
Id p;
+ Solvable *s;
if (!count)
return 0;
p = pool_add_solvable_block(repo->pool, count);
{
repo->start = p;
repo->end = p + count;
- return p;
}
- if (p < repo->start)
- repo->start = p;
- if (p + count > repo->end)
- repo->end = p + count;
+ else
+ {
+ if (p < repo->start)
+ repo->start = p;
+ if (p + count > repo->end)
+ repo->end = p + count;
+ }
+ repo->nsolvables += count;
+ for (s = repo->pool->solvables + p; count--; s++)
+ s->repo = repo;
return p;
}
-/* does not modify repo->nsolvables! */
static inline void repo_free_solvable_block(Repo *repo, Id start, int count, int reuseids)
{
extern void pool_free_solvable_block(Pool *pool, Id start, int count, int reuseids);
+ Solvable *s;
+ int i;
if (start + count == repo->end)
repo->end -= count;
+ repo->nsolvables -= count;
+ for (s = repo->pool->solvables + start, i = count; i--; s++)
+ s->repo = 0;
pool_free_solvable_block(repo->pool, start, count, reuseids);
}
#if 0
printf("read solvables\n");
#endif
- id = repo_add_solvable_block(repo, numsolv);
- s = pool->solvables + id;
+ s = pool_id2solvable(pool, repo_add_solvable_block(repo, numsolv));
for (i = 0; i < numsolv; i++, s++)
{
- s->repo = repo;
databits = 0;
if (numsolvdatabits)
{
}
}
}
- repo->nsolvables += numsolv;
-
xfree(idmap);
xfree(solvdata);
}
#define SOLVABLE_H
#include "pooltypes.h"
-#include "repo.h"
+
+struct _Repo;
typedef struct _Solvable {
Id name;
Id evr; /* epoch:version-release */
Id vendor;
- Repo *repo; /* repo we belong to */
+ struct _Repo *repo; /* repo we belong to */
/* dependencies are offsets into idarray of repo */
Offset provides; /* terminated with Id 0 */
#include <string.h>
#include "pool.h"
+#include "repo.h"
#include "repo_content.h"
#include "repo_write.h"
#include <string.h>
#include "pool.h"
+#include "repo.h"
#include "repo_patchxml.h"
#include "repo_write.h"
#include <assert.h>
#include "pool.h"
+#include "repo.h"
#include "util.h"
#include "repo_content.h"
char *line, *linep;
int aline;
Solvable *s;
- Id id;
struct parsedata pd;
memset(&pd, 0, sizeof(pd));
s->supplements = repo_fix_legacy(repo, s->provides, s->supplements);
/* Only support one product. */
pd.kind = "product";
- id = repo_add_solvable(repo);
- s = pool->solvables + id;
- s->repo = repo;
- repo->nsolvables++;
+ s = pool_id2solvable(pool, repo_add_solvable(repo));
s->name = str2id(pool, join(&pd, pd.kind, ":", value), 1);
}
else if (istag ("VERSION"))
struct stateswitch *sw;
Pool *pool = pd->pool;
Solvable *s = pd->solvable;
- Id id;
if (pd->depth != pd->statedepth)
{
break;
case STATE_PACKAGE: /* solvable name */
- id = repo_add_solvable(pd->repo);
- pd->solvable = pool->solvables + id;
+ pd->solvable = pool_id2solvable(pool, repo_add_solvable(pd->repo));
if (!strcmp(name, "selection"))
pd->kind = "selection";
else if (!strcmp(name, "pattern"))
pd->version = 0;
pd->release = 0;
#if 0
- fprintf(stderr, "package #%d\n", id);
+ fprintf(stderr, "package #%d\n", s - pool->solvables);
#endif
break;
{
case STATE_PACKAGE: /* package complete */
- s->repo = pd->repo;
- pd->repo->nsolvables++;
-
if (!s->arch) /* default to "noarch" */
s->arch = ARCH_NOARCH;
#include <expat.h>
#include "pool.h"
+#include "repo.h"
#include "repo_patchxml.h"
#include "repo_rpmmd.h"
Pool *pool = pd->pool;
Solvable *s = pd->solvable;
struct stateswitch *sw;
- Id id;
if (pd->depth != pd->statedepth)
{
/* HACK: close patch */
if (pd->kind && !strcmp(pd->kind, "patch"))
{
- s->repo = pd->repo;
- pd->repo->nsolvables++;
if (!s->arch)
s->arch = ARCH_NOARCH;
s->provides = repo_addid_dep(pd->repo, s->provides, rel2id(pool, s->name, s->evr, REL_EQ, 1), 0);
}
else
pd->kind = "patch";
- id = repo_add_solvable(pd->repo);
- pd->solvable = pool->solvables + id;
+
+ pd->solvable = pool_id2solvable(pool, repo_add_solvable(pd->repo));
#if 0
- fprintf(stderr, "package #%d\n", id);
+ fprintf(stderr, "package #%d\n", pd->solvable - pool->solvables);
#endif
break;
case STATE_VERSION:
case STATE_PATCH:
if (!strcmp(name, "patch") && strcmp(pd->kind, "patch"))
break; /* already closed */
- s->repo = pd->repo;
- pd->repo->nsolvables++;
if (!s->arch)
s->arch = ARCH_NOARCH;
if (s->arch != ARCH_SRC && s->arch != ARCH_NOSRC)
#include <db43/db.h>
#include "pool.h"
+#include "repo.h"
#include "hash.h"
#include "util.h"
#include "repo_rpmdb.h"
while (dbc->c_get(dbc, &key, &data, DB_NEXT) == 0)
{
if (!s)
- {
- id = repo_add_solvable(repo);
- s = pool->solvables + id;
- }
+ s = pool_id2solvable(pool, repo_add_solvable(repo));
if (i >= asolv)
{
repo->rpmdbid = xrealloc(repo->rpmdbid, (asolv + 256) * sizeof(unsigned int));
repo->rpmdbid[i] = dbid;
if (rpm2solv(pool, repo, s, rpmhead))
{
- s->repo = repo;
- repo->nsolvables++;
i++;
s = 0;
}
}
repo->rpmdbid = xcalloc(nrpmids, sizeof(unsigned int));
- id = repo_add_solvable_block(repo, nrpmids);
- s = pool->solvables + id;
+
+ s = pool_id2solvable(pool, repo_add_solvable_block(repo, nrpmids));
for (i = 0; i < nrpmids; i++, rp++, s++)
{
- s->repo = repo;
- repo->nsolvables++;
dbid = rp->dbid;
repo->rpmdbid[i] = dbid;
if (refhash)
#include <expat.h>
#include "pool.h"
+#include "repo.h"
#include "util.h"
#include "repo_rpmmd.h"
Pool *pool = pd->pool;
Solvable *s = pd->solvable;
struct stateswitch *sw;
- Id id;
if (pd->depth != pd->statedepth)
{
#if 0
fprintf(stderr, "numpacks: %d\n", pd->numpacks);
#endif
- id = repo_add_solvable_block(pd->repo, pd->numpacks);
- pd->solvable = pool->solvables + id;
+ pd->solvable = pool_id2solvable(pool, repo_add_solvable_block(pd->repo, pd->numpacks));
}
}
break;
case STATE_PACKAGE:
if (pd->numpacks > 0)
- pd->numpacks--;
- else
{
- id = repo_add_solvable(pd->repo);
- pd->solvable = pool->solvables + id;
+ pd->numpacks--;
+ pd->solvable++;
}
+ else
+ pd->solvable = pool_id2solvable(pool, repo_add_solvable(pd->repo));
#if 0
fprintf(stderr, "package #%d\n", pd->solvable - pool->solvables);
#endif
switch (pd->state)
{
case STATE_PACKAGE:
- s->repo = pd->repo;
- pd->repo->nsolvables++;
if (!s->arch)
s->arch = ARCH_NOARCH;
if (s->arch != ARCH_SRC && s->arch != ARCH_NOSRC)
s->provides = repo_addid_dep(pd->repo, s->provides, rel2id(pool, s->name, s->evr, REL_EQ, 1), 0);
s->supplements = repo_fix_legacy(pd->repo, s->provides, s->supplements);
- pd->solvable++;
break;
case STATE_NAME:
s->name = str2id(pool, pd->content, 1);
#include <string.h>
#include "pool.h"
+#include "repo.h"
#include "attr_store.h"
#include "repo_susetags.h"
int pack;
char *sp[5];
struct parsedata pd;
- Id id;
if (with_attr)
attr = new_store(pool);
pd.kind = 0;
if (line[3] == 't')
pd.kind = "pattern";
- id = repo_add_solvable(repo);
- s = pool->solvables + id;
- s->repo = repo;
- repo->nsolvables++;
- last_found_pack = pack;
- pack++;
+ s = pool_id2solvable(pool, repo_add_solvable(repo));
+ last_found_pack = (s - pool->solvables) - repo->start;
if (split(line + 5, sp, 5) != 4)
{
fprintf(stderr, "Bad line: %s\n", line);
lines comes in roughly the same order as the first set, so we
have a hint at where to start our search, namely were we found
the last entry. */
- for (n = 0, nn = last_found_pack; n < pack; n++, nn++)
+ for (n = repo->start, nn = n + last_found_pack; n < repo->end; n++, nn++)
{
- if (nn >= pack)
- nn = 0;
- s = pool->solvables + pool->nsolvables + nn;
- if (s->name == name && s->evr == evr && s->arch == arch)
+ if (nn >= repo->end)
+ nn = repo->start;
+ s = pool->solvables + nn;
+ if (s->repo == repo && s->name == name && s->evr == evr && s->arch == arch)
break;
}
if (n == pack)
s = 0;
else
- last_found_pack = nn;
+ last_found_pack = nn - repo->start;
continue;
}
/* If we have no current solvable to add to, ignore all further lines
#include <string.h>
#include "pool.h"
+#include "repo.h"
#include "repo_rpmdb.h"
#include "repo_solv.h"
#include "repo_write.h"
#include <string.h>
#include "pool.h"
+#include "repo.h"
#include "repo_rpmmd.h"
#include "repo_write.h"
#include <string.h>
#include "pool.h"
+#include "repo.h"
#include "repo_susetags.h"
#include "repo_write.h"
#include "attr_store.h"