Skip to content

Instantly share code, notes, and snippets.

@btm
Created August 21, 2012 21:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save btm/5332542a89c6ca14b825 to your computer and use it in GitHub Desktop.
Save btm/5332542a89c6ca14b825 to your computer and use it in GitHub Desktop.
--- chef/lib/chef/run_context.rb 2012-08-21 14:57:03.062579672 -0700
+++ /usr/lib/ruby/gems/1.8/gems/chef-10.12.0/lib/chef/run_context.rb 2012-08-21 14:55:51.676314647 -0700
@@ -47,6 +47,7 @@
@cookbook_collection = cookbook_collection
@resource_collection = Chef::ResourceCollection.new
@definitions = Hash.new
+ @seen_cookbooks = Array.new
# TODO: 5/18/2010 cw/timh - See note on Chef::Node's
# cookbook_collection attr_accessor
@@ -80,6 +81,7 @@
foreach_cookbook_load_segment(:libraries) do |cookbook_name, filename|
Chef::Log.debug("Loading cookbook #{cookbook_name}'s library file: #{filename}")
Kernel.load(filename)
+ @seen_cookbooks << cookbook_name
end
end
@@ -115,6 +117,17 @@
def foreach_cookbook_load_segment(segment, &block)
cookbook_collection.each do |cookbook_name, cookbook|
+ puts "DEBUG: #{cookbook_name} / #{segment}"
+ cookbook.metadata.dependencies.each do |dep|
+ puts "DEBUG: need #{dep}"
+ unless @seen_cookbooks.include?(dep)
+ puts "DEBUG: loading #{dep} as we haven't seen it yet"
+ segment_filenames = cookbook_collection[dep].segment_filenames(segment)
+ segment_filenames.each do |segment_filename|
+ block.call(dep, segment_filename)
+ end
+ end
+ end
segment_filenames = cookbook.segment_filenames(segment)
segment_filenames.each do |segment_filename|
block.call(cookbook_name, segment_filename)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment