summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Schroeder <mls@suse.de>2012-10-31 14:43:05 +0100
committerMichael Schroeder <mls@suse.de>2012-10-31 14:43:05 +0100
commit7662309186d0c0a41118d227abd9b58ce3df855b (patch)
tree7d5d66762bed61d5b1b6b8190119c2d3b9cb67be
parent084fe5bb77898536d192565c0a392561dff647b1 (diff)
downloadlibsolv-7662309186d0c0a41118d227abd9b58ce3df855b.tar.gz
libsolv-7662309186d0c0a41118d227abd9b58ce3df855b.tar.bz2
libsolv-7662309186d0c0a41118d227abd9b58ce3df855b.zip
rename SELECTION_MAYBESRC to SELECTION_SOURCE, make it just select src/nosrc packages
-rw-r--r--bindings/solv.i1
-rw-r--r--src/selection.c34
-rw-r--r--src/selection.h3
3 files changed, 30 insertions, 8 deletions
diff --git a/bindings/solv.i b/bindings/solv.i
index 556228a..f0969f4 100644
--- a/bindings/solv.i
+++ b/bindings/solv.i
@@ -720,6 +720,7 @@ typedef struct {
static const Id SELECTION_NOCASE = SELECTION_NOCASE;
static const Id SELECTION_INSTALLED_ONLY = SELECTION_INSTALLED_ONLY;
static const Id SELECTION_FLAT = SELECTION_FLAT;
+ static const Id SELECTION_SOURCE = SELECTION_SOURCE;
Selection(Pool *pool) {
Selection *s;
diff --git a/src/selection.c b/src/selection.c
index 8bd69f1..0128f80 100644
--- a/src/selection.c
+++ b/src/selection.c
@@ -157,9 +157,16 @@ selection_limit_rel(Pool *pool, Queue *selection, Id relflags, Id relevr)
for (i = j = 0; i < selection->count; i += 2)
{
Id select = selection->elements[i] & SOLVER_SELECTMASK;
+ Id id = selection->elements[i + 1];
if (select != SOLVER_SOLVABLE_NAME && select != SOLVER_SOLVABLE_PROVIDES)
continue; /* actually internal error */
- selection->elements[i + 1] = pool_rel2id(pool, selection->elements[i + 1], relevr, relflags, 1);
+ if (relflags == REL_ARCH && (relevr == ARCH_SRC || relevr == ARCH_NOSRC) && ISRELDEP(id))
+ {
+ Reldep *rd = GETRELDEP(pool, id);
+ if (rd->flags == REL_ARCH && rd->evr == ARCH_SRC)
+ id = rd->name;
+ }
+ selection->elements[i + 1] = pool_rel2id(pool, id, relevr, relflags, 1);
if (relflags == REL_ARCH)
selection->elements[i] |= SOLVER_SETARCH;
if (relflags == REL_EQ && select == SOLVER_SOLVABLE_NAME && selection->elements[i])
@@ -181,6 +188,9 @@ selection_depglob(Pool *pool, Queue *selection, const char *name, int flags)
int doglob = 0;
int globflags = 0;
+ if ((flags & SELECTION_SOURCE) != 0)
+ flags &= ~SELECTION_PROVIDES; /* sources don't provide anything */
+
if (!(flags & (SELECTION_NAME|SELECTION_PROVIDES)))
return 0;
@@ -192,7 +202,7 @@ selection_depglob(Pool *pool, Queue *selection, const char *name, int flags)
id = pool_str2id(pool, name, 0);
if (id)
{
- if ((flags & SELECTION_MAYBESRC) != 0 && (flags & SELECTION_NAME) != 0)
+ if ((flags & SELECTION_SOURCE) != 0 && (flags & SELECTION_NAME) != 0)
{
/* src rpms don't have provides, so we must check every solvable */
FOR_PROVIDES(p, pp, id) /* try fast path first */
@@ -202,6 +212,7 @@ selection_depglob(Pool *pool, Queue *selection, const char *name, int flags)
{
if ((flags & SELECTION_INSTALLED_ONLY) != 0 && s->repo != pool->installed)
continue;
+ id = pool_rel2id(pool, id, ARCH_SRC, REL_ARCH, 1);
queue_push2(selection, SOLVER_SOLVABLE_NAME, id);
return SELECTION_NAME;
}
@@ -213,6 +224,7 @@ selection_depglob(Pool *pool, Queue *selection, const char *name, int flags)
{
if ((flags & SELECTION_INSTALLED_ONLY) != 0 && s->repo != pool->installed)
continue; /* just in case... src rpms can't be installed */
+ id = pool_rel2id(pool, id, ARCH_SRC, REL_ARCH, 1);
queue_push2(selection, SOLVER_SOLVABLE_NAME, id);
return SELECTION_NAME;
}
@@ -226,6 +238,8 @@ selection_depglob(Pool *pool, Queue *selection, const char *name, int flags)
match = 1;
if (s->name == id && (flags & SELECTION_NAME) != 0)
{
+ if ((flags & SELECTION_SOURCE) != 0)
+ id = pool_rel2id(pool, id, ARCH_SRC, REL_ARCH, 1);
queue_push2(selection, SOLVER_SOLVABLE_NAME, id);
return SELECTION_NAME;
}
@@ -266,13 +280,16 @@ selection_depglob(Pool *pool, Queue *selection, const char *name, int flags)
{
Solvable *s = pool->solvables + p;
if (!pool_installable(pool, s))
- if (!(flags & SELECTION_MAYBESRC) || (s->arch != ARCH_SRC && s->arch != ARCH_NOSRC))
+ if (!(flags & SELECTION_SOURCE) || (s->arch != ARCH_SRC && s->arch != ARCH_NOSRC))
continue;
if ((flags & SELECTION_INSTALLED_ONLY) != 0 && s->repo != pool->installed)
continue;
id = s->name;
if ((doglob ? fnmatch(name, pool_id2str(pool, id), globflags) : strcasecmp(name, pool_id2str(pool, id))) == 0)
{
+ if ((flags & SELECTION_SOURCE) != 0)
+ id = pool_rel2id(pool, id, ARCH_SRC, REL_ARCH, 1);
+ /* queue_pushunique2 */
for (i = 0; i < selection->count; i += 2)
if (selection->elements[i] == SOLVER_SOLVABLE_NAME && selection->elements[i + 1] == id)
break;
@@ -326,7 +343,7 @@ selection_depglob_arch(Pool *pool, Queue *selection, const char *name, int flags
char *rname = solv_strdup(name);
rname[r - name] = 0;
if (archid == ARCH_SRC || archid == ARCH_NOSRC)
- flags |= SELECTION_MAYBESRC;
+ flags |= SELECTION_SOURCE;
if ((ret = selection_depglob(pool, selection, rname, flags)) != 0)
{
selection_limit_rel(pool, selection, REL_ARCH, archid);
@@ -353,7 +370,12 @@ selection_filelist(Pool *pool, Queue *selection, const char *name, int flags)
while (dataiterator_step(&di))
{
Solvable *s = pool->solvables + di.solvid;
- if (!s->repo || !pool_installable(pool, s))
+ if (!s->repo)
+ continue;
+ if (!pool_installable(pool, s))
+ if (!(flags & SELECTION_SOURCE) || (s->arch != ARCH_SRC && s->arch != ARCH_NOSRC))
+ continue;
+ if ((flags & SELECTION_INSTALLED_ONLY) != 0 && s->repo != pool->installed)
continue;
queue_push(&q, di.solvid);
dataiterator_skip_solvable(&di);
@@ -465,7 +487,7 @@ selection_nevra(Pool *pool, Queue *selection, const char *name, int flags)
if ((r2 = strrchr(r + 1, '.')) != 0 && r2[1] && (archid = str2archid(pool, r2 + 1)) != 0)
*r2 = 0; /* found valid arch, split it off */
if (archid == ARCH_SRC || archid == ARCH_NOSRC)
- flags |= SELECTION_MAYBESRC;
+ flags |= SELECTION_SOURCE;
/* try with just the version */
if ((ret = selection_depglob(pool, selection, rname, flags)) == 0)
diff --git a/src/selection.h b/src/selection.h
index 526f079..2a3662f 100644
--- a/src/selection.h
+++ b/src/selection.h
@@ -23,8 +23,7 @@
#define SELECTION_GLOB (1 << 9)
#define SELECTION_FLAT (1 << 10)
#define SELECTION_NOCASE (1 << 11)
-
-#define SELECTION_MAYBESRC (1 << 12) /* somewhat internal */
+#define SELECTION_SOURCE (1 << 12)
extern int selection_make(Pool *pool, Queue *selection, const char *name, int flags);
extern void selection_limit(Pool *pool, Queue *sel1, Queue *sel2);