{
Id dep, sid;
const char *s, *sr;
+ struct searchfiles *csf;
while ((dep = *ida++) != 0)
{
+ csf = sf;
while (ISRELDEP(dep))
{
Reldep *rd;
sid = pool->ss.nstrings + GETRELID(dep);
- if (MAPTST(&sf->seen, sid))
+ if (MAPTST(&csf->seen, sid))
{
dep = 0;
break;
}
- MAPSET(&sf->seen, sid);
+ MAPSET(&csf->seen, sid);
rd = GETRELDEP(pool, dep);
if (rd->flags < 8)
dep = rd->name;
else if (rd->flags == REL_NAMESPACE)
{
- if (isf && (rd->name == NAMESPACE_INSTALLED || rd->name == NAMESPACE_SPLITPROVIDES))
+ if (rd->name == NAMESPACE_INSTALLED || rd->name == NAMESPACE_SPLITPROVIDES)
{
- sf = isf;
- isf = 0;
- if (MAPTST(&sf->seen, sid))
+ csf = isf;
+ if (!csf || MAPTST(&csf->seen, sid))
{
dep = 0;
break;
}
- MAPSET(&sf->seen, sid);
+ MAPSET(&csf->seen, sid);
}
dep = rd->evr;
}
Id ids[2];
ids[0] = rd->name;
ids[1] = 0;
- pool_addfileprovides_dep(pool, ids, sf, isf);
+ pool_addfileprovides_dep(pool, ids, csf, isf);
dep = rd->evr;
}
}
if (!dep)
continue;
- if (MAPTST(&sf->seen, dep))
+ if (MAPTST(&csf->seen, dep))
continue;
- MAPSET(&sf->seen, dep);
+ MAPSET(&csf->seen, dep);
s = id2str(pool, dep);
if (*s != '/')
continue;
- sf->ids = sat_extend(sf->ids, sf->nfiles, 1, sizeof(Id), SEARCHFILES_BLOCK);
- sf->dirs = sat_extend(sf->dirs, sf->nfiles, 1, sizeof(const char *), SEARCHFILES_BLOCK);
- sf->names = sat_extend(sf->names, sf->nfiles, 1, sizeof(const char *), SEARCHFILES_BLOCK);
- sf->ids[sf->nfiles] = dep;
+ csf->ids = sat_extend(csf->ids, csf->nfiles, 1, sizeof(Id), SEARCHFILES_BLOCK);
+ csf->dirs = sat_extend(csf->dirs, csf->nfiles, 1, sizeof(const char *), SEARCHFILES_BLOCK);
+ csf->names = sat_extend(csf->names, csf->nfiles, 1, sizeof(const char *), SEARCHFILES_BLOCK);
+ csf->ids[csf->nfiles] = dep;
sr = strrchr(s, '/');
- sf->names[sf->nfiles] = strdup(sr + 1);
- sf->dirs[sf->nfiles] = sat_malloc(sr - s + 1);
+ csf->names[csf->nfiles] = strdup(sr + 1);
+ csf->dirs[csf->nfiles] = sat_malloc(sr - s + 1);
if (sr != s)
- strncpy(sf->dirs[sf->nfiles], s, sr - s);
- sf->dirs[sf->nfiles][sr - s] = 0;
- sf->nfiles++;
+ strncpy(csf->dirs[csf->nfiles], s, sr - s);
+ csf->dirs[csf->nfiles][sr - s] = 0;
+ csf->nfiles++;
}
}
{
Solvable *s;
Repo *repo;
- struct searchfiles sf, isf;
+ struct searchfiles sf, isf, *isfp;
struct addfileprovides_cbdata cbd;
int i;
memset(&isf, 0, sizeof(isf));
map_init(&isf.seen, pool->ss.nstrings + pool->nrels);
+ isfp = installed ? &isf : 0;
for (i = 1, s = pool->solvables + i; i < pool->nsolvables; i++, s++)
{
repo = s->repo;
if (!repo)
continue;
if (s->obsoletes)
- pool_addfileprovides_dep(pool, repo->idarraydata + s->obsoletes, &sf, &isf);
+ pool_addfileprovides_dep(pool, repo->idarraydata + s->obsoletes, &sf, isfp);
if (s->conflicts)
- pool_addfileprovides_dep(pool, repo->idarraydata + s->conflicts, &sf, &isf);
+ pool_addfileprovides_dep(pool, repo->idarraydata + s->conflicts, &sf, isfp);
if (s->requires)
- pool_addfileprovides_dep(pool, repo->idarraydata + s->requires, &sf, &isf);
+ pool_addfileprovides_dep(pool, repo->idarraydata + s->requires, &sf, isfp);
if (s->recommends)
- pool_addfileprovides_dep(pool, repo->idarraydata + s->recommends, &sf, &isf);
+ pool_addfileprovides_dep(pool, repo->idarraydata + s->recommends, &sf, isfp);
if (s->suggests)
- pool_addfileprovides_dep(pool, repo->idarraydata + s->suggests, &sf, &isf);
+ pool_addfileprovides_dep(pool, repo->idarraydata + s->suggests, &sf, isfp);
if (s->supplements)
- pool_addfileprovides_dep(pool, repo->idarraydata + s->supplements, &sf, &isf);
+ pool_addfileprovides_dep(pool, repo->idarraydata + s->supplements, &sf, isfp);
if (s->enhances)
- pool_addfileprovides_dep(pool, repo->idarraydata + s->enhances, &sf, &isf);
+ pool_addfileprovides_dep(pool, repo->idarraydata + s->enhances, &sf, isfp);
if (s->freshens)
- pool_addfileprovides_dep(pool, repo->idarraydata + s->freshens, &sf, &isf);
+ pool_addfileprovides_dep(pool, repo->idarraydata + s->freshens, &sf, isfp);
}
map_free(&sf.seen);
map_free(&isf.seen);
sat_free(sf.dirs);
sat_free(sf.names);
}
- if (isf.nfiles && installed)
+ if (isf.nfiles)
{
#if 0
for (i = 0; i < isf.nfiles; i++)
POOL_DEBUG(SAT_DEBUG_STATS, "looking up %s in installed filelist\n", id2str(pool, isf.ids[i]));
#endif
- pool_addfileprovides_search(pool, &cbd, &isf, installed);
+ if (installed)
+ pool_addfileprovides_search(pool, &cbd, &isf, installed);
sat_free(isf.ids);
for (i = 0; i < isf.nfiles; i++)
{
data->attrdatalen += l;
}
+static void
+repoadata_add_array(Repodata *data, Id entry, Id keyname, Id keytype, int entrysize)
+{
+ int oldsize;
+ Id *ida, *pp;
+
+ pp = 0;
+ if (data->attrs && data->attrs[entry])
+ for (pp = data->attrs[entry]; *pp; pp += 2)
+ if (data->keys[*pp].name == keyname && data->keys[*pp].type == keytype)
+ break;
+ if (!pp || !*pp)
+ {
+ /* not found. allocate new key */
+ Repokey key;
+ key.name = keyname;
+ key.type = keytype;
+ key.size = 0;
+ key.storage = KEY_STORAGE_INCORE;
+ data->attriddata = sat_extend(data->attriddata, data->attriddatalen, entrysize + 1, sizeof(Id), REPODATA_ATTRIDDATA_BLOCK);
+ repodata_set(data, entry, &key, data->attriddatalen);
+ return;
+ }
+ oldsize = 0;
+ for (ida = data->attriddata + pp[1]; *ida; ida += entrysize)
+ oldsize += entrysize;
+ if (ida + 1 == data->attriddata + data->attriddatalen)
+ {
+ /* this was the last entry, just append it */
+ data->attriddata = sat_extend(data->attriddata, data->attriddatalen, entrysize, sizeof(Id), REPODATA_ATTRIDDATA_BLOCK);
+ data->attriddatalen--; /* overwrite terminating 0 */
+ }
+ else
+ {
+ /* too bad. move to back. */
+ data->attriddata = sat_extend(data->attriddata, data->attriddatalen, oldsize + entrysize + 1, sizeof(Id), REPODATA_ATTRIDDATA_BLOCK);
+ memcpy(data->attriddata + data->attriddatalen, data->attriddata + pp[1], oldsize * sizeof(Id));
+ pp[1] = data->attriddatalen;
+ data->attriddatalen += oldsize;
+ }
+}
+
void
repodata_add_dirnumnum(Repodata *data, Id entry, Id keyname, Id dir, Id num, Id num2)
{
- Id *ida, *pp;
- Repokey key;
#if 0
fprintf(stderr, "repodata_add_dirnumnum %d %d %d %d (%d)\n", entry, dir, num, num2, data->attriddatalen);
#endif
- if (data->attrs && data->attrs[entry])
- {
- for (pp = data->attrs[entry]; *pp; pp += 2)
- if (data->keys[*pp].name == keyname && data->keys[*pp].type == REPOKEY_TYPE_DIRNUMNUMARRAY)
- break;
- if (*pp)
- {
- int oldsize = 0;
- for (ida = data->attriddata + pp[1]; *ida; ida += 3)
- oldsize += 3;
- if (ida + 1 == data->attriddata + data->attriddatalen)
- {
- /* this was the last entry, just append it */
- data->attriddata = sat_extend(data->attriddata, data->attriddatalen, 3, sizeof(Id), REPODATA_ATTRIDDATA_BLOCK);
- data->attriddatalen--; /* overwrite terminating 0 */
- }
- else
- {
- /* too bad. move to back. */
- data->attriddata = sat_extend(data->attriddata, data->attriddatalen, oldsize + 4, sizeof(Id), REPODATA_ATTRIDDATA_BLOCK);
- memcpy(data->attriddata + data->attriddatalen, data->attriddata + pp[1], oldsize * sizeof(Id));
- pp[1] = data->attriddatalen;
- data->attriddatalen += oldsize;
- }
- data->attriddata[data->attriddatalen++] = dir;
- data->attriddata[data->attriddatalen++] = num;
- data->attriddata[data->attriddatalen++] = num2;
- data->attriddata[data->attriddatalen++] = 0;
- return;
- }
- }
- key.name = keyname;
- key.type = REPOKEY_TYPE_DIRNUMNUMARRAY;
- key.size = 0;
- key.storage = KEY_STORAGE_INCORE;
- data->attriddata = sat_extend(data->attriddata, data->attriddatalen, 4, sizeof(Id), REPODATA_ATTRIDDATA_BLOCK);
- repodata_set(data, entry, &key, data->attriddatalen);
+ repoadata_add_array(data, entry, keyname, REPOKEY_TYPE_DIRNUMNUMARRAY, 3);
data->attriddata[data->attriddatalen++] = dir;
data->attriddata[data->attriddatalen++] = num;
data->attriddata[data->attriddatalen++] = num2;
void
repodata_add_dirstr(Repodata *data, Id entry, Id keyname, Id dir, const char *str)
{
- Id *ida, *pp, stroff;
- Repokey key;
+ Id stroff;
int l;
l = strlen(str) + 1;
#if 0
fprintf(stderr, "repodata_add_dirstr %d %d %s (%d)\n", entry, dir, str, data->attriddatalen);
#endif
- if (data->attrs && data->attrs[entry])
- {
- for (pp = data->attrs[entry]; *pp; pp += 2)
- if (data->keys[*pp].name == keyname && data->keys[*pp].type == REPOKEY_TYPE_DIRSTRARRAY)
- break;
- if (*pp)
- {
- int oldsize = 0;
- for (ida = data->attriddata + pp[1]; *ida; ida += 2)
- oldsize += 2;
- if (ida + 1 == data->attriddata + data->attriddatalen)
- {
- /* this was the last entry, just append it */
- data->attriddata = sat_extend(data->attriddata, data->attriddatalen, 2, sizeof(Id), REPODATA_ATTRIDDATA_BLOCK);
- data->attriddatalen--; /* overwrite terminating 0 */
- }
- else
- {
- /* too bad. move to back. */
- data->attriddata = sat_extend(data->attriddata, data->attriddatalen, oldsize + 3, sizeof(Id), REPODATA_ATTRIDDATA_BLOCK);
- memcpy(data->attriddata + data->attriddatalen, data->attriddata + pp[1], oldsize * sizeof(Id));
- pp[1] = data->attriddatalen;
- data->attriddatalen += oldsize;
- }
- data->attriddata[data->attriddatalen++] = dir;
- data->attriddata[data->attriddatalen++] = stroff;
- data->attriddata[data->attriddatalen++] = 0;
- return;
- }
- }
- key.name = keyname;
- key.type = REPOKEY_TYPE_DIRSTRARRAY;
- key.size = 0;
- key.storage = KEY_STORAGE_INCORE;
- data->attriddata = sat_extend(data->attriddata, data->attriddatalen, 3, sizeof(Id), REPODATA_ATTRIDDATA_BLOCK);
- repodata_set(data, entry, &key, data->attriddatalen);
+ repoadata_add_array(data, entry, keyname, REPOKEY_TYPE_DIRSTRARRAY, 2);
data->attriddata[data->attriddatalen++] = dir;
data->attriddata[data->attriddatalen++] = stroff;
data->attriddata[data->attriddatalen++] = 0;
void
repodata_add_idarray(Repodata *data, Id entry, Id keyname, Id id)
{
- Id *ida, *pp;
- Repokey key;
-
#if 0
fprintf(stderr, "repodata_add_idarray %d %d (%d)\n", entry, id, data->attriddatalen);
#endif
- if (data->attrs && data->attrs[entry])
- {
- for (pp = data->attrs[entry]; *pp; pp += 2)
- if (data->keys[*pp].name == keyname
- && data->keys[*pp].type == REPOKEY_TYPE_IDARRAY)
- break;
- if (*pp)
- {
- int oldsize = 0;
- for (ida = data->attriddata + pp[1]; *ida; ida++)
- oldsize++;
- if (ida + 1 == data->attriddata + data->attriddatalen)
- {
- /* this was the last entry, just append it */
- data->attriddata = sat_extend(data->attriddata, data->attriddatalen, 1, sizeof(Id), REPODATA_ATTRIDDATA_BLOCK);
- data->attriddatalen--; /* overwrite terminating 0 */
- }
- else
- {
- /* too bad. move to back. */
- data->attriddata = sat_extend(data->attriddata, data->attriddatalen, oldsize + 2, sizeof(Id), REPODATA_ATTRIDDATA_BLOCK);
- memcpy(data->attriddata + data->attriddatalen, data->attriddata + pp[1], oldsize * sizeof(Id));
- pp[1] = data->attriddatalen;
- data->attriddatalen += oldsize;
- }
- data->attriddata[data->attriddatalen++] = id;
- data->attriddata[data->attriddatalen++] = 0;
- return;
- }
- }
- key.name = keyname;
- key.type = REPOKEY_TYPE_IDARRAY;
- key.size = 0;
- key.storage = KEY_STORAGE_INCORE;
- data->attriddata = sat_extend(data->attriddata, data->attriddatalen, 2, sizeof(Id), REPODATA_ATTRIDDATA_BLOCK);
- repodata_set(data, entry, &key, data->attriddatalen);
+ repoadata_add_array(data, entry, keyname, REPOKEY_TYPE_IDARRAY, 1);
data->attriddata[data->attriddatalen++] = id;
data->attriddata[data->attriddatalen++] = 0;
}