Commit 7447e2d3 authored by Reto Kaiser's avatar Reto Kaiser Committed by Carlos Sanchez

Consider Puppetfile recursively in git source

parent 47ffa0a2
......@@ -13,6 +13,7 @@
* Add a User-Agent header to all requests to the GitHub API
* Convert puppet version requirements to rubygems, pessimistic and ranges
* Use librarian gem
* Consider Puppetfile-dependencies recursively in git-source
### 0.9.10
......
......@@ -49,6 +49,11 @@ This Puppetfile will download all the dependencies listed in your Modulefile fro
*See [jenkins-appliance](https://github.com/aussielunix/jenkins-appliance) for
a puppet repo already setup to use librarian-puppet.*
### Recursive module dependency resolving
When fetching a module from a `:git`-source all dependencies specified in its
`Modulefile` and `Puppetfile` will be resolved and installed.
### Puppetfile Breakdown
forge "http://forge.puppetlabs.com"
......
......@@ -67,10 +67,27 @@ module Librarian
end
def fetch_dependencies(name, version, extra)
dependencies.map do |k, v|
v = Requirement.new(v).gem_requirement
Dependency.new(k, v, forge_source)
dependencies = []
if modulefile?
metadata = ::Puppet::ModuleTool::Metadata.new
::Puppet::ModuleTool::ModulefileReader.evaluate(metadata, modulefile)
metadata.dependencies.each do |dependency|
name = dependency.instance_variable_get(:@full_module_name)
version = dependency.instance_variable_get(:@version_requirement)
gem_requirement = Requirement.new(version).gem_requirement
dependencies.push Dependency.new(name, gem_requirement, forge_source)
end
end
if specfile?
spec = environment.dsl(Pathname(specfile))
dependencies.concat spec.dependencies
end
dependencies
end
def forge_source
......@@ -89,20 +106,6 @@ module Librarian
metadata.version
end
def dependencies
return {} unless modulefile?
metadata = ::Puppet::ModuleTool::Metadata.new
::Puppet::ModuleTool::ModulefileReader.evaluate(metadata, modulefile)
metadata.dependencies.inject({}) do |h, dependency|
name = dependency.instance_variable_get(:@full_module_name)
version = dependency.instance_variable_get(:@version_requirement)
h.update(name => version)
end
end
def modulefile
File.join(filesystem_path, 'Modulefile')
end
......@@ -111,6 +114,14 @@ module Librarian
File.exists?(modulefile)
end
def specfile
File.join(filesystem_path, environment.specfile_name)
end
def specfile?
File.exists?(specfile)
end
end
end
end
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment