/*
- * Copyright (c) 2007, Novell Inc.
+ * Copyright (c) 2012, Novell Inc.
*
* This program is licensed under the BSD license, read LICENSE.BSD
* for further information
{
Queue q;
int i;
- if (selection->count <= 1)
+ if (selection->count <= 2)
return;
for (i = 0; i < selection->count; i += 2)
if ((selection->elements[i] & SOLVER_SELECTMASK) == SOLVER_SOLVABLE_ALL)
}
static void
-selection_limit_rel(Pool *pool, Queue *selection, Id relflags, Id relevr)
+selection_filter_rel(Pool *pool, Queue *selection, Id relflags, Id relevr)
{
int i;
+
for (i = 0; i < selection->count; i += 2)
{
Id select = selection->elements[i] & SOLVER_SELECTMASK;
}
queue_free(&q);
}
- else if (select == SOLVER_SOLVABLE_NAME && select == SOLVER_SOLVABLE_PROVIDES)
+ else if (select == SOLVER_SOLVABLE_NAME || select == SOLVER_SOLVABLE_PROVIDES)
{
/* don't stack src reldeps */
if (relflags == REL_ARCH && (relevr == ARCH_SRC || relevr == ARCH_NOSRC) && ISRELDEP(id))
if (pool->disttype == DISTTYPE_DEB)
selection->elements[i] |= SOLVER_SETEVR; /* debian can't match version only like rpm */
else
- selection->elements[i] |= strchr(pool_id2str(pool, relevr), '-') != 0 ? SOLVER_SETEVR : SOLVER_SETEV;
+ {
+ const char *rel = strrchr(pool_id2str(pool, relevr), '-');
+ if (rel && pool->disttype == DISTTYPE_HAIKU && (rel[1] < '0' || rel[1] > '9'))
+ rel = 0;
+ selection->elements[i] |= rel ? SOLVER_SETEVR : SOLVER_SETEV;
+ }
}
}
selection_prune(pool, selection);
if (s->name != name)
continue;
if (s->arch == ARCH_SRC || s->arch == ARCH_NOSRC)
- havesrc = 1;
+ {
+ if (pool_disabled_solvable(pool, s))
+ continue;
+ havesrc = 1;
+ }
else if (s->repo != pool->installed && !pool_installable(pool, s))
continue;
queue_push(&q, p);
{
if ((flags & SELECTION_INSTALLED_ONLY) != 0 && s->repo != pool->installed)
continue; /* just in case... src rpms can't be installed */
+ if (pool_disabled_solvable(pool, s))
+ continue;
if ((flags & SELECTION_SOURCE_ONLY) != 0)
id = pool_rel2id(pool, id, ARCH_SRC, REL_ARCH, 1);
queue_push2(selection, SOLVER_SOLVABLE_NAME, id);
if (doglob && (flags & SELECTION_NOCASE) != 0)
globflags = FNM_CASEFOLD;
-#if 0 /* doesn't work with selection_limit_rel yet */
+#if 0 /* doesn't work with selection_filter_rel yet */
if (doglob && !strcmp(name, "*") && (flags & SELECTION_FLAT) != 0)
{
/* can't do this for SELECTION_PROVIDES, as src rpms don't provide anything */
{
Solvable *s = pool->solvables + p;
if (s->repo != pool->installed && !pool_installable(pool, s))
- if (!(flags & SELECTION_SOURCE_ONLY) || (s->arch != ARCH_SRC && s->arch != ARCH_NOSRC))
- continue;
+ {
+ if (!(flags & SELECTION_SOURCE_ONLY) || (s->arch != ARCH_SRC && s->arch != ARCH_NOSRC))
+ continue;
+ if (pool_disabled_solvable(pool, s))
+ continue;
+ }
if ((flags & SELECTION_INSTALLED_ONLY) != 0 && s->repo != pool->installed)
continue;
id = s->name;
if ((ret = selection_depglob(pool, selection, name, flags)) != 0)
return ret;
+ if (!(flags & SELECTION_DOTARCH))
+ return 0;
/* check if there is an .arch suffix */
if ((r = strrchr(name, '.')) != 0 && r[1] && (archid = str2archid(pool, r + 1)) != 0)
{
flags |= SELECTION_SOURCE_ONLY;
if ((ret = selection_depglob(pool, selection, rname, flags)) != 0)
{
- selection_limit_rel(pool, selection, REL_ARCH, archid);
+ selection_filter_rel(pool, selection, REL_ARCH, archid);
solv_free(rname);
- return ret;
+ return ret | SELECTION_DOTARCH;
}
solv_free(rname);
}
if (!s->repo)
continue;
if (s->repo != pool->installed && !pool_installable(pool, s))
- if (!(flags & SELECTION_SOURCE_ONLY) || (s->arch != ARCH_SRC && s->arch != ARCH_NOSRC))
- continue;
+ {
+ if (!(flags & SELECTION_SOURCE_ONLY) || (s->arch != ARCH_SRC && s->arch != ARCH_NOSRC))
+ continue;
+ if (pool_disabled_solvable(pool, s))
+ continue;
+ }
if ((flags & SELECTION_INSTALLED_ONLY) != 0 && s->repo != pool->installed)
continue;
queue_push(&q, di.solvid);
if ((r = strpbrk(rname, "<=>")) != 0)
{
int nend = r - rname;
+ if (nend && *r == '=' && r[-1] == '!')
+ {
+ nend--;
+ r++;
+ rflags = REL_LT|REL_GT;
+ }
for (; *r; r++)
{
if (*r == '<')
if ((ret = selection_depglob_arch(pool, selection, rname, flags)) != 0)
{
if (rflags)
- selection_limit_rel(pool, selection, rflags, pool_str2id(pool, r, 1));
+ selection_filter_rel(pool, selection, rflags, pool_str2id(pool, r, 1));
solv_free(rname);
- return ret;
+ return ret | SELECTION_REL;
}
solv_free(rname);
return 0;
/* magic epoch promotion code, works only for SELECTION_NAME selections */
static void
-selection_limit_evr(Pool *pool, Queue *selection, char *evr)
+selection_filter_evr(Pool *pool, Queue *selection, char *evr)
{
int i, j;
Queue q;
}
queue_empty(&q);
queue_push2(&q, selection->elements[i], selection->elements[i + 1]);
- selection_limit_rel(pool, &q, REL_EQ, id);
+ selection_filter_rel(pool, &q, REL_EQ, id);
if (!q.count)
continue; /* oops, no match */
selection->elements[j] = q.elements[0];
queue_free(&q);
}
+/* match the "canonical" name of the package */
static int
-selection_nevra(Pool *pool, Queue *selection, const char *name, int flags)
+selection_canon(Pool *pool, Queue *selection, const char *name, int flags)
{
char *rname, *r, *r2;
Id archid = 0;
return 0;
}
/* is there a vaild arch? */
- if ((r2 = strchr(r, '_')) != 0 && r[1] && (archid = str2archid(pool, r + 1)) != 0)
+ if ((r2 = strrchr(r, '_')) != 0 && r[1] && (archid = str2archid(pool, r + 1)) != 0)
{
*r2 = 0; /* split off */
- selection_limit_rel(pool, selection, REL_ARCH, archid);
+ selection_filter_rel(pool, selection, REL_ARCH, archid);
}
- selection_limit_rel(pool, selection, REL_EQ, pool_str2id(pool, r, 1));
+ selection_filter_rel(pool, selection, REL_EQ, pool_str2id(pool, r, 1));
solv_free(rname);
- return ret;
+ return ret | SELECTION_CANON;
+ }
+
+ if (pool->disttype == DISTTYPE_HAIKU)
+ {
+ if ((r = strchr(name, '-')) == 0)
+ return 0;
+ rname = solv_strdup(name); /* so we can modify it */
+ r = rname + (r - name);
+ *r++ = 0;
+ if ((ret = selection_depglob(pool, selection, rname, flags)) == 0)
+ {
+ solv_free(rname);
+ return 0;
+ }
+ /* is there a vaild arch? */
+ if ((r2 = strrchr(r, '-')) != 0 && r[1] && (archid = str2archid(pool, r + 1)) != 0)
+ {
+ *r2 = 0; /* split off */
+ selection_filter_rel(pool, selection, REL_ARCH, archid);
+ }
+ selection_filter_rel(pool, selection, REL_EQ, pool_str2id(pool, r, 1));
+ solv_free(rname);
+ return ret | SELECTION_CANON;
}
if ((r = strrchr(name, '-')) == 0)
}
}
if (archid)
- selection_limit_rel(pool, selection, REL_ARCH, archid);
- selection_limit_evr(pool, selection, r + 1); /* magic epoch promotion */
+ selection_filter_rel(pool, selection, REL_ARCH, archid);
+ selection_filter_evr(pool, selection, r + 1); /* magic epoch promotion */
solv_free(rname);
- return ret;
+ return ret | SELECTION_CANON;
}
int
queue_empty(selection);
if (*name == '/' && (flags & SELECTION_FILELIST))
ret = selection_filelist(pool, selection, name, flags);
- if (!ret && (r = strpbrk(name, "<=>")) != 0)
+ if (!ret && (flags & SELECTION_REL) != 0 && (r = strpbrk(name, "<=>")) != 0)
ret = selection_rel(pool, selection, name, flags);
if (!ret)
ret = selection_depglob_arch(pool, selection, name, flags);
- if (!ret && (flags & SELECTION_NAME) != 0)
- ret = selection_nevra(pool, selection, name, flags);
+ if (!ret && (flags & SELECTION_CANON) != 0)
+ ret = selection_canon(pool, selection, name, flags);
+ if (ret && !selection->count)
+ ret = 0; /* no match -> always return zero */
if (ret && (flags & SELECTION_FLAT) != 0)
selection_flatten(pool, selection);
return ret;
}
void
-selection_limit(Pool *pool, Queue *sel1, Queue *sel2)
+selection_filter(Pool *pool, Queue *sel1, Queue *sel2)
{
int i, j, miss;
Id p, pp;