From: Duncan Mac-Vicar P Date: Fri, 26 Oct 2007 20:25:08 +0000 (+0000) Subject: to follow SUSE tools conventions X-Git-Tag: BASE-SuSE-Code-12_1-Branch~308^2~877 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=a00b22fc21692242f0582ae6d9ff4e27d927c09d;p=thirdparty%2Flibsolv.git to follow SUSE tools conventions Source is now Repo --- diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index a582bf83..65749268 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -1,10 +1,10 @@ -SET(libsatsolver_SRCS bitmap.c poolarch.c poolid.c solver.c source_solv.c -evr.c pool.c queue.c source.c util.c) +SET(libsatsolver_SRCS bitmap.c poolarch.c poolid.c solver.c repo_solv.c +evr.c pool.c queue.c repo.c util.c) ADD_LIBRARY(satsolver STATIC ${libsatsolver_SRCS}) -SET(libsatsolver_HEADERS bitmap.h evr.h hash.h poolarch.h pool.h poolid.h pooltypes.h queue.h solvable.h solver.h source.h source_solv.h util.h ) +SET(libsatsolver_HEADERS bitmap.h evr.h hash.h poolarch.h pool.h poolid.h pooltypes.h queue.h solvable.h solver.h repo.h repo_solv.h util.h ) INSTALL( FILES ${libsatsolver_HEADERS} DESTINATION "${CMAKE_INSTALL_PREFIX}/include/satsolver" ) INSTALL(TARGETS satsolver LIBRARY DESTINATION ${LIB_INSTALL_DIR} ARCHIVE DESTINATION ${LIB_INSTALL_DIR}) \ No newline at end of file diff --git a/src/pool.c b/src/pool.c index a4ddbbf0..ac96e43d 100644 --- a/src/pool.c +++ b/src/pool.c @@ -109,20 +109,20 @@ void pool_free(Pool *pool) { int i; - Source *source; + Repo *repo; pool_freewhatprovides(pool); pool_freeidhashes(pool); - for (i = 0; i < pool->nsources; i++) + for (i = 0; i < pool->nrepos; i++) { - source = pool->sources[i]; - xfree(source->idarraydata); - xfree(source->rpmdbid); - xfree(source); + repo = pool->repos[i]; + xfree(repo->idarraydata); + xfree(repo->rpmdbid); + xfree(repo); } xfree(pool->id2arch); xfree(pool->solvables); - xfree(pool->sources); + xfree(pool->repos); xfree(pool->stringspace); xfree(pool->strings); xfree(pool->rels); @@ -275,7 +275,7 @@ pool_prepare(Pool *pool) continue; if (!pool_installable(pool, s)) continue; - pp = s->source->idarraydata + s->provides; + pp = s->repo->idarraydata + s->provides; while ((id = *pp++) != ID_NULL) { if (ISRELDEP(id)) @@ -324,7 +324,7 @@ pool_prepare(Pool *pool) continue; /* for all provides of this solvable */ - pp = s->source->idarraydata + s->provides; + pp = s->repo->idarraydata + s->provides; while ((id = *pp++) != 0) { if (ISRELDEP(id)) @@ -480,7 +480,7 @@ pool_addrelproviders(Pool *pool, Id d) printf("addrelproviders: checking package %s\n", id2str(pool, pool->p[p].name)); #endif /* solvable p provides name in some rels */ - pidp = pool->solvables[p].source->idarraydata + pool->solvables[p].provides; + pidp = pool->solvables[p].repo->idarraydata + pool->solvables[p].provides; while ((pid = *pidp++) != 0) { int pflags; diff --git a/src/pool.h b/src/pool.h index 0f97b7c8..bf68ed04 100644 --- a/src/pool.h +++ b/src/pool.h @@ -12,7 +12,7 @@ extern "C" { #include "pooltypes.h" #include "poolid.h" -#include "source.h" +#include "repo.h" #include "solvable.h" #include "queue.h" @@ -70,8 +70,8 @@ struct _Pool { Hashtable relhashtbl; // hash table: (name,evr,op ->) Hash -> Id Hashmask relhashmask; - Source **sources; - int nsources; + Repo **repos; + int nrepos; Solvable *solvables; int nsolvables; @@ -145,7 +145,7 @@ extern void pool_free(Pool *pool); /** * ???? */ -extern void pool_freesource(Pool *pool, Source *source); +extern void pool_freerepo(Pool *pool, Repo *repo); /** * Prepares a pool for solving */ diff --git a/src/source.c b/src/repo.c similarity index 62% rename from src/source.c rename to src/repo.c index d776f7cc..218e2c06 100644 --- a/src/source.c +++ b/src/repo.c @@ -1,5 +1,5 @@ /* - * source.c + * repo.c * * Manage metadata coming from one repository * @@ -9,7 +9,7 @@ #include #include -#include "source.h" +#include "repo.h" #include "pool.h" #include "poolid_private.h" #include "util.h" @@ -18,48 +18,48 @@ /* - * create empty source + * create empty repo * and add to pool */ -Source * -pool_addsource_empty(Pool *pool) +Repo * +pool_addrepo_empty(Pool *pool) { - Source *source; + Repo *repo; pool_freewhatprovides(pool); - source = (Source *)xcalloc(1, sizeof(*source)); - pool->sources = (Source **)xrealloc(pool->sources, (pool->nsources + 1) * sizeof(Source *)); - pool->sources[pool->nsources++] = source; - source->name = "empty"; - source->pool = pool; - source->start = pool->nsolvables; - source->nsolvables = 0; - return source; + repo = (Repo *)xcalloc(1, sizeof(*repo)); + pool->repos = (Repo **)xrealloc(pool->repos, (pool->nrepos + 1) * sizeof(Repo *)); + pool->repos[pool->nrepos++] = repo; + repo->name = "empty"; + repo->pool = pool; + repo->start = pool->nsolvables; + repo->nsolvables = 0; + return repo; } /* - * add Id to source + * add Id to repo * olddeps = old array to extend * */ unsigned int -source_addid(Source *source, Offset olddeps, Id id) +repo_addid(Repo *repo, Offset olddeps, Id id) { Id *idarray; int idarraysize; int i; - idarray = source->idarraydata; - idarraysize = source->idarraysize; + idarray = repo->idarraydata; + idarraysize = repo->idarraysize; if (!idarray) /* alloc idarray if not done yet */ { idarray = (Id *)xmalloc((1 + IDARRAY_BLOCK) * sizeof(Id)); idarray[0] = 0; idarraysize = 1; - source->lastoff = 0; + repo->lastoff = 0; } if (!olddeps) /* no deps yet */ @@ -68,7 +68,7 @@ source_addid(Source *source, Offset olddeps, Id id) if ((idarraysize & IDARRAY_BLOCK) == 0) idarray = (Id *)xrealloc(idarray, (idarraysize + 1 + IDARRAY_BLOCK) * sizeof(Id)); } - else if (olddeps == source->lastoff) /* extend at end */ + else if (olddeps == repo->lastoff) /* extend at end */ idarraysize--; else /* can't extend, copy old */ { @@ -91,16 +91,16 @@ source_addid(Source *source, Offset olddeps, Id id) idarray[idarraysize++] = 0; /* ensure NULL termination */ - source->idarraydata = idarray; - source->idarraysize = idarraysize; - source->lastoff = olddeps; + repo->idarraydata = idarray; + repo->idarraysize = idarraysize; + repo->lastoff = olddeps; return olddeps; } /* - * add dependency (as Id) to source + * add dependency (as Id) to repo * olddeps = offset into idarraydata * isreq = 0 for normal dep * isreq = 1 for requires @@ -109,24 +109,24 @@ source_addid(Source *source, Offset olddeps, Id id) */ unsigned int -source_addid_dep(Source *source, Offset olddeps, Id id, int isreq) +repo_addid_dep(Repo *repo, Offset olddeps, Id id, int isreq) { Id oid, *oidp, *marker = 0; if (!olddeps) - return source_addid(source, olddeps, id); + return repo_addid(repo, olddeps, id); if (!isreq) { - for (oidp = source->idarraydata + olddeps; (oid = *oidp) != ID_NULL; oidp++) + for (oidp = repo->idarraydata + olddeps; (oid = *oidp) != ID_NULL; oidp++) { if (oid == id) return olddeps; } - return source_addid(source, olddeps, id); + return repo_addid(repo, olddeps, id); } - for (oidp = source->idarraydata + olddeps; (oid = *oidp) != ID_NULL; oidp++) + for (oidp = repo->idarraydata + olddeps; (oid = *oidp) != ID_NULL; oidp++) { if (oid == SOLVABLE_PREREQMARKER) marker = oidp; @@ -148,7 +148,7 @@ source_addid_dep(Source *source, Offset olddeps, Id id, int isreq) if (marker < oidp) memmove(marker, marker + 1, (oidp - marker) * sizeof(Id)); *oidp = SOLVABLE_PREREQMARKER; - return source_addid(source, olddeps, id); + return repo_addid(repo, olddeps, id); } while (oidp[1]) oidp++; @@ -157,7 +157,7 @@ source_addid_dep(Source *source, Offset olddeps, Id id, int isreq) return olddeps; } if (isreq == 2 && !marker) - olddeps = source_addid(source, olddeps, SOLVABLE_PREREQMARKER); + olddeps = repo_addid(repo, olddeps, SOLVABLE_PREREQMARKER); else if (isreq == 1 && marker) { *marker++ = id; @@ -166,7 +166,7 @@ source_addid_dep(Source *source, Offset olddeps, Id id, int isreq) memmove(marker + 1, marker, (oidp - marker) * sizeof(Id)); *marker = SOLVABLE_PREREQMARKER; } - return source_addid(source, olddeps, id); + return repo_addid(repo, olddeps, id); } @@ -176,20 +176,20 @@ source_addid_dep(Source *source, Offset olddeps, Id id, int isreq) */ unsigned int -source_reserve_ids(Source *source, unsigned int olddeps, int num) +repo_reserve_ids(Repo *repo, unsigned int olddeps, int num) { num++; /* room for trailing ID_NULL */ - if (!source->idarraysize) /* ensure buffer space */ + if (!repo->idarraysize) /* ensure buffer space */ { - source->idarraysize = 1; - source->idarraydata = (Id *)xmalloc(((1 + num + IDARRAY_BLOCK) & ~IDARRAY_BLOCK) * sizeof(Id)); - source->idarraydata[0] = 0; - source->lastoff = 1; + repo->idarraysize = 1; + repo->idarraydata = (Id *)xmalloc(((1 + num + IDARRAY_BLOCK) & ~IDARRAY_BLOCK) * sizeof(Id)); + repo->idarraydata[0] = 0; + repo->lastoff = 1; return 1; } - if (olddeps && olddeps != source->lastoff) /* if not appending */ + if (olddeps && olddeps != repo->lastoff) /* if not appending */ { /* can't insert into idarray, this would invalidate all 'larger' offsets * so create new space at end and move existing deps there. @@ -199,92 +199,92 @@ source_reserve_ids(Source *source, unsigned int olddeps, int num) Id *idstart, *idend; int count; - for (idstart = idend = source->idarraydata + olddeps; *idend++; ) /* find end */ + for (idstart = idend = repo->idarraydata + olddeps; *idend++; ) /* find end */ ; count = idend - idstart - 1 + num; /* new size */ /* realloc if crossing block boundary */ - if (((source->idarraysize - 1) | IDARRAY_BLOCK) != ((source->idarraysize + count - 1) | IDARRAY_BLOCK)) - source->idarraydata = (Id *)xrealloc(source->idarraydata, ((source->idarraysize + count + IDARRAY_BLOCK) & ~IDARRAY_BLOCK) * sizeof(Id)); + if (((repo->idarraysize - 1) | IDARRAY_BLOCK) != ((repo->idarraysize + count - 1) | IDARRAY_BLOCK)) + repo->idarraydata = (Id *)xrealloc(repo->idarraydata, ((repo->idarraysize + count + IDARRAY_BLOCK) & ~IDARRAY_BLOCK) * sizeof(Id)); /* move old deps to end */ - olddeps = source->lastoff = source->idarraysize; - memcpy(source->idarraydata + olddeps, idstart, count - num); - source->idarraysize = olddeps + count - num; + olddeps = repo->lastoff = repo->idarraysize; + memcpy(repo->idarraydata + olddeps, idstart, count - num); + repo->idarraysize = olddeps + count - num; return olddeps; } if (olddeps) /* appending */ - source->idarraysize--; + repo->idarraysize--; /* realloc if crossing block boundary */ - if (((source->idarraysize - 1) | IDARRAY_BLOCK) != ((source->idarraysize + num - 1) | IDARRAY_BLOCK)) - source->idarraydata = (Id *)xrealloc(source->idarraydata, ((source->idarraysize + num + IDARRAY_BLOCK) & ~IDARRAY_BLOCK) * sizeof(Id)); + if (((repo->idarraysize - 1) | IDARRAY_BLOCK) != ((repo->idarraysize + num - 1) | IDARRAY_BLOCK)) + repo->idarraydata = (Id *)xrealloc(repo->idarraydata, ((repo->idarraysize + num + IDARRAY_BLOCK) & ~IDARRAY_BLOCK) * sizeof(Id)); /* appending or new */ - source->lastoff = olddeps ? olddeps : source->idarraysize; + repo->lastoff = olddeps ? olddeps : repo->idarraysize; - return source->lastoff; + return repo->lastoff; } /* - * remove source from pool + * remove repo from pool * */ void -pool_freesource(Pool *pool, Source *source) +pool_freerepo(Pool *pool, Repo *repo) { int i, nsolvables; pool_freewhatprovides(pool); - for (i = 0; i < pool->nsources; i++) /* find source in pool */ + for (i = 0; i < pool->nrepos; i++) /* find repo in pool */ { - if (pool->sources[i] == source) + if (pool->repos[i] == repo) break; } - if (i == pool->nsources) /* source not in pool, return */ + if (i == pool->nrepos) /* repo not in pool, return */ return; /* close gap - * all sources point into pool->solvables _relatively_ to source->start - * so closing the gap only needs adaption of source->start for all - * other sources. + * all repos point into pool->solvables _relatively_ to repo->start + * so closing the gap only needs adaption of repo->start for all + * other repos. */ - nsolvables = source->nsolvables; - if (pool->nsolvables > source->start + nsolvables) - memmove(pool->solvables + source->start, pool->solvables + source->start + nsolvables, (pool->nsolvables - source->start - nsolvables) * sizeof(Solvable)); + nsolvables = repo->nsolvables; + if (pool->nsolvables > repo->start + nsolvables) + memmove(pool->solvables + repo->start, pool->solvables + repo->start + nsolvables, (pool->nsolvables - repo->start - nsolvables) * sizeof(Solvable)); pool->nsolvables -= nsolvables; - for (; i < pool->nsources - 1; i++) + for (; i < pool->nrepos - 1; i++) { - pool->sources[i] = pool->sources[i + 1]; /* remove source */ - pool->sources[i]->start -= nsolvables; /* adapt start offset of remaining sources */ + pool->repos[i] = pool->repos[i + 1]; /* remove repo */ + pool->repos[i]->start -= nsolvables; /* adapt start offset of remaining repos */ } - pool->nsources = i; + pool->nrepos = i; - xfree(source->idarraydata); - xfree(source->rpmdbid); - xfree(source); + xfree(repo->idarraydata); + xfree(repo->rpmdbid); + xfree(repo); } unsigned int -source_fix_legacy(Source *source, unsigned int provides, unsigned int supplements) +repo_fix_legacy(Repo *repo, unsigned int provides, unsigned int supplements) { - Pool *pool = source->pool; + Pool *pool = repo->pool; Id id, idp, idl, idns; char buf[1024], *p, *dep; int i; if (provides) { - for (i = provides; source->idarraydata[i]; i++) + for (i = provides; repo->idarraydata[i]; i++) { - id = source->idarraydata[i]; + id = repo->idarraydata[i]; if (ISRELDEP(id)) continue; dep = (char *)id2str(pool, id); @@ -331,7 +331,7 @@ source_fix_legacy(Source *source, unsigned int provides, unsigned int supplement if (idp) id = rel2id(pool, idp, id, REL_AND, 1); if (id) - supplements = source_addid_dep(source, supplements, id, 0); + supplements = repo_addid_dep(repo, supplements, id, 0); } else if ((p = strchr(dep, ':')) != 0 && p != dep && p[1] == '/' && strlen(dep) < sizeof(buf)) { @@ -343,15 +343,15 @@ source_fix_legacy(Source *source, unsigned int provides, unsigned int supplement id = str2id(pool, p, 1); id = rel2id(pool, idns, id, REL_NAMESPACE, 1); id = rel2id(pool, idp, id, REL_AND, 1); - supplements = source_addid_dep(source, supplements, id, 0); + supplements = repo_addid_dep(repo, supplements, id, 0); } } } if (!supplements) return 0; - for (i = supplements; source->idarraydata[i]; i++) + for (i = supplements; repo->idarraydata[i]; i++) { - id = source->idarraydata[i]; + id = repo->idarraydata[i]; if (ISRELDEP(id)) continue; dep = (char *)id2str(pool, id); @@ -379,7 +379,7 @@ source_fix_legacy(Source *source, unsigned int provides, unsigned int supplement id = rel2id(pool, idns, id, REL_NAMESPACE, 1); } if (id) - source->idarraydata[i] = id; + repo->idarraydata[i] = id; } else if (!strncmp(dep, "packageand(", 11) && strlen(dep) < sizeof(buf)) { @@ -411,7 +411,7 @@ source_fix_legacy(Source *source, unsigned int provides, unsigned int supplement id = idp; } if (id) - source->idarraydata[i] = id; + repo->idarraydata[i] = id; } } return supplements; diff --git a/src/repo.h b/src/repo.h new file mode 100644 index 00000000..19c6001a --- /dev/null +++ b/src/repo.h @@ -0,0 +1,38 @@ +/* + * repo.h + * + */ + +#ifndef REPO_H +#define REPO_H + +#include "pooltypes.h" + +typedef struct _Repo { + const char *name; + struct _Pool *pool; /* pool containing repo data */ + int start; /* start of this repo solvables within pool->solvables */ + int nsolvables; /* number of solvables repo is contributing to pool */ + + int priority; /* priority of this repo */ + + Id *idarraydata; /* array of metadata Ids, solvable dependencies are offsets into this array */ + int idarraysize; + Offset lastoff; + + Id *rpmdbid; +} Repo; + +extern unsigned int repo_addid(Repo *repo, unsigned int olddeps, Id id); +extern unsigned int repo_addid_dep(Repo *repo, unsigned int olddeps, Id id, int isreq); +extern unsigned int repo_reserve_ids(Repo *repo, unsigned int olddeps, int num); +extern unsigned int repo_fix_legacy(Repo *repo, unsigned int provides, unsigned int supplements); + +extern Repo *pool_addrepo_empty(Pool *pool); + +static inline const char *repo_name(const Repo *repo) +{ + return repo->name; +} + +#endif /* REPO_H */ diff --git a/src/source_solv.c b/src/repo_solv.c similarity index 88% rename from src/source_solv.c rename to src/repo_solv.c index 3c14d236..c416bf51 100644 --- a/src/source_solv.c +++ b/src/repo_solv.c @@ -1,10 +1,10 @@ /* - * source_solv.c + * repo_solv.c * - * Read the binary dump of a Source and create a Source * from it + * Read the binary dump of a Repo and create a Repo * from it * * See - * Source *pool_addsource_solv(Pool *pool, FILE *fp) + * Repo *pool_addrepo_solv(Pool *pool, FILE *fp) * below * */ @@ -16,7 +16,7 @@ #include #include -#include "source_solv.h" +#include "repo_solv.h" #include "util.h" #define INTERESTED_START 2 @@ -163,21 +163,21 @@ typedef struct solvdata { // ---------------------------------------------- /* - * read source from .solv file + * read repo from .solv file * and add it to pool */ -Source * -pool_addsource_solv(Pool *pool, FILE *fp, const char *sourcename) +Repo * +pool_addrepo_solv(Pool *pool, FILE *fp, const char *reponame) { int i, j, l; unsigned int numid, numrel, numsolv, numsrcdata, numsolvdata; int numsolvdatabits, type; Offset sizeid; Offset *str; /* map Id -> Offset into string space */ - char *strsp; /* source string space */ + char *strsp; /* repo string space */ char *sp; /* pointer into string space */ - Id *idmap; /* map of source Ids to pool Ids */ + Id *idmap; /* map of repo Ids to pool Ids */ Id id; unsigned int hashmask, h; int hh; @@ -187,7 +187,7 @@ pool_addsource_solv(Pool *pool, FILE *fp, const char *sourcename) Reldep *ran; SolvData *solvdata; unsigned int size, size_str, size_idarray; - Source *source; + Repo *repo; Id *idarraydatap, *idarraydataend; Offset ido; unsigned int databits; @@ -204,11 +204,11 @@ pool_addsource_solv(Pool *pool, FILE *fp, const char *sourcename) exit(1); } - /* create empty Source */ - source = pool_addsource_empty(pool); + /* create empty Repo */ + repo = pool_addrepo_empty(pool); pool_freeidhashes(pool); - source->name = sourcename; + repo->name = reponame; numid = read_u32(fp); numrel = read_u32(fp); @@ -240,7 +240,7 @@ pool_addsource_solv(Pool *pool, FILE *fp, const char *sourcename) idmap = (Id *)xcalloc(numid + numrel, sizeof(Id)); /* - * read new source at end of pool + * read new repo at end of pool */ if (fread(strsp, sizeid, 1, fp) != 1) @@ -326,7 +326,7 @@ pool_addsource_solv(Pool *pool, FILE *fp, const char *sourcename) memmove(pool->stringspace + pool->sstrings, sp, l); /* append to pool buffer */ pool->sstrings += l; } - idmap[i] = id; /* source relative -> pool relative */ + idmap[i] = id; /* repo relative -> pool relative */ sp += l; /* next string */ } xfree(hashtbl); @@ -369,12 +369,12 @@ pool_addsource_solv(Pool *pool, FILE *fp, const char *sourcename) } /* - * read RelDeps from source + * read RelDeps from repo */ for (i = 0; i < numrel; i++) { - name = read_id(fp, i + numid); /* read (source relative) Ids */ + name = read_id(fp, i + numid); /* read (repo relative) Ids */ evr = read_id(fp, i + numid); flags = read_u8(fp); name = idmap[name]; /* map to (pool relative) Ids */ @@ -405,11 +405,11 @@ pool_addsource_solv(Pool *pool, FILE *fp, const char *sourcename) } /* - * read (but dont store) source data + * read (but dont store) repo data */ #if 0 - printf("read source data\n"); + printf("read repo data\n"); #endif numsrcdata = read_u32(fp); for (i = 0; i < numsrcdata; i++) @@ -481,16 +481,16 @@ pool_addsource_solv(Pool *pool, FILE *fp, const char *sourcename) if (size_idarray) { size_idarray++; /* first entry is always zero */ - source->idarraydata = (Id *)xmalloc(sizeof(Id) * size_idarray); - source->idarraysize = size_idarray; - idarraydatap = source->idarraydata; + repo->idarraydata = (Id *)xmalloc(sizeof(Id) * size_idarray); + repo->idarraysize = size_idarray; + idarraydatap = repo->idarraydata; *idarraydatap++ = 0; - idarraydataend = source->idarraydata + size_idarray; + idarraydataend = repo->idarraydata + size_idarray; } else { - source->idarraydata = 0; - source->idarraysize = 0; + repo->idarraydata = 0; + repo->idarraysize = 0; idarraydatap = 0; idarraydataend = 0; } @@ -500,8 +500,8 @@ pool_addsource_solv(Pool *pool, FILE *fp, const char *sourcename) if (numsolv) /* clear newly allocated area */ memset(pool->solvables + pool->nsolvables, 0, numsolv * sizeof(Solvable)); - source->start = pool->nsolvables; - source->nsolvables = numsolv; + repo->start = pool->nsolvables; + repo->nsolvables = numsolv; /* * read solvables @@ -510,9 +510,9 @@ pool_addsource_solv(Pool *pool, FILE *fp, const char *sourcename) #if 0 printf("read solvables\n"); #endif - for (i = 0, s = pool->solvables + source->start; i < numsolv; i++, s++) + for (i = 0, s = pool->solvables + repo->start; i < numsolv; i++, s++) { - s->source = source; + s->repo = repo; databits = 0; if (numsolvdatabits) { @@ -554,9 +554,9 @@ pool_addsource_solv(Pool *pool, FILE *fp, const char *sourcename) #endif if (id == RPM_RPMDBID) { - if (!source->rpmdbid) - source->rpmdbid = (Id *)xcalloc(numsolv, sizeof(Id)); - source->rpmdbid[i] = h; + if (!repo->rpmdbid) + repo->rpmdbid = (Id *)xcalloc(numsolv, sizeof(Id)); + repo->rpmdbid[i] = h; } break; case TYPE_STR: @@ -571,7 +571,7 @@ pool_addsource_solv(Pool *pool, FILE *fp, const char *sourcename) ; break; } - ido = idarraydatap - source->idarraydata; + ido = idarraydatap - repo->idarraydata; idarraydatap = read_idarray(fp, numid + numrel, idmap, idarraydatap, idarraydataend); if (id == SOLVABLE_PROVIDES) s->provides = ido; @@ -593,8 +593,8 @@ pool_addsource_solv(Pool *pool, FILE *fp, const char *sourcename) s->freshens = ido; #if 0 printf("%s ->\n", id2str(pool, id)); - for (; source->idarraydata[ido]; ido++) - printf(" %s\n", dep2str(pool, source->idarraydata[ido])); + for (; repo->idarraydata[ido]; ido++) + printf(" %s\n", dep2str(pool, repo->idarraydata[ido])); #endif break; } @@ -606,7 +606,7 @@ pool_addsource_solv(Pool *pool, FILE *fp, const char *sourcename) pool->nsolvables += numsolv; - return source; + return repo; } // EOF diff --git a/src/repo_solv.h b/src/repo_solv.h new file mode 100644 index 00000000..1c547163 --- /dev/null +++ b/src/repo_solv.h @@ -0,0 +1,22 @@ +/* + * repo_solv.h + * + */ + +#ifndef REPO_SOLVE_H +#define REPO_SOLVE_H + +#ifdef __cplusplus +extern "C" { +#endif + +#include "pool.h" +#include "repo.h" + +extern Repo *pool_addrepo_solv(Pool *pool, FILE *fp, const char *name); + +#ifdef __cplusplus +} +#endif + +#endif /* REPO_SOLVE_H */ diff --git a/src/solvable.h b/src/solvable.h index bc8cae6d..0c643ad0 100644 --- a/src/solvable.h +++ b/src/solvable.h @@ -8,16 +8,16 @@ #define SOLVABLE_H #include "pooltypes.h" -#include "source.h" +#include "repo.h" typedef struct _Solvable { Id name; Id arch; Id evr; /* epoch:version-release */ - Source *source; /* source we belong to */ + Repo *repo; /* repo we belong to */ - /* dependencies are offsets into idarray of source */ + /* dependencies are offsets into idarray of repo */ Offset provides; /* terminated with Id 0 */ Offset obsoletes; Offset conflicts; diff --git a/src/solver.c b/src/solver.c index 989d2459..ef007b69 100644 --- a/src/solver.c +++ b/src/solver.c @@ -41,7 +41,7 @@ static Id replaces_system(Solver *solv, Id id) { Pool *pool = solv->pool; - Source *system = solv->system; + Repo *system = solv->system; Id *name = pool->solvables[id].name; FOR_PROVIDES(p, pp, id) @@ -144,13 +144,13 @@ prune_to_highest_prio(Pool *pool, Queue *plist) for (i = 0; i < plist->count; i++) { s = pool->solvables + plist->elements[i]; - if (i == 0 || s->source->priority > bestprio) - bestprio = s->source->priority; + if (i == 0 || s->repo->priority > bestprio) + bestprio = s->repo->priority; } for (i = j = 0; i < plist->count; i++) { s = pool->solvables + plist->elements[i]; - if (s->source->priority == bestprio) + if (s->repo->priority == bestprio) plist->elements[j++] = plist->elements[i]; } plist->count = j; @@ -184,14 +184,14 @@ prune_to_recommended(Solver *solv, Queue *plist) s = pool->solvables + p; if (s->recommends) { - recp = s->source->idarraydata + s->recommends; + recp = s->repo->idarraydata + s->recommends; while ((rec = *recp++) != 0) FOR_PROVIDES(p, pp, rec) MAPSET(&solv->recommendsmap, p); } if (s->suggests) { - sugp = s->source->idarraydata + s->suggests; + sugp = s->repo->idarraydata + s->suggests; while ((sug = *sugp++) != 0) FOR_PROVIDES(p, pp, sug) MAPSET(&solv->suggestsmap, p); @@ -211,7 +211,7 @@ prune_to_recommended(Solver *solv, Queue *plist) continue; if (s->supplements) { - supp = s->source->idarraydata + s->supplements; + supp = s->repo->idarraydata + s->supplements; while ((sup = *supp++) != 0) if (dep_fulfilled(solv, sup)) break; @@ -220,7 +220,7 @@ prune_to_recommended(Solver *solv, Queue *plist) } if (s->freshens) { - supp = s->source->idarraydata + s->freshens; + supp = s->repo->idarraydata + s->freshens; while ((sup = *supp++) != 0) if (dep_fulfilled(solv, sup)) break; @@ -246,7 +246,7 @@ prune_to_recommended(Solver *solv, Queue *plist) s = pool->solvables + p; if (!s->enhances) continue; - enhp = s->source->idarraydata + s->enhances; + enhp = s->repo->idarraydata + s->enhances; while ((enh = *enhp++) != 0) if (dep_fulfilled(solv, enh)) break; @@ -796,7 +796,7 @@ static void addrulesforsolvable(Solver *solv, Solvable *s, Map *m) { Pool *pool = solv->pool; - Source *system = solv->system; + Repo *system = solv->system; Queue q; Id qbuf[64]; int i; @@ -842,7 +842,7 @@ addrulesforsolvable(Solver *solv, Solvable *s, Map *m) if (s->requires) { - reqp = s->source->idarraydata + s->requires; + reqp = s->repo->idarraydata + s->requires; while ((req = *reqp++) != 0) { if (req == SOLVABLE_PREREQMARKER) /* skip the marker */ @@ -876,7 +876,7 @@ addrulesforsolvable(Solver *solv, Solvable *s, Map *m) #endif addrule(solv, -n, 0); /* mark requestor as uninstallable */ if (solv->rc_output) - printf(">!> !unflag %s-%s.%s[%s]\n", id2str(pool, s->name), id2str(pool, s->evr), id2str(pool, s->arch), source_name(s->source)); + printf(">!> !unflag %s-%s.%s[%s]\n", id2str(pool, s->name), id2str(pool, s->evr), id2str(pool, s->arch), repo_name(s->repo)); continue; } @@ -909,7 +909,7 @@ addrulesforsolvable(Solver *solv, Solvable *s, Map *m) if (s->conflicts) { - conp = s->source->idarraydata + s->conflicts; + conp = s->repo->idarraydata + s->conflicts; while ((con = *conp++) != 0) { FOR_PROVIDES(p, pp, con) @@ -930,7 +930,7 @@ addrulesforsolvable(Solver *solv, Solvable *s, Map *m) { /* not installed */ if (s->obsoletes) { - obsp = s->source->idarraydata + s->obsoletes; + obsp = s->repo->idarraydata + s->obsoletes; while ((obs = *obsp++) != 0) { FOR_PROVIDES(p, pp, obs) @@ -949,7 +949,7 @@ addrulesforsolvable(Solver *solv, Solvable *s, Map *m) */ if (s->recommends) { - recp = s->source->idarraydata + s->recommends; + recp = s->repo->idarraydata + s->recommends; while ((rec = *recp++) != 0) { FOR_PROVIDES(p, pp, rec) @@ -959,7 +959,7 @@ addrulesforsolvable(Solver *solv, Solvable *s, Map *m) } if (s->suggests) { - sugp = s->source->idarraydata + s->suggests; + sugp = s->repo->idarraydata + s->suggests; while ((sug = *sugp++) != 0) { FOR_PROVIDES(p, pp, sug) @@ -992,21 +992,21 @@ addrulesforweak(Solver *solv, Map *m) sup = 0; if (s->supplements) { - supp = s->source->idarraydata + s->supplements; + supp = s->repo->idarraydata + s->supplements; while ((sup = *supp++) != ID_NULL) if (dep_possible(solv, sup, m)) break; } if (!sup && s->freshens) { - supp = s->source->idarraydata + s->freshens; + supp = s->repo->idarraydata + s->freshens; while ((sup = *supp++) != ID_NULL) if (dep_possible(solv, sup, m)) break; } if (!sup && s->enhances) { - supp = s->source->idarraydata + s->enhances; + supp = s->repo->idarraydata + s->enhances; while ((sup = *supp++) != ID_NULL) if (dep_possible(solv, sup, m)) break; @@ -1075,7 +1075,7 @@ findupdatepackages(Solver *solv, Solvable *s, Queue *qs, Map *m, int allowdowngr } else if (!solv->noupdateprovide && ps->obsoletes) /* provides/obsoletes combination ? */ { - obsp = ps->source->idarraydata + ps->obsoletes; + obsp = ps->repo->idarraydata + ps->obsoletes; while ((obs = *obsp++) != 0) /* for all obsoletes */ { FOR_PROVIDES(p2, pp2, obs) /* and all matching providers of the obsoletes */ @@ -1798,11 +1798,11 @@ setpropagatelearn(Solver *solv, int level, Id decision, int disablerules) * * * Upon solving, rules are created to flag the Solvables - * of the 'system' Source as installed. + * of the 'system' Repo as installed. */ Solver * -solver_create(Pool *pool, Source *system) +solver_create(Pool *pool, Repo *system) { Solver *solv; solv = (Solver *)xcalloc(1, sizeof(Solver)); @@ -2130,7 +2130,7 @@ run_solver(Solver *solv, int disablerules, int doweak) /* XXX need to special case AND ? */ if (s->recommends) { - recp = s->source->idarraydata + s->recommends; + recp = s->repo->idarraydata + s->recommends; while ((rec = *recp++) != 0) { qcount = dq.count; @@ -2157,7 +2157,7 @@ run_solver(Solver *solv, int disablerules, int doweak) continue; if (s->supplements) { - supp = s->source->idarraydata + s->supplements; + supp = s->repo->idarraydata + s->supplements; while ((sup = *supp++) != 0) if (dep_fulfilled(solv, sup)) break; @@ -2166,7 +2166,7 @@ run_solver(Solver *solv, int disablerules, int doweak) } if (s->freshens) { - supp = s->source->idarraydata + s->freshens; + supp = s->repo->idarraydata + s->freshens; while ((sup = *supp++) != 0) if (dep_fulfilled(solv, sup)) break; @@ -2408,7 +2408,7 @@ printdecisions(Solver *solv) s = pool->solvables + n; if (s->obsoletes) { - obsp = s->source->idarraydata + s->obsoletes; + obsp = s->repo->idarraydata + s->obsoletes; while ((obs = *obsp++) != 0) FOR_PROVIDES(p, pp, obs) { @@ -2526,9 +2526,9 @@ printdecisions(Solver *solv) } if (solv->rc_output) { - Source *source = s->source; - if (source && strcmp(source_name(source), "locales")) - printf("[%s]", source_name(source)); + Repo *repo = s->repo; + if (repo && strcmp(repo_name(repo), "locales")) + printf("[%s]", repo_name(repo)); } printf("\n"); } @@ -2544,7 +2544,7 @@ create_obsolete_index(Solver *solv) { Pool *pool = solv->pool; Solvable *s; - Source *system = solv->system; + Repo *system = solv->system; Id p, *pp, obs, *obsp, *obsoletes, *obsoletes_data; int i, n; @@ -2557,7 +2557,7 @@ create_obsolete_index(Solver *solv) continue; if (!pool_installable(pool, s)) continue; - obsp = s->source->idarraydata + s->obsoletes; + obsp = s->repo->idarraydata + s->obsoletes; while ((obs = *obsp++) != 0) FOR_PROVIDES(p, pp, obs) { @@ -2584,7 +2584,7 @@ create_obsolete_index(Solver *solv) continue; if (!pool_installable(pool, s)) continue; - obsp = s->source->idarraydata + s->obsoletes; + obsp = s->repo->idarraydata + s->obsoletes; while ((obs = *obsp++) != 0) FOR_PROVIDES(p, pp, obs) { @@ -2756,7 +2756,7 @@ solve(Solver *solv, Queue *job) case SOLVER_INSTALL_SOLVABLE: /* install specific solvable */ if (solv->rc_output) { Solvable *s = pool->solvables + what; - printf(">!> Installing %s from channel %s\n", id2str(pool, s->name), source_name(s->source)); + printf(">!> Installing %s from channel %s\n", id2str(pool, s->name), repo_name(s->repo)); } addrule(solv, what, 0); /* install by Id */ queuepush(&solv->ruletojob, i); @@ -2900,7 +2900,7 @@ solve(Solver *solv, Queue *job) s = pool->solvables + p; if (s->suggests) { - sugp = s->source->idarraydata + s->suggests; + sugp = s->repo->idarraydata + s->suggests; while ((sug = *sugp++) != 0) { FOR_PROVIDES(p, pp, sug) @@ -2924,7 +2924,7 @@ solve(Solver *solv, Queue *job) continue; if (!pool_installable(pool, s)) continue; - enhp = s->source->idarraydata + s->enhances; + enhp = s->repo->idarraydata + s->enhances; while ((enh = *enhp++) != 0) if (dep_fulfilled(solv, enh)) break; diff --git a/src/solver.h b/src/solver.h index bd66b192..8eff66e9 100644 --- a/src/solver.h +++ b/src/solver.h @@ -8,7 +8,7 @@ #include "pooltypes.h" #include "pool.h" -#include "source.h" +#include "repo.h" #include "queue.h" #include "bitmap.h" @@ -39,7 +39,7 @@ typedef struct rule { typedef struct solver { Pool *pool; - Source *system; + Repo *system; int fixsystem; /* repair errors in rpm dependency graph */ int allowdowngrade; /* allow to downgrade installed solvable */ @@ -106,7 +106,7 @@ enum solvcmds { SOLVER_INSTALL_SOLVABLE_UPDATE } SolverCmd; -extern Solver *solver_create(Pool *pool, Source *system); +extern Solver *solver_create(Pool *pool, Repo *system); extern void solver_free(Solver *solv); extern void solve(Solver *solv, Queue *job); diff --git a/src/source.h b/src/source.h deleted file mode 100644 index 575b647e..00000000 --- a/src/source.h +++ /dev/null @@ -1,38 +0,0 @@ -/* - * source.h - * - */ - -#ifndef SOURCE_H -#define SOURCE_H - -#include "pooltypes.h" - -typedef struct _Source { - const char *name; - struct _Pool *pool; /* pool containing source data */ - int start; /* start of this source solvables within pool->solvables */ - int nsolvables; /* number of solvables source is contributing to pool */ - - int priority; /* priority of this source */ - - Id *idarraydata; /* array of metadata Ids, solvable dependencies are offsets into this array */ - int idarraysize; - Offset lastoff; - - Id *rpmdbid; -} Source; - -extern unsigned int source_addid(Source *source, unsigned int olddeps, Id id); -extern unsigned int source_addid_dep(Source *source, unsigned int olddeps, Id id, int isreq); -extern unsigned int source_reserve_ids(Source *source, unsigned int olddeps, int num); -extern unsigned int source_fix_legacy(Source *source, unsigned int provides, unsigned int supplements); - -extern Source *pool_addsource_empty(Pool *pool); - -static inline const char *source_name(const Source *source) -{ - return source->name; -} - -#endif /* SOURCE_H */ diff --git a/src/source_solv.h b/src/source_solv.h deleted file mode 100644 index c7f61b0c..00000000 --- a/src/source_solv.h +++ /dev/null @@ -1,22 +0,0 @@ -/* - * source_solv.h - * - */ - -#ifndef SOURCE_SOLVE_H -#define SOURCE_SOLVE_H - -#ifdef __cplusplus -extern "C" { -#endif - -#include "pool.h" -#include "source.h" - -extern Source *pool_addsource_solv(Pool *pool, FILE *fp, const char *name); - -#ifdef __cplusplus -} -#endif - -#endif /* SOURCE_SOLVE_H */ diff --git a/tools/CMakeLists.txt b/tools/CMakeLists.txt index 389c09f3..a09387f0 100644 --- a/tools/CMakeLists.txt +++ b/tools/CMakeLists.txt @@ -1,44 +1,44 @@ -SET(rpmdb2solv_SOURCES +SET(rpmdb2solv_REPOS rpmdb2solv.c - source_rpmdb.h - source_rpmdb.c - source_write.c + repo_rpmdb.h + repo_rpmdb.c + repo_write.c ) -ADD_EXECUTABLE( rpmdb2solv ${rpmdb2solv_SOURCES} ) +ADD_EXECUTABLE( rpmdb2solv ${rpmdb2solv_REPOS} ) TARGET_LINK_LIBRARIES( rpmdb2solv satsolver ${DB43_LIBRARY}) -SET(rpmmd2solv_SOURCES rpmmd2solv.c source_rpmmd.h source_rpmmd.c source_write.c ) -ADD_EXECUTABLE( rpmmd2solv ${rpmmd2solv_SOURCES} ) +SET(rpmmd2solv_REPOS rpmmd2solv.c repo_rpmmd.h repo_rpmmd.c repo_write.c ) +ADD_EXECUTABLE( rpmmd2solv ${rpmmd2solv_REPOS} ) TARGET_LINK_LIBRARIES( rpmmd2solv satsolver ${EXPAT_LIBRARY}) -SET(helix2solv_SOURCES helix2solv.c source_helix.h source_helix.c source_write.c ) -ADD_EXECUTABLE( helix2solv ${helix2solv_SOURCES} ) +SET(helix2solv_REPOS helix2solv.c repo_helix.h repo_helix.c repo_write.c ) +ADD_EXECUTABLE( helix2solv ${helix2solv_REPOS} ) TARGET_LINK_LIBRARIES( helix2solv satsolver ${EXPAT_LIBRARY}) -SET(susetags2solv_SOURCES susetags2solv.c source_susetags.h source_susetags.c source_write.c) -ADD_EXECUTABLE( susetags2solv ${susetags2solv_SOURCES} ) +SET(susetags2solv_REPOS susetags2solv.c repo_susetags.h repo_susetags.c repo_write.c) +ADD_EXECUTABLE( susetags2solv ${susetags2solv_REPOS} ) TARGET_LINK_LIBRARIES( susetags2solv satsolver) -SET(patchxml2solv_SOURCES patchxml2solv.c source_patchxml.h source_patchxml.c source_write.c) -ADD_EXECUTABLE( patchxml2solv ${patchxml2solv_SOURCES} ) +SET(patchxml2solv_REPOS patchxml2solv.c repo_patchxml.h repo_patchxml.c repo_write.c) +ADD_EXECUTABLE( patchxml2solv ${patchxml2solv_REPOS} ) TARGET_LINK_LIBRARIES( patchxml2solv satsolver ${EXPAT_LIBRARY}) -SET(content2solv_SOURCES +SET(content2solv_REPOS content2solv.c - source_content.h - source_content.c - source_write.c) -ADD_EXECUTABLE( content2solv ${content2solv_SOURCES} ) + repo_content.h + repo_content.c + repo_write.c) +ADD_EXECUTABLE( content2solv ${content2solv_REPOS} ) TARGET_LINK_LIBRARIES( content2solv satsolver) -SET(dumpsolv_SOURCES dumpsolv.c) -ADD_EXECUTABLE( dumpsolv ${dumpsolv_SOURCES} ) +SET(dumpsolv_REPOS dumpsolv.c) +ADD_EXECUTABLE( dumpsolv ${dumpsolv_REPOS} ) TARGET_LINK_LIBRARIES( dumpsolv satsolver) -SET(mergesolv_SOURCES mergesolv.c source_write.c) -ADD_EXECUTABLE( mergesolv ${mergesolv_SOURCES} ) +SET(mergesolv_REPOS mergesolv.c repo_write.c) +ADD_EXECUTABLE( mergesolv ${mergesolv_REPOS} ) TARGET_LINK_LIBRARIES( mergesolv satsolver) \ No newline at end of file diff --git a/tools/content2solv.c b/tools/content2solv.c index 26d71405..fa2e8ec3 100644 --- a/tools/content2solv.c +++ b/tools/content2solv.c @@ -6,15 +6,15 @@ #include #include "pool.h" -#include "source_content.h" -#include "source_write.h" +#include "repo_content.h" +#include "repo_write.h" int main(int argc, char **argv) { Pool *pool = pool_create(); - Source *source = pool_addsource_content(pool, stdin); - pool_writesource(pool, source, stdout); + Repo *repo = pool_addrepo_content(pool, stdin); + pool_writerepo(pool, repo, stdout); pool_free(pool); return 0; } diff --git a/tools/dumpsolv.c b/tools/dumpsolv.c index 8b4d37d2..f196a133 100644 --- a/tools/dumpsolv.c +++ b/tools/dumpsolv.c @@ -4,24 +4,24 @@ #include #include "pool.h" -#include "source_solv.h" +#include "repo_solv.h" static void -printids(Source *source, char *kind, Offset ido) +printids(Repo *repo, char *kind, Offset ido) { - Pool *pool = source->pool; + Pool *pool = repo->pool; Id id, *ids; if (!ido) return; printf("%s:\n", kind); - ids = source->idarraydata + ido; + ids = repo->idarraydata + ido; while((id = *ids++) != 0) printf(" %s\n", dep2str(pool, id)); } int main(int argc, char **argv) { - Source *source; + Repo *repo; Pool *pool; int i; Solvable *s; @@ -35,23 +35,23 @@ int main(int argc, char **argv) } } pool = pool_create(); - source = pool_addsource_solv(pool, stdin, ""); - printf("source contains %d solvables\n", source->nsolvables); - for (i = source->start; i < source->start + source->nsolvables; i++) + repo = pool_addrepo_solv(pool, stdin, ""); + printf("repo contains %d solvables\n", repo->nsolvables); + for (i = repo->start; i < repo->start + repo->nsolvables; i++) { s = pool->solvables + i; printf("\n"); printf("solvable %d:\n", i); printf("name: %s %s %s\n", id2str(pool, s->name), id2str(pool, s->evr), id2str(pool, s->arch)); - printids(source, "provides", s->provides); - printids(source, "obsoletes", s->obsoletes); - printids(source, "conflicts", s->conflicts); - printids(source, "requires", s->requires); - printids(source, "recommends", s->recommends); - printids(source, "suggests", s->suggests); - printids(source, "supplements", s->supplements); - printids(source, "enhances", s->enhances); - printids(source, "freshens", s->freshens); + printids(repo, "provides", s->provides); + printids(repo, "obsoletes", s->obsoletes); + printids(repo, "conflicts", s->conflicts); + printids(repo, "requires", s->requires); + printids(repo, "recommends", s->recommends); + printids(repo, "suggests", s->suggests); + printids(repo, "supplements", s->supplements); + printids(repo, "enhances", s->enhances); + printids(repo, "freshens", s->freshens); } exit(0); } diff --git a/tools/helix2solv.c b/tools/helix2solv.c index 5abd8b4d..f33ffcdd 100644 --- a/tools/helix2solv.c +++ b/tools/helix2solv.c @@ -15,15 +15,15 @@ #include #include "pool.h" -#include "source_helix.h" -#include "source_write.h" +#include "repo_helix.h" +#include "repo_write.h" int main(int argc, char **argv) { Pool *pool = pool_create(); - Source *source = pool_addsource_helix(pool, stdin); - pool_writesource(pool, source, stdout); + Repo *repo = pool_addrepo_helix(pool, stdin); + pool_writerepo(pool, repo, stdout); pool_free(pool); exit(0); } diff --git a/tools/mergesolv.c b/tools/mergesolv.c index 932771e2..11272172 100644 --- a/tools/mergesolv.c +++ b/tools/mergesolv.c @@ -12,8 +12,8 @@ #include #include "pool.h" -#include "source_solv.h" -#include "source_write.h" +#include "repo_solv.h" +#include "repo_write.h" int main(int argc, char **argv) @@ -32,24 +32,24 @@ main(int argc, char **argv) perror(argv[1]); exit(0); } - pool_addsource_solv(pool, fp, ""); + pool_addrepo_solv(pool, fp, ""); fclose(fp); } - if (!pool->nsources) + if (!pool->nrepos) return 0; new_id_size = 0; - for (i = 0; i < pool->nsources; i++) - new_id_size += pool->sources[i]->idarraysize; + for (i = 0; i < pool->nrepos; i++) + new_id_size += pool->repos[i]->idarraysize; new_id = (Id*) malloc (sizeof (Id) * new_id_size); new_id_size = 0; - for (i = 0; i < pool->nsources; i++) + for (i = 0; i < pool->nrepos; i++) { - Source *source = pool->sources[i]; + Repo *repo = pool->repos[i]; int si; - memcpy (new_id + new_id_size, source->idarraydata, - source->idarraysize * sizeof (new_id[0])); - for (si = source->start; si < source->start + source->nsolvables; si++) + memcpy (new_id + new_id_size, repo->idarraydata, + repo->idarraysize * sizeof (new_id[0])); + for (si = repo->start; si < repo->start + repo->nsolvables; si++) { Solvable *s = pool->solvables + si; if (s->provides) @@ -71,25 +71,25 @@ main(int argc, char **argv) if (s->freshens) s->freshens += new_id_size; } - new_id_size += source->idarraysize; + new_id_size += repo->idarraysize; if (i > 0) { - pool->sources[0]->nsolvables += source->nsolvables; - source->nsolvables = 0; - source->start = pool->nsolvables; - free (source->idarraydata); - source->idarraydata = 0; + pool->repos[0]->nsolvables += repo->nsolvables; + repo->nsolvables = 0; + repo->start = pool->nsolvables; + free (repo->idarraydata); + repo->idarraydata = 0; } } - while (pool->nsources > 1) + while (pool->nrepos > 1) { - pool_freesource (pool, pool->sources[1]); + pool_freerepo (pool, pool->repos[1]); } - free (pool->sources[0]->idarraydata); - pool->sources[0]->idarraydata = new_id; - pool->sources[0]->idarraysize = new_id_size; + free (pool->repos[0]->idarraydata); + pool->repos[0]->idarraydata = new_id; + pool->repos[0]->idarraysize = new_id_size; - pool_writesource(pool, pool->sources[0], stdout); + pool_writerepo(pool, pool->repos[0], stdout); pool_free(pool); return 0; diff --git a/tools/patchxml2solv.c b/tools/patchxml2solv.c index 5fb549c8..a4ab5277 100644 --- a/tools/patchxml2solv.c +++ b/tools/patchxml2solv.c @@ -6,15 +6,15 @@ #include #include "pool.h" -#include "source_patchxml.h" -#include "source_write.h" +#include "repo_patchxml.h" +#include "repo_write.h" int main(int argc, char **argv) { Pool *pool = pool_create(); - Source *source = pool_addsource_patchxml(pool, stdin); - pool_writesource(pool, source, stdout); + Repo *repo = pool_addrepo_patchxml(pool, stdin); + pool_writerepo(pool, repo, stdout); pool_free(pool); exit(0); } diff --git a/tools/source_content.c b/tools/repo_content.c similarity index 87% rename from tools/source_content.c rename to tools/repo_content.c index 4007976f..2e215c90 100644 --- a/tools/source_content.c +++ b/tools/repo_content.c @@ -8,7 +8,7 @@ #include "pool.h" #include "util.h" -#include "source_content.h" +#include "repo_content.h" #define PACK_BLOCK 16 @@ -36,7 +36,7 @@ split(char *l, char **sp, int m) struct parsedata { char *kind; - Source *source; + Repo *repo; char *tmp; int tmpl; }; @@ -146,29 +146,29 @@ adddep(Pool *pool, struct parsedata *pd, unsigned int olddeps, char *line, int i if (words == 3) line = sp[2], words = 2; } - olddeps = source_addid_dep(pd->source, olddeps, id, isreq); + olddeps = repo_addid_dep(pd->repo, olddeps, id, isreq); if (!line) break; } return olddeps; } -Source * -pool_addsource_content(Pool *pool, FILE *fp) +Repo * +pool_addrepo_content(Pool *pool, FILE *fp) { char *line, *linep; int aline; - Source *source; + Repo *repo; Solvable *s; int pack; struct parsedata pd; - source = pool_addsource_empty(pool); + repo = pool_addrepo_empty(pool); memset(&pd, 0, sizeof(pd)); line = xmalloc(1024); aline = 1024; - pd.source = source; + pd.repo = repo; linep = line; pack = 0; s = 0; @@ -208,18 +208,18 @@ pool_addsource_content(Pool *pool, FILE *fp) if (istag ("PRODUCT")) { if (s && s->arch != ARCH_SRC && s->arch != ARCH_NOSRC) - s->provides = source_addid_dep(source, s->provides, rel2id(pool, s->name, s->evr, REL_EQ, 1), 0); + s->provides = repo_addid_dep(repo, s->provides, rel2id(pool, s->name, s->evr, REL_EQ, 1), 0); if (s) - s->supplements = source_fix_legacy(source, s->provides, s->supplements); + s->supplements = repo_fix_legacy(repo, s->provides, s->supplements); /* Only support one product. */ pd.kind = "product"; if ((pack & PACK_BLOCK) == 0) { pool->solvables = realloc(pool->solvables, (pool->nsolvables + pack + PACK_BLOCK + 1) * sizeof(Solvable)); - memset(pool->solvables + source->start + pack, 0, (PACK_BLOCK + 1) * sizeof(Solvable)); + memset(pool->solvables + repo->start + pack, 0, (PACK_BLOCK + 1) * sizeof(Solvable)); } - s = pool->solvables + source->start + pack; - s->source = source; + s = pool->solvables + repo->start + pack; + s->repo = repo; pack++; } else if (istag ("VERSION")) @@ -260,15 +260,15 @@ pool_addsource_content(Pool *pool, FILE *fp) } if (s && s->arch != ARCH_SRC && s->arch != ARCH_NOSRC) - s->provides = source_addid_dep(source, s->provides, rel2id(pool, s->name, s->evr, REL_EQ, 1), 0); + s->provides = repo_addid_dep(repo, s->provides, rel2id(pool, s->name, s->evr, REL_EQ, 1), 0); if (s) - s->supplements = source_fix_legacy(source, s->provides, s->supplements); + s->supplements = repo_fix_legacy(repo, s->provides, s->supplements); pool->nsolvables += pack; - source->nsolvables = pack; + repo->nsolvables = pack; if (pd.tmp) free(pd.tmp); free(line); - return source; + return repo; } diff --git a/tools/repo_content.h b/tools/repo_content.h new file mode 100644 index 00000000..2ccf2007 --- /dev/null +++ b/tools/repo_content.h @@ -0,0 +1 @@ +Repo * pool_addrepo_content(Pool *pool, FILE *fp); diff --git a/tools/source_helix.c b/tools/repo_helix.c similarity index 94% rename from tools/source_helix.c rename to tools/repo_helix.c index e514bf9c..238f9993 100644 --- a/tools/source_helix.c +++ b/tools/repo_helix.c @@ -1,9 +1,9 @@ /* -*- mode: C; c-file-style: "gnu"; fill-column: 78 -*- */ /* - * source_helix.c + * repo_helix.c * * Parse 'helix' XML representation - * and create 'source' + * and create 'repo' * */ @@ -15,7 +15,7 @@ #include #include -#include "source_helix.h" +#include "repo_helix.h" #include "evr.h" @@ -133,11 +133,11 @@ typedef struct _parsedata { int acontent; // actual buffer size int docontent; // handle content - // source data + // repo data int pack; // number of solvables Pool *pool; // current pool - Source *source; // current source + Repo *repo; // current repo Solvable *start; // collected solvables // package data @@ -352,8 +352,8 @@ adddep(Pool *pool, Parsedata *pd, unsigned int olddeps, const char **atts, int i else id = name; /* no operator */ - /* add new dependency to source */ - return source_addid_dep(pd->source, olddeps, id, isreq); + /* add new dependency to repo */ + return repo_addid_dep(pd->repo, olddeps, id, isreq); } @@ -435,7 +435,7 @@ startElement(void *userData, const char *name, const char **atts) if ((pd->pack & PACK_BLOCK) == 0) /* alloc new block ? */ { pool->solvables = (Solvable *)realloc(pool->solvables, (pool->nsolvables + pd->pack + PACK_BLOCK + 1) * sizeof(Solvable)); - pd->start = pool->solvables + pd->source->start; + pd->start = pool->solvables + pd->repo->start; memset(pd->start + pd->pack, 0, (PACK_BLOCK + 1) * sizeof(Solvable)); } @@ -534,7 +534,7 @@ static const char* findKernelFlavor(Parsedata *pd, Solvable *s) if (s->provides) { - for (pidp = pd->source->idarraydata + s->provides; pidp && (pid = *pidp++) != 0; ) + for (pidp = pd->repo->idarraydata + s->provides; pidp && (pid = *pidp++) != 0; ) { Reldep *prd; const char *depname; @@ -551,12 +551,12 @@ static const char* findKernelFlavor(Parsedata *pd, Solvable *s) } //fprintf(stderr, "pack %d\n", pd->pack); - //fprintf(stderr, "source %d\n", s->requires); + //fprintf(stderr, "repo %d\n", s->requires); if (!s->requires) return 0; - for (pidp = pd->source->idarraydata + s->requires ; pidp && (pid = *pidp++) != 0; ) + for (pidp = pd->repo->idarraydata + s->requires ; pidp && (pid = *pidp++) != 0; ) { const char *depname = 0; @@ -611,7 +611,7 @@ endElement(void *userData, const char *name) { case STATE_PACKAGE: /* package complete */ - s->source = pd->source; + s->repo = pd->repo; if (!s->arch) /* default to "noarch" */ s->arch = ARCH_NOARCH; @@ -623,8 +623,8 @@ endElement(void *userData, const char *name) pd->release ? pd->evrspace + pd->release : 0); /* ensure self-provides */ if (s->arch != ARCH_SRC && s->arch != ARCH_NOSRC) - s->provides = source_addid_dep(pd->source, s->provides, rel2id(pool, s->name, s->evr, REL_EQ, 1), 0); - s->supplements = source_fix_legacy(pd->source, s->provides, s->supplements); + 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); const char *flavor = findKernelFlavor(pd, s); if (flavor) @@ -638,7 +638,7 @@ endElement(void *userData, const char *name) if (s->provides) { npr = 0; - for (pidp = pd->source->idarraydata + s->provides; (pid = *pidp++) != 0; ) + for (pidp = pd->repo->idarraydata + s->provides; (pid = *pidp++) != 0; ) { const char *depname = 0; Reldep *prd = 0; @@ -666,7 +666,7 @@ endElement(void *userData, const char *name) pid = rel2id(pool, pid, prd->evr, prd->flags, 1); } - npr = source_addid_dep(pd->source, npr, pid, 0); + npr = repo_addid_dep(pd->repo, npr, pid, 0); } s->provides = npr; } @@ -675,7 +675,7 @@ endElement(void *userData, const char *name) if (s->requires) { npr = 0; - for (pidp = pd->source->idarraydata + s->requires; (pid = *pidp++) != 0; ) + for (pidp = pd->repo->idarraydata + s->requires; (pid = *pidp++) != 0; ) { const char *depname = 0; Reldep *prd = 0; @@ -701,7 +701,7 @@ endElement(void *userData, const char *name) if (prd) pid = rel2id(pool, pid, prd->evr, prd->flags, 1); } - npr = source_addid_dep(pd->source, npr, pid, 0); + npr = repo_addid_dep(pd->repo, npr, pid, 0); } s->requires = npr; } @@ -800,21 +800,21 @@ characterData(void *userData, const XML_Char *s, int len) /* * read 'helix' type xml from fp - * add packages to pool/source + * add packages to pool/repo * */ -Source * -pool_addsource_helix(Pool *pool, FILE *fp) +Repo * +pool_addrepo_helix(Pool *pool, FILE *fp) { Parsedata pd; char buf[BUFF_SIZE]; int i, l; - Source *source; + Repo *repo; struct stateswitch *sw; - // create empty source - source = pool_addsource_empty(pool); + // create empty repo + repo = pool_addrepo_empty(pool); // prepare parsedata memset(&pd, 0, sizeof(pd)); @@ -826,7 +826,7 @@ pool_addsource_helix(Pool *pool, FILE *fp) } pd.pool = pool; - pd.source = source; + pd.repo = repo; pd.content = (char *)malloc(256); /* must hold all solvable kinds! */ pd.acontent = 256; @@ -859,10 +859,10 @@ pool_addsource_helix(Pool *pool, FILE *fp) // adapt package count pool->nsolvables += pd.pack; - source->nsolvables = pd.pack; + repo->nsolvables = pd.pack; free(pd.content); free(pd.evrspace); - return source; + return repo; } diff --git a/tools/repo_helix.h b/tools/repo_helix.h new file mode 100644 index 00000000..b03a1579 --- /dev/null +++ b/tools/repo_helix.h @@ -0,0 +1,15 @@ +/* + * repo_helix.h + * + */ + +#ifndef REPO_HELIX_H +#define REPO_HELIX_H + +#include +#include "pool.h" +#include "repo.h" + +extern Repo *pool_addrepo_helix(Pool *pool, FILE *fp); + +#endif /* REPO_HELIX_H */ diff --git a/tools/source_patchxml.c b/tools/repo_patchxml.c similarity index 93% rename from tools/source_patchxml.c rename to tools/repo_patchxml.c index a4090fad..d9c98207 100644 --- a/tools/source_patchxml.c +++ b/tools/repo_patchxml.c @@ -7,8 +7,8 @@ #include #include "pool.h" -#include "source_patchxml.h" -#include "source_rpmmd.h" +#include "repo_patchxml.h" +#include "repo_rpmmd.h" enum state { @@ -94,7 +94,7 @@ struct parsedata { int docontent; int pack; Pool *pool; - Source *source; + Repo *repo; Solvable *start; char *kind; @@ -227,7 +227,7 @@ adddep(Pool *pool, struct parsedata *pd, unsigned int olddeps, const char **atts #if 0 fprintf(stderr, "new dep %s%s%s\n", id2str(pool, d), id2rel(pool, d), id2evr(pool, d)); #endif - return source_addid_dep(pd->source, olddeps, id, isreq); + return repo_addid_dep(pd->repo, olddeps, id, isreq); } @@ -282,10 +282,10 @@ startElement(void *userData, const char *name, const char **atts) /* HACK: close patch */ if (pd->kind && !strcmp(pd->kind, "patch")) { - s->source = pd->source; + s->repo = pd->repo; if (!s->arch) s->arch = ARCH_NOARCH; - s->provides = source_addid_dep(pd->source, s->provides, rel2id(pool, s->name, s->evr, REL_EQ, 1), 0); + s->provides = repo_addid_dep(pd->repo, s->provides, rel2id(pool, s->name, s->evr, REL_EQ, 1), 0); pd->pack++; } pd->kind = "atom"; @@ -296,7 +296,7 @@ startElement(void *userData, const char *name, const char **atts) if ((pd->pack & PACK_BLOCK) == 0) { pool->solvables = realloc(pool->solvables, (pool->nsolvables + pd->pack + PACK_BLOCK + 1) * sizeof(Solvable)); - pd->start = pool->solvables + pd->source->start; + pd->start = pool->solvables + pd->repo->start; memset(pd->start + pd->pack, 0, (PACK_BLOCK + 1) * sizeof(Solvable)); } #if 0 @@ -389,12 +389,12 @@ endElement(void *userData, const char *name) case STATE_PATCH: if (!strcmp(name, "patch") && strcmp(pd->kind, "patch")) break; /* already closed */ - s->source = pd->source; + s->repo = pd->repo; if (!s->arch) s->arch = ARCH_NOARCH; if (s->arch != ARCH_SRC && s->arch != ARCH_NOSRC) - s->provides = source_addid_dep(pd->source, s->provides, rel2id(pool, s->name, s->evr, REL_EQ, 1), 0); - s->supplements = source_fix_legacy(pd->source, s->provides, s->supplements); + 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->pack++; break; case STATE_NAME: @@ -436,16 +436,16 @@ characterData(void *userData, const XML_Char *s, int len) #define BUFF_SIZE 8192 -Source * -pool_addsource_patchxml(Pool *pool, FILE *fp) +Repo * +pool_addrepo_patchxml(Pool *pool, FILE *fp) { struct parsedata pd; char buf[BUFF_SIZE]; int i, l; - Source *source; + Repo *repo; struct stateswitch *sw; - source = pool_addsource_empty(pool); + repo = pool_addrepo_empty(pool); memset(&pd, 0, sizeof(pd)); for (i = 0, sw = stateswitches; sw->from != NUMSTATES; i++, sw++) { @@ -454,7 +454,7 @@ pool_addsource_patchxml(Pool *pool, FILE *fp) pd.sbtab[sw->to] = sw->from; } pd.pool = pool; - pd.source = source; + pd.repo = repo; pd.content = malloc(256); pd.acontent = 256; pd.lcontent = 0; @@ -476,8 +476,8 @@ pool_addsource_patchxml(Pool *pool, FILE *fp) XML_ParserFree(parser); pool->nsolvables += pd.pack; - source->nsolvables = pd.pack; + repo->nsolvables = pd.pack; free(pd.content); - return source; + return repo; } diff --git a/tools/repo_patchxml.h b/tools/repo_patchxml.h new file mode 100644 index 00000000..8f9dff58 --- /dev/null +++ b/tools/repo_patchxml.h @@ -0,0 +1 @@ +extern Repo *pool_addrepo_patchxml(Pool *pool, FILE *fp); diff --git a/tools/source_rpmdb.c b/tools/repo_rpmdb.c similarity index 82% rename from tools/source_rpmdb.c rename to tools/repo_rpmdb.c index cea90923..2697a644 100644 --- a/tools/source_rpmdb.c +++ b/tools/repo_rpmdb.c @@ -1,7 +1,7 @@ /* - * source_rpmdb + * repo_rpmdb * - * convert rpm db to source + * convert rpm db to repo * */ @@ -16,7 +16,7 @@ #include "pool.h" #include "hash.h" -#include "source_rpmdb.h" +#include "repo_rpmdb.h" #define TAG_NAME 1000 #define TAG_VERSION 1001 @@ -199,7 +199,7 @@ static char *headtoevr(RpmHead *h) } static unsigned int -makedeps(Pool *pool, Source *source, RpmHead *rpmhead, int tagn, int tagv, int tagf, int strong) +makedeps(Pool *pool, Repo *repo, RpmHead *rpmhead, int tagn, int tagv, int tagf, int strong) { char **n, **v; unsigned int *f; @@ -261,8 +261,8 @@ makedeps(Pool *pool, Source *source, RpmHead *rpmhead, int tagn, int tagv, int t return 0; } cc += haspre; - olddeps = source_reserve_ids(source, 0, cc); - ida = source->idarraydata + olddeps; + olddeps = repo_reserve_ids(repo, 0, cc); + ida = repo->idarraydata + olddeps; for (i = 0; ; i++) { if (i == nc) @@ -300,7 +300,7 @@ makedeps(Pool *pool, Source *source, RpmHead *rpmhead, int tagn, int tagv, int t *ida++ = str2id(pool, n[i], 1); } *ida++ = 0; - source->idarraysize += cc + 1; + repo->idarraysize += cc + 1; free(n); free(v); free(f); @@ -308,22 +308,22 @@ makedeps(Pool *pool, Source *source, RpmHead *rpmhead, int tagn, int tagv, int t } static Offset -copydeps(Pool *pool, Source *source, Offset fromoff, Source *fromsource) +copydeps(Pool *pool, Repo *repo, Offset fromoff, Repo *fromrepo) { int cc; Id id, *ida, *from; Offset ido; - Pool *frompool = fromsource->pool; + Pool *frompool = fromrepo->pool; if (!fromoff) return 0; - from = fromsource->idarraydata + fromoff; + from = fromrepo->idarraydata + fromoff; for (ida = from, cc = 0; *ida; ida++, cc++) ; if (cc == 0) return 0; - ido = source_reserve_ids(source, 0, cc); - ida = source->idarraydata + ido; + ido = repo_reserve_ids(repo, 0, cc); + ida = repo->idarraydata + ido; if (frompool && pool != frompool) { while (*from) @@ -344,7 +344,7 @@ copydeps(Pool *pool, Source *source, Offset fromoff, Source *fromsource) } else memcpy(ida, from, (cc + 1) * sizeof(Id)); - source->idarraysize += cc + 1; + repo->idarraysize += cc + 1; return ido; } @@ -373,7 +373,7 @@ static struct filefilter filefilters[] = { /* assumes last processed array is provides! */ static unsigned int -addfileprovides(Pool *pool, Source *source, RpmHead *rpmhead, unsigned int olddeps) +addfileprovides(Pool *pool, Repo *repo, RpmHead *rpmhead, unsigned int olddeps) { char **bn; char **dn; @@ -449,7 +449,7 @@ addfileprovides(Pool *pool, Source *source, RpmHead *rpmhead, unsigned int oldde } strcpy(fn, dn[di[i]]); strcat(fn, bn[i]); - olddeps = source_addid(source, olddeps, str2id(pool, fn, 1)); + olddeps = repo_addid(repo, olddeps, str2id(pool, fn, 1)); } if (fn) free(fn); @@ -460,7 +460,7 @@ addfileprovides(Pool *pool, Source *source, RpmHead *rpmhead, unsigned int oldde } static int -rpm2solv(Pool *pool, Source *source, Solvable *s, RpmHead *rpmhead) +rpm2solv(Pool *pool, Repo *repo, Solvable *s, RpmHead *rpmhead) { char *name; char *evr; @@ -484,30 +484,30 @@ rpm2solv(Pool *pool, Source *source, Solvable *s, RpmHead *rpmhead) s->evr = str2id(pool, evr, 1); free(evr); - s->provides = makedeps(pool, source, rpmhead, TAG_PROVIDENAME, TAG_PROVIDEVERSION, TAG_PROVIDEFLAGS, 0); - s->provides = addfileprovides(pool, source, rpmhead, s->provides); - s->provides = source_addid_dep(source, s->provides, rel2id(pool, s->name, s->evr, REL_EQ, 1), 0); - s->requires = makedeps(pool, source, rpmhead, TAG_REQUIRENAME, TAG_REQUIREVERSION, TAG_REQUIREFLAGS, 0); - s->conflicts = makedeps(pool, source, rpmhead, TAG_CONFLICTNAME, TAG_CONFLICTVERSION, TAG_CONFLICTFLAGS, 0); - s->obsoletes = makedeps(pool, source, rpmhead, TAG_OBSOLETENAME, TAG_OBSOLETEVERSION, TAG_OBSOLETEFLAGS, 0); - - s->recommends = makedeps(pool, source, rpmhead, TAG_SUGGESTSNAME, TAG_SUGGESTSVERSION, TAG_SUGGESTSFLAGS, 2); - s->suggests = makedeps(pool, source, rpmhead, TAG_SUGGESTSNAME, TAG_SUGGESTSVERSION, TAG_SUGGESTSFLAGS, 1); - s->supplements = makedeps(pool, source, rpmhead, TAG_ENHANCESNAME, TAG_ENHANCESVERSION, TAG_ENHANCESFLAGS, 2); - s->enhances = makedeps(pool, source, rpmhead, TAG_ENHANCESNAME, TAG_ENHANCESVERSION, TAG_ENHANCESFLAGS, 1); + s->provides = makedeps(pool, repo, rpmhead, TAG_PROVIDENAME, TAG_PROVIDEVERSION, TAG_PROVIDEFLAGS, 0); + s->provides = addfileprovides(pool, repo, rpmhead, s->provides); + s->provides = repo_addid_dep(repo, s->provides, rel2id(pool, s->name, s->evr, REL_EQ, 1), 0); + s->requires = makedeps(pool, repo, rpmhead, TAG_REQUIRENAME, TAG_REQUIREVERSION, TAG_REQUIREFLAGS, 0); + s->conflicts = makedeps(pool, repo, rpmhead, TAG_CONFLICTNAME, TAG_CONFLICTVERSION, TAG_CONFLICTFLAGS, 0); + s->obsoletes = makedeps(pool, repo, rpmhead, TAG_OBSOLETENAME, TAG_OBSOLETEVERSION, TAG_OBSOLETEFLAGS, 0); + + s->recommends = makedeps(pool, repo, rpmhead, TAG_SUGGESTSNAME, TAG_SUGGESTSVERSION, TAG_SUGGESTSFLAGS, 2); + s->suggests = makedeps(pool, repo, rpmhead, TAG_SUGGESTSNAME, TAG_SUGGESTSVERSION, TAG_SUGGESTSFLAGS, 1); + s->supplements = makedeps(pool, repo, rpmhead, TAG_ENHANCESNAME, TAG_ENHANCESVERSION, TAG_ENHANCESFLAGS, 2); + s->enhances = makedeps(pool, repo, rpmhead, TAG_ENHANCESNAME, TAG_ENHANCESVERSION, TAG_ENHANCESFLAGS, 1); s->freshens = 0; - s->supplements = source_fix_legacy(source, s->provides, s->supplements); + s->supplements = repo_fix_legacy(repo, s->provides, s->supplements); return 1; } /* - * read rpm db as source + * read rpm db as repo * */ -Source * -pool_addsource_rpmdb(Pool *pool, Source *ref) +Repo * +pool_addrepo_rpmdb(Pool *pool, Repo *ref) { unsigned char buf[16]; DB *db = 0; @@ -520,13 +520,13 @@ pool_addsource_rpmdb(Pool *pool, Source *ref) int i; int rpmheadsize; RpmHead *rpmhead; - Source *source; + Repo *repo; Solvable *s; Id id, *refhash; unsigned int refmask, h; int asolv; - source = pool_addsource_empty(pool); + repo = pool_addrepo_empty(pool); if (ref && !(ref->nsolvables && ref->rpmdbid)) ref = 0; @@ -556,8 +556,8 @@ pool_addsource_rpmdb(Pool *pool, Source *ref) } dbidp = (unsigned char *)&dbid; pool->solvables = realloc(pool->solvables, (pool->nsolvables + 256) * sizeof(Solvable)); - memset(pool->solvables + source->start, 0, 256 * sizeof(Solvable)); - source->rpmdbid = calloc(256, sizeof(unsigned int)); + memset(pool->solvables + repo->start, 0, 256 * sizeof(Solvable)); + repo->rpmdbid = calloc(256, sizeof(unsigned int)); asolv = 256; rpmheadsize = 0; rpmhead = 0; @@ -567,12 +567,12 @@ pool_addsource_rpmdb(Pool *pool, Source *ref) if (i >= asolv) { pool->solvables = realloc(pool->solvables, (pool->nsolvables + asolv + 256) * sizeof(Solvable)); - memset(pool->solvables + source->start + asolv, 0, 256 * sizeof(Solvable)); - source->rpmdbid = realloc(source->rpmdbid, (asolv + 256) * sizeof(unsigned int)); - memset(source->rpmdbid + asolv, 0, 256 * sizeof(unsigned int)); + memset(pool->solvables + repo->start + asolv, 0, 256 * sizeof(Solvable)); + repo->rpmdbid = realloc(repo->rpmdbid, (asolv + 256) * sizeof(unsigned int)); + memset(repo->rpmdbid + asolv, 0, 256 * sizeof(unsigned int)); asolv += 256; } - pool->solvables[source->start + i].source = source; + pool->solvables[repo->start + i].repo = repo; if (key.size != 4) { fprintf(stderr, "corrupt Packages database (key size)\n"); @@ -609,8 +609,8 @@ pool_addsource_rpmdb(Pool *pool, Source *ref) } memcpy(rpmhead->data, (unsigned char *)data.data + 8, rpmhead->cnt * 16 + rpmhead->dcnt); rpmhead->dp = rpmhead->data + rpmhead->cnt * 16; - source->rpmdbid[i] = dbid; - if (rpm2solv(pool, source, pool->solvables + source->start + i, rpmhead)) + repo->rpmdbid[i] = dbid; + if (rpm2solv(pool, repo, pool->solvables + repo->start + i, rpmhead)) i++; } nrpmids = i; @@ -682,8 +682,8 @@ pool_addsource_rpmdb(Pool *pool, Source *ref) rpmhead = 0; pool->solvables = realloc(pool->solvables, (pool->nsolvables + nrpmids) * sizeof(Solvable)); - memset(pool->solvables + source->start, 0, nrpmids * sizeof(Solvable)); - source->rpmdbid = calloc(nrpmids, sizeof(unsigned int)); + memset(pool->solvables + repo->start, 0, nrpmids * sizeof(Solvable)); + repo->rpmdbid = calloc(nrpmids, sizeof(unsigned int)); refhash = 0; refmask = 0; @@ -699,12 +699,12 @@ pool_addsource_rpmdb(Pool *pool, Source *ref) refhash[h] = i + 1; /* make it non-zero */ } } - s = pool->solvables + source->start; + s = pool->solvables + repo->start; for (i = 0; i < nrpmids; i++, rp++, s++) { - s->source = source; + s->repo = repo; dbid = rp->dbid; - source->rpmdbid[i] = dbid; + repo->rpmdbid[i] = dbid; if (refhash) { h = dbid & refmask; @@ -732,15 +732,15 @@ pool_addsource_rpmdb(Pool *pool, Source *ref) if (r->arch) s->arch = str2id(pool, id2str(ref->pool, r->arch), 1); } - s->provides = copydeps(pool, source, r->provides, ref); - s->requires = copydeps(pool, source, r->requires, ref); - s->conflicts = copydeps(pool, source, r->conflicts, ref); - s->obsoletes = copydeps(pool, source, r->obsoletes, ref); - s->recommends = copydeps(pool, source, r->recommends, ref); - s->suggests = copydeps(pool, source, r->suggests, ref); - s->supplements = copydeps(pool, source, r->supplements, ref); - s->enhances = copydeps(pool, source, r->enhances, ref); - s->freshens = copydeps(pool, source, r->freshens, ref); + s->provides = copydeps(pool, repo, r->provides, ref); + s->requires = copydeps(pool, repo, r->requires, ref); + s->conflicts = copydeps(pool, repo, r->conflicts, ref); + s->obsoletes = copydeps(pool, repo, r->obsoletes, ref); + s->recommends = copydeps(pool, repo, r->recommends, ref); + s->suggests = copydeps(pool, repo, r->suggests, ref); + s->supplements = copydeps(pool, repo, r->supplements, ref); + s->enhances = copydeps(pool, repo, r->enhances, ref); + s->freshens = copydeps(pool, repo, r->freshens, ref); continue; } } @@ -801,7 +801,7 @@ pool_addsource_rpmdb(Pool *pool, Source *ref) memcpy(rpmhead->data, (unsigned char *)data.data + 8, rpmhead->cnt * 16 + rpmhead->dcnt); rpmhead->dp = rpmhead->data + rpmhead->cnt * 16; - rpm2solv(pool, source, s, rpmhead); + rpm2solv(pool, repo, s, rpmhead); } if (refhash) @@ -816,9 +816,9 @@ pool_addsource_rpmdb(Pool *pool, Source *ref) if (rpmhead) free(rpmhead); pool->nsolvables += nrpmids; - source->nsolvables = nrpmids; + repo->nsolvables = nrpmids; if (db) db->close(db, 0); - return source; + return repo; } diff --git a/tools/repo_rpmdb.h b/tools/repo_rpmdb.h new file mode 100644 index 00000000..027d610c --- /dev/null +++ b/tools/repo_rpmdb.h @@ -0,0 +1 @@ +extern Repo *pool_addrepo_rpmdb(Pool *pool, Repo *ref); diff --git a/tools/source_rpmmd.c b/tools/repo_rpmmd.c similarity index 94% rename from tools/source_rpmmd.c rename to tools/repo_rpmmd.c index c34cd406..b9b65f92 100644 --- a/tools/source_rpmmd.c +++ b/tools/repo_rpmmd.c @@ -7,7 +7,7 @@ #include #include "pool.h" -#include "source_rpmmd.h" +#include "repo_rpmmd.h" enum state { @@ -88,7 +88,7 @@ struct parsedata { int numpacks; int pack; Pool *pool; - Source *source; + Repo *repo; Solvable *start; struct stateswitch *swtab[NUMSTATES]; enum state sbtab[NUMSTATES]; @@ -219,7 +219,7 @@ adddep(Pool *pool, struct parsedata *pd, unsigned int olddeps, const char **atts #if 0 fprintf(stderr, "new dep %s%s%s\n", id2str(pool, d), id2rel(pool, d), id2evr(pool, d)); #endif - return source_addid_dep(pd->source, olddeps, id, isreq); + return repo_addid_dep(pd->repo, olddeps, id, isreq); } @@ -264,7 +264,7 @@ startElement(void *userData, const char *name, const char **atts) fprintf(stderr, "numpacks: %d\n", pd->numpacks); #endif pool->solvables = realloc(pool->solvables, (pool->nsolvables + pd->numpacks) * sizeof(Solvable)); - pd->start = pool->solvables + pd->source->start; + pd->start = pool->solvables + pd->repo->start; memset(pd->start, 0, pd->numpacks * sizeof(Solvable)); } } @@ -360,12 +360,12 @@ endElement(void *userData, const char *name) switch (pd->state) { case STATE_PACKAGE: - s->source = pd->source; + s->repo = pd->repo; if (!s->arch) s->arch = ARCH_NOARCH; if (s->arch != ARCH_SRC && s->arch != ARCH_NOSRC) - s->provides = source_addid_dep(pd->source, s->provides, rel2id(pool, s->name, s->evr, REL_EQ, 1), 0); - s->supplements = source_fix_legacy(pd->source, s->provides, s->supplements); + 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->pack++; break; case STATE_NAME: @@ -376,7 +376,7 @@ endElement(void *userData, const char *name) break; case STATE_FILE: id = str2id(pool, pd->content, 1); - s->provides = source_addid(pd->source, s->provides, id); + s->provides = repo_addid(pd->repo, s->provides, id); break; default: break; @@ -411,16 +411,16 @@ characterData(void *userData, const XML_Char *s, int len) #define BUFF_SIZE 8192 -Source * -pool_addsource_rpmmd(Pool *pool, FILE *fp) +Repo * +pool_addrepo_rpmmd(Pool *pool, FILE *fp) { struct parsedata pd; char buf[BUFF_SIZE]; int i, l; - Source *source; + Repo *repo; struct stateswitch *sw; - source = pool_addsource_empty(pool); + repo = pool_addrepo_empty(pool); memset(&pd, 0, sizeof(pd)); for (i = 0, sw = stateswitches; sw->from != NUMSTATES; i++, sw++) { @@ -429,7 +429,7 @@ pool_addsource_rpmmd(Pool *pool, FILE *fp) pd.sbtab[sw->to] = sw->from; } pd.pool = pool; - pd.source = source; + pd.repo = repo; pd.content = malloc(256); pd.acontent = 256; pd.lcontent = 0; @@ -451,8 +451,8 @@ pool_addsource_rpmmd(Pool *pool, FILE *fp) XML_ParserFree(parser); pool->nsolvables += pd.pack; - source->nsolvables = pd.pack; + repo->nsolvables = pd.pack; free(pd.content); - return source; + return repo; } diff --git a/tools/repo_rpmmd.h b/tools/repo_rpmmd.h new file mode 100644 index 00000000..3e51fa32 --- /dev/null +++ b/tools/repo_rpmmd.h @@ -0,0 +1 @@ +extern Repo *pool_addrepo_rpmmd(Pool *pool, FILE *fp); diff --git a/tools/source_susetags.c b/tools/repo_susetags.c similarity index 88% rename from tools/source_susetags.c rename to tools/repo_susetags.c index e07d5af4..d7b06246 100644 --- a/tools/source_susetags.c +++ b/tools/repo_susetags.c @@ -6,7 +6,7 @@ #include #include "pool.h" -#include "source_susetags.h" +#include "repo_susetags.h" #define PACK_BLOCK 255 @@ -32,7 +32,7 @@ split(char *l, char **sp, int m) struct parsedata { char *kind; - Source *source; + Repo *repo; char *tmp; int tmpl; }; @@ -123,15 +123,15 @@ adddep(Pool *pool, struct parsedata *pd, unsigned int olddeps, char *line, int i } id = rel2id(pool, id, evrid, flags + 1, 1); } - return source_addid_dep(pd->source, olddeps, id, isreq); + return repo_addid_dep(pd->repo, olddeps, id, isreq); } -Source * -pool_addsource_susetags(Pool *pool, FILE *fp) +Repo * +pool_addrepo_susetags(Pool *pool, FILE *fp) { char *line, *linep; int aline; - Source *source; + Repo *repo; Solvable *s; int intag = 0; int cummulate = 0; @@ -139,12 +139,12 @@ pool_addsource_susetags(Pool *pool, FILE *fp) char *sp[5]; struct parsedata pd; - source = pool_addsource_empty(pool); + repo = pool_addrepo_empty(pool); memset(&pd, 0, sizeof(pd)); line = malloc(1024); aline = 1024; - pd.source = source; + pd.repo = repo; linep = line; pack = 0; @@ -209,19 +209,19 @@ pool_addsource_susetags(Pool *pool, FILE *fp) if (!strncmp(line, "=Pkg:", 5) || !strncmp(line, "=Pat:", 5)) { if (s && s->arch != ARCH_SRC && s->arch != ARCH_NOSRC) - s->provides = source_addid_dep(source, s->provides, rel2id(pool, s->name, s->evr, REL_EQ, 1), 0); + s->provides = repo_addid_dep(repo, s->provides, rel2id(pool, s->name, s->evr, REL_EQ, 1), 0); if (s) - s->supplements = source_fix_legacy(source, s->provides, s->supplements); + s->supplements = repo_fix_legacy(repo, s->provides, s->supplements); pd.kind = 0; if (line[3] == 't') pd.kind = "pattern"; if ((pack & PACK_BLOCK) == 0) { pool->solvables = realloc(pool->solvables, (pool->nsolvables + pack + PACK_BLOCK + 1) * sizeof(Solvable)); - memset(pool->solvables + source->start + pack, 0, (PACK_BLOCK + 1) * sizeof(Solvable)); + memset(pool->solvables + repo->start + pack, 0, (PACK_BLOCK + 1) * sizeof(Solvable)); } - s = pool->solvables + source->start + pack; - s->source = source; + s = pool->solvables + repo->start + pack; + s->repo = repo; pack++; if (split(line + 5, sp, 5) != 4) { @@ -301,14 +301,14 @@ pool_addsource_susetags(Pool *pool, FILE *fp) } } if (s && s->arch != ARCH_SRC && s->arch != ARCH_NOSRC) - s->provides = source_addid_dep(source, s->provides, rel2id(pool, s->name, s->evr, REL_EQ, 1), 0); + s->provides = repo_addid_dep(repo, s->provides, rel2id(pool, s->name, s->evr, REL_EQ, 1), 0); if (s) - s->supplements = source_fix_legacy(source, s->provides, s->supplements); + s->supplements = repo_fix_legacy(repo, s->provides, s->supplements); pool->nsolvables += pack; - source->nsolvables = pack; + repo->nsolvables = pack; if (pd.tmp) free(pd.tmp); free(line); - return source; + return repo; } diff --git a/tools/repo_susetags.h b/tools/repo_susetags.h new file mode 100644 index 00000000..1019583f --- /dev/null +++ b/tools/repo_susetags.h @@ -0,0 +1 @@ +extern Repo *pool_addrepo_susetags(Pool *pool, FILE *fp); diff --git a/tools/source_write.c b/tools/repo_write.c similarity index 95% rename from tools/source_write.c rename to tools/repo_write.c index d954992e..78c00697 100644 --- a/tools/source_write.c +++ b/tools/repo_write.c @@ -1,7 +1,7 @@ /* - * source_write.c + * repo_write.c * - * Write Source data out to binary file + * Write Repo data out to binary file * * See doc/README.format for a description * of the binary file format @@ -16,7 +16,7 @@ #include #include "pool.h" -#include "source_write.h" +#include "repo_write.h" /*------------------------------------------------------------------*/ /* Id map optimizations */ @@ -178,11 +178,11 @@ write_idarray(FILE *fp, Pool *pool, NeedId *needid, Id *ids) /* - * Source + * Repo */ void -pool_writesource(Pool *pool, Source *source, FILE *fp) +pool_writerepo(Pool *pool, Repo *repo, FILE *fp) { int i, numsolvdata; Solvable *s, *sstart; @@ -196,9 +196,9 @@ pool_writesource(Pool *pool, Source *source, FILE *fp) int bits, bitmaps; int nsolvables; - nsolvables = source->nsolvables; - sstart = pool->solvables + source->start; - idarraydata = source->idarraydata; + nsolvables = repo->nsolvables; + sstart = pool->solvables + repo->start; + idarraydata = repo->idarraydata; needid = (NeedId *)calloc(pool->nstrings + pool->nrels, sizeof(*needid)); @@ -233,7 +233,7 @@ pool_writesource(Pool *pool, Source *source, FILE *fp) idsizes[SOLVABLE_NAME] = 1; idsizes[SOLVABLE_ARCH] = 1; idsizes[SOLVABLE_EVR] = 1; - if (source->rpmdbid) + if (repo->rpmdbid) idsizes[RPM_RPMDBID] = 1; for (i = SOLVABLE_NAME; i <= RPM_RPMDBID; i++) @@ -311,7 +311,7 @@ pool_writesource(Pool *pool, Source *source, FILE *fp) write_u8( fp, ran->flags); } - write_u32(fp, 0); /* no source data */ + write_u32(fp, 0); /* no repo data */ /* * write Solvables @@ -344,7 +344,7 @@ pool_writesource(Pool *pool, Source *source, FILE *fp) write_u32(fp, 0); } - if (source->rpmdbid) + if (repo->rpmdbid) { write_u8(fp, TYPE_U32); write_id(fp, needid[RPM_RPMDBID].need); @@ -405,8 +405,8 @@ pool_writesource(Pool *pool, Source *source, FILE *fp) write_idarray(fp, pool, needid, idarraydata + s->enhances); if (s->freshens) write_idarray(fp, pool, needid, idarraydata + s->freshens); - if (source->rpmdbid) - write_u32(fp, source->rpmdbid[i]); + if (repo->rpmdbid) + write_u32(fp, repo->rpmdbid[i]); } free(needid); diff --git a/tools/repo_write.h b/tools/repo_write.h new file mode 100644 index 00000000..7e73e272 --- /dev/null +++ b/tools/repo_write.h @@ -0,0 +1,16 @@ +/* + * repo_write.h + * + */ + +#ifndef REPO_WRITE_H +#define REPO_WRITE_H + +#include + +#include "pool.h" +#include "repo.h" + +extern void pool_writerepo(Pool *pool, Repo *repo, FILE *fp); + +#endif diff --git a/tools/rpmdb2solv.c b/tools/rpmdb2solv.c index e4239fb9..3dd7f926 100644 --- a/tools/rpmdb2solv.c +++ b/tools/rpmdb2solv.c @@ -11,15 +11,15 @@ #include #include "pool.h" -#include "source_rpmdb.h" -#include "source_solv.h" -#include "source_write.h" +#include "repo_rpmdb.h" +#include "repo_solv.h" +#include "repo_write.h" int main(int argc, char **argv) { Pool *pool = pool_create(); - Source *ref = NULL; + Repo *ref = NULL; FILE *fp; if (argc != 1) @@ -30,21 +30,21 @@ main(int argc, char **argv) perror(argv[1]); exit(0); } - ref = pool_addsource_solv(refpool, fp, "rpmdb"); + ref = pool_addrepo_solv(refpool, fp, "rpmdb"); fclose(fp); } - Source *source = pool_addsource_rpmdb(pool, ref); + Repo *repo = pool_addrepo_rpmdb(pool, ref); if (ref) { if (ref->pool != pool) pool_free(ref->pool); else - pool_freesource(pool, ref); + pool_freerepo(pool, ref); ref = NULL; } - pool_writesource(pool, source, stdout); + pool_writerepo(pool, repo, stdout); pool_free(pool); exit(0); diff --git a/tools/rpmmd2solv.c b/tools/rpmmd2solv.c index 9ca1ba2c..4a797527 100644 --- a/tools/rpmmd2solv.c +++ b/tools/rpmmd2solv.c @@ -6,15 +6,15 @@ #include #include "pool.h" -#include "source_rpmmd.h" -#include "source_write.h" +#include "repo_rpmmd.h" +#include "repo_write.h" int main(int argc, char **argv) { Pool *pool = pool_create(); - Source *source = pool_addsource_rpmmd(pool, stdin); - pool_writesource(pool, source, stdout); + Repo *repo = pool_addrepo_rpmmd(pool, stdin); + pool_writerepo(pool, repo, stdout); pool_free(pool); exit(0); } diff --git a/tools/source_content.h b/tools/source_content.h deleted file mode 100644 index ca7f0adf..00000000 --- a/tools/source_content.h +++ /dev/null @@ -1 +0,0 @@ -Source * pool_addsource_content(Pool *pool, FILE *fp); diff --git a/tools/source_helix.h b/tools/source_helix.h deleted file mode 100644 index dfcf45ef..00000000 --- a/tools/source_helix.h +++ /dev/null @@ -1,15 +0,0 @@ -/* - * source_helix.h - * - */ - -#ifndef SOURCE_HELIX_H -#define SOURCE_HELIX_H - -#include -#include "pool.h" -#include "source.h" - -extern Source *pool_addsource_helix(Pool *pool, FILE *fp); - -#endif /* SOURCE_HELIX_H */ diff --git a/tools/source_patchxml.h b/tools/source_patchxml.h deleted file mode 100644 index 75d8aa32..00000000 --- a/tools/source_patchxml.h +++ /dev/null @@ -1 +0,0 @@ -extern Source *pool_addsource_patchxml(Pool *pool, FILE *fp); diff --git a/tools/source_rpmdb.h b/tools/source_rpmdb.h deleted file mode 100644 index d17d418f..00000000 --- a/tools/source_rpmdb.h +++ /dev/null @@ -1 +0,0 @@ -extern Source *pool_addsource_rpmdb(Pool *pool, Source *ref); diff --git a/tools/source_rpmmd.h b/tools/source_rpmmd.h deleted file mode 100644 index 38cc00d8..00000000 --- a/tools/source_rpmmd.h +++ /dev/null @@ -1 +0,0 @@ -extern Source *pool_addsource_rpmmd(Pool *pool, FILE *fp); diff --git a/tools/source_susetags.h b/tools/source_susetags.h deleted file mode 100644 index 3938e7ce..00000000 --- a/tools/source_susetags.h +++ /dev/null @@ -1 +0,0 @@ -extern Source *pool_addsource_susetags(Pool *pool, FILE *fp); diff --git a/tools/source_write.h b/tools/source_write.h deleted file mode 100644 index 3ab230fc..00000000 --- a/tools/source_write.h +++ /dev/null @@ -1,16 +0,0 @@ -/* - * source_write.h - * - */ - -#ifndef SOURCE_WRITE_H -#define SOURCE_WRITE_H - -#include - -#include "pool.h" -#include "source.h" - -extern void pool_writesource(Pool *pool, Source *source, FILE *fp); - -#endif diff --git a/tools/susetags2solv.c b/tools/susetags2solv.c index 764a69ce..3666f6e5 100644 --- a/tools/susetags2solv.c +++ b/tools/susetags2solv.c @@ -6,15 +6,15 @@ #include #include "pool.h" -#include "source_susetags.h" -#include "source_write.h" +#include "repo_susetags.h" +#include "repo_write.h" int main(int argc, char **argv) { Pool *pool = pool_create(); - Source *source = pool_addsource_susetags(pool, stdin); - pool_writesource(pool, source, stdout); + Repo *repo = pool_addrepo_susetags(pool, stdin); + pool_writerepo(pool, repo, stdout); pool_free(pool); exit(0); }