sorting which would be a result of the below algorithm looking for
strongly connected components in a directed graph. Unfortunately it's
not possible to order a directed graph with loops topologially.
- The idea here is to look for packages with no dependencies first,
- then for the packages which only depend on these packages, then
- packages which depend on these and another one. The last loop then
- collects all the rest. This is not foolproof, but it should easy
- the pain. */
+ UGLY, but we really have to make sure that "base-cygwin" and
+ "base-passwd" run first, whatever the dependency loops come up with in
+ future.
+ FIXME: Find another depnendecy mechanism which ensures this without
+ hardcoding. */
for (size_t i = 0; i < db.packages.size(); ++i)
{
packagemeta &pkg (*db.packages[i]);
- if (pkg.installed && pkg.installed.depends ()->size () == 0)
- visit (i);
+ if (pkg.installed && casecompare (pkg.name, "base-cygwin"))
+ {
+ visit (i);
+ break;
+ }
}
- /* FIXME: Is there a more elegant way to get the same? */
- size_t num_packages = 1;
- for (size_t cnt = 0; cnt < 5; ++cnt)
+ for (size_t i = 0; i < db.packages.size(); ++i)
{
- if (cnt == 3)
- num_packages = 2;
- for (size_t i = 0; i < db.packages.size(); ++i)
+ packagemeta &pkg (*db.packages[i]);
+ if (pkg.installed && casecompare (pkg.name, "base-passwd"))
{
- packagemeta &pkg (*db.packages[i]);
- if (visitOrder[i] || !pkg.installed
- || pkg.installed.depends ()->size () != num_packages)
- continue;
- for (PackageDBConnectedIterator j = db.connectedBegin ();
- j != db.connectedEnd ();
- ++j)
- {
- for (vector <vector <PackageSpecification *> *>::iterator dp
- = pkg.installed.depends ()->begin ();
- dp != pkg.installed.depends ()->end ();
- ++dp)
- for (vector <PackageSpecification *>::iterator dp2
- = (*dp)->begin (); dp2 != (*dp)->end (); ++dp2)
- if (!casecompare ((*j)->name, (*dp2)->packageName ()))
- {
- visit (i);
- goto post_conn_iterate;
- }
- }
- post_conn_iterate:
- ;
+ visit (i);
+ break;
}
}
for (size_t i = 0; i < db.packages.size(); ++i)
{
packagemeta &pkg (*db.packages[i]);
- if (pkg.installed && ! visitOrder[i])
+ if (pkg.installed && !visitOrder[i])
visit (i);
}
log (LOG_BABBLE) << "Visited: " << visited << " nodes out of "