On 12-12-14 12:32:03, Lars Wirzenius wrote:
Currently we are creating the build order for an artifact by computing
a dependency graph, and then doing a sort of topological sort to compute
a flat ordering of the component artifacts to build. This works, but
it could be replaced by a simple depth-first graph traversal. Doing this
would mean the code in Morph is somewhat simpler, which means it'll be
easier to change in the future, when we need to do that.
I'd like to suggest we do the following:
* BuildCommand.compute_build_order: return an artifact only
* BuildCommand.build_in_order and build_artifacts: remove
* morphlib.buildorder*.py: remove
* Add a new method BuildCommand.build_recursively, which takes an artifact
object, and recurses in depth-first order so that it builds leaves
first, then their parents, etc, by calling build_artifact. This will
guarantee things are built so that their dependencies are built first.
* BuildCommand.build: call self.build_recursively instead of build_artifacts
* morphlib/plugins/show_dependencies_plugin.py: replace use of BuildOrder
with BuildCommand.compute_build_order, and traversing the dependency
tree of the returned artifact
I thought I'd request opinions before making the code changes, since this
is somewhat invasive. However, the actual changes look like they'll be
one thing that is related and that I think we need to have is an easy
way for different parts of morph to resolve a system name into the list
of its artifacts (rootfs, kernel, meta data).
Part of that is adding workspace and system branch data structures to
morphlib so that all plugins can be made "branch-aware". Another part is
to have a method like compute_build_order() that takes a system and
returns its artifacts.
I think "return[ing] an artifact only" from compute_build_order() may be
good enoguh for building but not for scenarios like
morph deploy sd <destination> <system name>,
morph diff <system name 1> <system name 2>
morph content-manifest <system name>
(a potential command to generate a compact list of things that went into
an already built system).
When you start working on the above, please keep these use cases in
Senior Software Developer