berkshelf/berkshelf — pull request #1009 by sethvargo (2014-02-09 00:45:21+00:00)
Title: Refactor the lockfile to separate top-level dependencies from the graph

:construction:

The current lockfile implementation makes no distinction between a cookbook defined in the Berksfile and a cookbook that is a transitive dependency. This is a large problem and a major blocker for Berkshelf 3, because it's the root of all the problems caused by the current lockfile implementation.

This PR changes the format of the lockfile and divides the file into two distinct parts - the dependencies and the graph. The dependencies are the list of dependencies and their options from the Berksfile. The graph is the fully-solved graph of all dependencies, with a list of it's top-level dependencies.

This format gives us the ability to fully recreate a dependency graph without reaching out to the Interwebs. However, there are some additional refactors that need to happen to take advantage of this approach.

@reset I need some help diving into the resolver/graph pieces to figure out how to wire everything together for a better proof of concept.

Here's a sample-generated lockfile from the Jenkins cookbook:

```text
DEPENDENCIES
apt (~> 2.0)
authentication
path: ./test/fixtures/cookbooks/authentication
jenkins
path: .
jenkins_command
path: ./test/fixtures/cookbooks/jenkins_command
jenkins_credentials
path: ./test/fixtures/cookbooks/jenkins_credentials
jenkins_job
path: ./test/fixtures/cookbooks/jenkins_job
jenkins_plugin
path: ./test/fixtures/cookbooks/jenkins_plugin
jenkins_script
path: ./test/fixtures/cookbooks/jenkins_script
jenkins_slave
path: ./test/fixtures/cookbooks/jenkins_slave
jenkins_user
path: ./test/fixtures/cookbooks/jenkins_user
smoke
path: ./test/fixtures/cookbooks/smoke

GRAPH
apt (2.3.6)
authentication (0.0.0)
jenkins (>= 0.0.0)
build-essential (1.4.2)
jenkins (2.0.3)
apt (~> 2.0)
runit (~> 1.5)
yum (~> 3.0)
jenkins_command (0.0.0)
jenkins (>= 0.0.0)
jenkins_credentials (0.0.0)
jenkins (>= 0.0.0)
jenkins_job (0.0.0)
jenkins (>= 0.0.0)
jenkins_plugin (0.0.0)
jenkins (>= 0.0.0)
jenkins_script (0.0.0)
jenkins (>= 0.0.0)
jenkins_slave (0.0.0)
jenkins (>= 0.0.0)
jenkins_user (0.0.0)
jenkins (>= 0.0.0)
runit (1.5.8)
build-essential (>= 0.0.0)
yum (~> 3.0)
yum-epel (>= 0.0.0)
smoke (0.0.0)
authentication (>= 0.0.0)
jenkins_command (>= 0.0.0)
jenkins_credentials (>= 0.0.0)
jenkins_job (>= 0.0.0)
jenkins_plugin (>= 0.0.0)
jenkins_script (>= 0.0.0)
jenkins_slave (>= 0.0.0)
jenkins_user (>= 0.0.0)
yum (3.0.6)
yum-epel (0.2.0)
yum (~> 3.0)
```

I'm not sure how to map the graph back to the original dependencies and handle things like updates, etc.