mirror of
git://projects.qi-hardware.com/wernermisc.git
synced 2024-11-22 13:48:26 +02:00
qpkg: some cleanup, prerequisite search speedup
With the reduction of search depth, "prereq abiword" takes about 3 minutes on my PC. (Obviously, this can still be improved.) - gobble.c (gobble_buf): if pkg->id->value is NULL, just it as such - prereq.c (push): abort if trying to consider a package already considered or installed - prereq.c (conflicts): before being satisfied with using an installed package, make sure it really satisfies the requirement - prereq.c (conflicts): abort if an installed package conflicts - prereq.c (conflicts): added some debugging output (temporary) - prereq.c (conflicts): cut the search if we can't do better than a previous match
This commit is contained in:
parent
fe14aa01d5
commit
0ca4751b77
@ -241,7 +241,7 @@ package:
|
||||
WHITESPACE;
|
||||
pkg = alloc_type(struct pkg);
|
||||
pkg->id = ID(packages);
|
||||
pkg->more = pkg->id->value ? pkg->id->value : NULL;
|
||||
pkg->more = pkg->id->value;
|
||||
pkg->id->value = pkg;
|
||||
pkg->version = NULL;
|
||||
pkg->filename = NULL;
|
||||
|
@ -111,6 +111,7 @@ static void push(struct pkg *pkg)
|
||||
|
||||
}
|
||||
stack[n_stack++] = pkg;
|
||||
assert(!pkg->mark && !pkg->installed);
|
||||
pkg->mark = 1;
|
||||
}
|
||||
|
||||
@ -158,6 +159,7 @@ static int conflicts(const struct pkg *pkg, const struct list *conf)
|
||||
static void resolve(struct list *next_dep, const struct ref *dep,
|
||||
struct list *conf)
|
||||
{
|
||||
static int level = 0;
|
||||
struct list more_deps;
|
||||
struct list more_conf = {
|
||||
.next = conf
|
||||
@ -173,14 +175,27 @@ static void resolve(struct list *next_dep, const struct ref *dep,
|
||||
next_dep = next_dep->next;
|
||||
}
|
||||
for (pkg = dep->pkg->value; pkg; pkg = pkg->more) {
|
||||
if (best && n_stack == n_best)
|
||||
return;
|
||||
#if 0
|
||||
fprintf(stderr, "%*s", level, "");
|
||||
fprintf(stderr, "%.*s %p", ID2S(pkg->id), pkg);
|
||||
if (pkg->version)
|
||||
fprintf(stderr, " %.*s", ID2S(pkg->version));
|
||||
if (pkg->mark) fprintf(stderr, " +");
|
||||
if (pkg->installed) fprintf(stderr, " ***");
|
||||
fprintf(stderr, "\n");
|
||||
#endif
|
||||
if (!satisfies(pkg, dep))
|
||||
continue;
|
||||
if (pkg->installed || pkg->mark) {
|
||||
assert(!conflicts(pkg, conf));
|
||||
resolve(next_dep, dep->next, conf);
|
||||
continue;
|
||||
}
|
||||
if (!satisfies(pkg, dep))
|
||||
continue;
|
||||
if (conflicts(pkg, conf))
|
||||
continue;
|
||||
level++;
|
||||
push(pkg);
|
||||
more_deps.refs = pkg->depends;
|
||||
more_deps.next = next_dep;
|
||||
@ -189,6 +204,7 @@ static void resolve(struct list *next_dep, const struct ref *dep,
|
||||
resolve(&more_deps, dep->next, &more_conf);
|
||||
next_dep = more_deps.next;
|
||||
pop();
|
||||
level--;
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user