mirror of
git://projects.qi-hardware.com/wernermisc.git
synced 2024-11-15 06:29:22 +02:00
qpkg: change prerequisite resolution order to be fully depth-first
Until now, when considering adding a package, we processed its dependencies after completing the current list of dependencies. E.g., if we had a package A that depended on B and C, B depended on D, and C depended on E, then the sequence would have been A, B, C, ... We now process the dependencies of a package immediately after considering the package, so the sequence above would become A, B, D, C, ... The advantage of the new order is that it becomes easier to follow the dependency tree, which will be beneficial for loop detection and for ordering packages by installation order. - prereq.c (resolve): change prerequisite resolution order such that the dependencies of the package being considered are processed immediately, instead of deferring them until the end of the current dependency list - prereq.c (prereq): we can now pass the list of dependencies directly, without needing a list of lists element - test/resorder: test resolution order
This commit is contained in:
parent
6c66fa6053
commit
0229051f07
@ -210,12 +210,11 @@ static void resolve(struct list *next_dep, const struct ref *dep,
|
||||
continue;
|
||||
level++;
|
||||
append_install(pkg);
|
||||
more_deps.refs = pkg->depends;
|
||||
more_deps.refs = dep->next;
|
||||
more_deps.next = next_dep;
|
||||
more_conf.refs = pkg->conflicts;
|
||||
more_conf.next = conf;
|
||||
resolve(&more_deps, dep->next, &more_conf);
|
||||
next_dep = more_deps.next;
|
||||
resolve(&more_deps, pkg->depends, &more_conf);
|
||||
backtrack();
|
||||
level--;
|
||||
}
|
||||
@ -224,13 +223,8 @@ static void resolve(struct list *next_dep, const struct ref *dep,
|
||||
|
||||
struct pkg **prereq(struct pkg *pkg)
|
||||
{
|
||||
struct list deps = {
|
||||
.refs = pkg->depends,
|
||||
.next = NULL
|
||||
};
|
||||
|
||||
/* @@@ make list of pre-existing conflicts */
|
||||
resolve(&deps, NULL, NULL);
|
||||
resolve(NULL, pkg->depends, NULL);
|
||||
free(installs);
|
||||
return best;
|
||||
}
|
||||
|
40
qpkg/test/resorder
Executable file
40
qpkg/test/resorder
Executable file
@ -0,0 +1,40 @@
|
||||
#!/bin/sh
|
||||
. ./Common
|
||||
|
||||
###############################################################################
|
||||
|
||||
qpkg "resolution order" prereq A <<EOF
|
||||
Package: A
|
||||
Version: 0
|
||||
Architecture: test
|
||||
Depends: B, C
|
||||
Filename: A
|
||||
|
||||
Package: B
|
||||
Version: 0
|
||||
Architecture: test
|
||||
Depends: D
|
||||
Filename: B
|
||||
|
||||
Package: C
|
||||
Version: 0
|
||||
Architecture: test
|
||||
Depends: E
|
||||
Filename: C
|
||||
|
||||
Package: D
|
||||
Version: 0
|
||||
Architecture: test
|
||||
Filename: D
|
||||
|
||||
Package: E
|
||||
Version: 0
|
||||
Architecture: test
|
||||
Filename: E
|
||||
EOF
|
||||
expect <<EOF
|
||||
B
|
||||
D
|
||||
C
|
||||
E
|
||||
EOF
|
Loading…
Reference in New Issue
Block a user