pkg: add pkg_verify_graph() to verify the depgraph is satisfiable

feature/tap-sh
William Pitcock 2011-07-25 17:44:05 -05:00
parent 95298b4c72
commit 8100eb84f0
3 changed files with 18 additions and 1 deletions

3
main.c
View File

@ -101,6 +101,9 @@ pkg_queue_walk(pkg_queue_t *head)
world.requires = pkg_dependency_append(world.requires, pkgdep);
}
/* we should verify that the graph is complete before attempting to compute cflags etc. */
pkg_verify_graph(&world, maximum_traverse_depth);
if (want_modversion)
{
wanted_something = 0;

15
pkg.c
View File

@ -33,6 +33,18 @@ pkg_find(const char *name)
return parse_file(locbuf);
}
/*
* pkg_verify_graph(root, depth)
*
* verify the graph dependency nodes are satisfiable by walking the tree using
* pkg_traverse().
*/
void
pkg_verify_graph(pkg_t *root, int depth)
{
pkg_traverse(root, NULL, NULL, depth);
}
void
pkg_traverse(pkg_t *root,
void (*pkg_traverse_func)(pkg_t *package, void *data),
@ -64,5 +76,6 @@ pkg_traverse(pkg_t *root,
pkg_traverse(pkgdep, pkg_traverse_func, data, maxdepth - 1);
}
pkg_traverse_func(root, data);
if (pkg_traverse_func != NULL)
pkg_traverse_func(root, data);
}

1
pkg.h
View File

@ -87,6 +87,7 @@ struct pkg_ {
pkg_t *pkg_find(const char *name);
void pkg_traverse(pkg_t *root, void (*pkg_traverse_func)(pkg_t *package, void *data), void *data, int maxdepth);
void pkg_verify_graph(pkg_t *root, int depth);
/* parse.c */
pkg_t *parse_file(const char *path);