Skip to content

Commit

Permalink
render templates in the context of the package, not the source
Browse files Browse the repository at this point in the history
This allows things like debs referring to x86_64 as amd64
to be in the Deb class.
  • Loading branch information
jneen committed Jan 6, 2011
1 parent bd055be commit 8722e99
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 11 deletions.
9 changes: 3 additions & 6 deletions lib/fpm/builder.rb
Expand Up @@ -22,11 +22,6 @@ def garbage
@garbage ||= []
end

# the spec or control file
def spec
@spec ||= @source.render(@package.template)
end

attr_reader :paths
attr_reader :package
attr_reader :source
Expand Down Expand Up @@ -113,7 +108,9 @@ def cleanup!
end

def generate_specfile
File.open(@package.specfile(builddir), "w") { |f| f.puts spec }
File.open(@package.specfile(builddir), "w") do |f|
f.puts @package.render_spec
end
end

def generate_md5sums
Expand Down
4 changes: 4 additions & 0 deletions lib/fpm/package.rb
Expand Up @@ -82,6 +82,10 @@ def template
end
end

def render_spec
template.result(binding)
end

def default_output
"#{name}-#{version}-#{iteration}.#{architecture}.#{type}"
end
Expand Down
5 changes: 0 additions & 5 deletions lib/fpm/source.rb
Expand Up @@ -66,11 +66,6 @@ def package(pkg_cls)
pkg_cls.new(self)
end

# make the binding public for erb templating
def render(template)
template.result(binding)
end

private
def tar(output, paths)
dirs = []
Expand Down

0 comments on commit 8722e99

Please sign in to comment.