Skip to content

Commit

Permalink
- Fix gem tar building to include only the gem install dir
Browse files Browse the repository at this point in the history
- Abort if rpmbuild fails so we can debug it.
- Fix dependency conversion for rpm
- Fix path prefixing so rpm accepts our list of files (rpm requires
  paths in %files section start with '/'
  • Loading branch information
jordansissel committed Jan 22, 2011
1 parent 587798b commit ce1cb5e
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 6 deletions.
5 changes: 4 additions & 1 deletion lib/fpm/source/gem.rb
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,10 @@ def make_tarball!(tar_path, builddir)
args = ["gem", "install", "--quiet", "--no-ri", "--no-rdoc",
"--install-dir", installdir, "--ignore-dependencies", @paths.first]
system(*args)
tar(tar_path, ".", tmpdir)

@paths = [ ::Gem::dir ]
tar(tar_path, ".#{@paths.first}", tmpdir)
FileUtils.rm_r(tmpdir)

# TODO(sissel): Make a helper method.
system(*["gzip", "-f", tar_path])
Expand Down
6 changes: 5 additions & 1 deletion lib/fpm/target/rpm.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@ def build!(params)
"--define", "_sourcedir #{Dir.pwd}",
"--define", "_rpmdir #{params[:output]}",
"#{name}.spec"]
system(*args)
ret = system(*args)
if !ret
raise "rpmbuild failed"
end

end
end
22 changes: 18 additions & 4 deletions templates/rpm.erb
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,22 @@ License: <%= @license %>
Source0: %{_sourcedir}/data.tar.gz
BuildRoot: %(mktemp -ud %{_tmppath}/%{name}-%{version}-%{release}-XXXXXX)

<% if @dependencies && !@dependencies.empty? %>
Requires: <%= @dependencies.join(", ") %>
<% 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 %>

%description
Expand All @@ -33,9 +47,9 @@ tar -zvxf %SOURCE0
%clean
rm -rf $RPM_BUILD_ROOT


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

%changelog

0 comments on commit ce1cb5e

Please sign in to comment.