Name: <%= @name %>
Version: <%= @version %>
<% if @epoch %>
Epoch: <%= @epoch %>
<% end %>
Release: <%= @iteration or 1 %>
Summary: <%= @summary %>
BuildArch: <%= architecture %>
AutoReqProv: no

Group: <%= @category %>
<%#
TODO: [Jay] rpms require a license
let's detect it intelligently
%>
License: <%= @license %> 
Source0:  %{_sourcedir}/data.tar.gz
BuildRoot: %(mktemp -ud %{_tmppath}/%{name}-%{version}-%{release}-XXXXXX)

<% if !dependencies.empty? %>
<%
  properdeps = dependencies.collect do |d|
    # Convert gem ~> X.Y.Z to '>= X.Y.Z' and < X.Y+1.0
    if d =~ /\~>/
      name, version = d.gsub(/[()~>]/, "").split(/ +/)[0..1]
      nextversion = version.split(".").collect { |v| v.to_i }
      nextversion[1] += 1
      nextversion[2] = 0 
      nextversion = nextversion.join(".")
      ["#{name} >= #{version}", "#{name} < #{nextversion}"]
    else
      d
    end
  end
%>Requires: <%= properdeps.join(", ") %>
<% end %>
<% provides.each do |prov| %>
Provides: <%= prov %>
<% end %>

%description
<%= @summary %>

%prep
echo "PREP"
pwd
tar -zvxf %SOURCE0

%build
#noop

%install
#noop

%clean
rm -rf $RPM_BUILD_ROOT

%files
%defattr(-,root,root,-)
<%# Trim leading '.' from paths if they are './blah...' %>
<%# Also ensure paths start with '/' %>
<%= @source.paths.collect { |p| p.gsub(/^\.\//, "/").gsub(/^[^\/]/, "/\\0") }.join("\n") %>

%changelog
