From: Michael Schroeder Date: Thu, 16 Nov 2017 13:20:33 +0000 (+0100) Subject: Special case marchdeps filtering on a repo or all packages. X-Git-Tag: 0.6.31~25 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=243310ff42693159e4440647127a06a4a55aaffd;p=thirdparty%2Flibsolv.git Special case marchdeps filtering on a repo or all packages. --- diff --git a/src/selection.c b/src/selection.c index e9ef3b53..1fdaa46b 100644 --- a/src/selection.c +++ b/src/selection.c @@ -1202,14 +1202,10 @@ setup_limiter(Pool *pool, int flags, struct limiter *limiter) limiter->repofilter = 0; if ((flags & SELECTION_INSTALLED_ONLY) != 0) { - if (!pool->installed) - limiter->end = 0; - else - { - limiter->repofilter = pool->installed; - limiter->start = pool->installed->start; - limiter->end = pool->installed->end; - } + Repo *repo = pool->installed; + limiter->repofilter = repo; + limiter->start = repo ? repo->start : 0; + limiter->end = repo ? repo->end : 0; } } @@ -1455,7 +1451,23 @@ selection_make_matchdeps_common(Pool *pool, Queue *selection, const char *name, Queue q, qlimit; queue_init(&q); queue_init(&qlimit); - if ((flags & SELECTION_MODEBITS) == SELECTION_SUBTRACT || (flags & SELECTION_MODEBITS) == SELECTION_FILTER) + /* deal with special filter cases */ + if ((flags & SELECTION_MODEBITS) == SELECTION_FILTER && selection->count == 2 && limiter.end) + { + if ((selection->elements[0] & SOLVER_SELECTMASK) == SOLVER_SOLVABLE_ALL) + flags = (flags & ~SELECTION_MODEBITS) | SELECTION_REPLACE; + else if ((selection->elements[0] & SOLVER_SELECTMASK) == SOLVER_SOLVABLE_REPO) + { + Repo *repo = pool_id2repo(pool, selection->elements[1]); + if (limiter.repofilter && repo != limiter.repofilter) + repo = 0; + limiter.repofilter = repo; + limiter.start = repo ? repo->start : 0; + limiter.end = repo ? repo->end : 0; + flags = (flags & ~SELECTION_MODEBITS) | SELECTION_REPLACE; + } + } + if (limiter.end && ((flags & SELECTION_MODEBITS) == SELECTION_SUBTRACT || (flags & SELECTION_MODEBITS) == SELECTION_FILTER)) { selection_solvables(pool, selection, &qlimit); limiter.start = 0; @@ -1468,8 +1480,21 @@ selection_make_matchdeps_common(Pool *pool, Queue *selection, const char *name, selection_add(pool, selection, &q); else if ((flags & SELECTION_MODEBITS) == SELECTION_SUBTRACT) selection_subtract(pool, selection, &q); + else if ((flags & SELECTION_MODEBITS) == SELECTION_FILTER) + { + if (ret || !(flags & SELECTION_FILTER_KEEP_IFEMPTY)) + selection_filter(pool, selection, &q); + } else if (ret || !(flags & SELECTION_FILTER_KEEP_IFEMPTY)) - selection_filter(pool, selection, &q); + { + /* special filter case from above */ + int i; + Id f = selection->elements[0] & ~(SOLVER_SELECTMASK|SOLVER_NOAUTOSET); /* job, jobflags, setflags */ + queue_free(selection); + queue_init_clone(selection, &q); + for (i = 0; i < selection->count; i += 2) + selection->elements[i] = (selection->elements[i] & (SOLVER_SELECTMASK | SOLVER_SETMASK)) | f; + } queue_free(&q); return ret; } diff --git a/src/selection.h b/src/selection.h index c809d553..8fe2d794 100644 --- a/src/selection.h +++ b/src/selection.h @@ -31,10 +31,10 @@ extern "C" { /* string comparison modifiers */ #define SELECTION_GLOB (1 << 9) -#define SELECTION_FLAT (1 << 10) #define SELECTION_NOCASE (1 << 11) /* extra flags */ +#define SELECTION_FLAT (1 << 10) /* flatten the resulting selection */ #define SELECTION_SKIP_KIND (1 << 14) /* remove kind: name prefix in SELECTION_NAME matches */ #define SELECTION_MATCH_DEPSTR (1 << 15) /* match dep2str result */