Permalink
Browse files

- Fix gem tar building to include only the gem install dir

- 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...
1 parent 587798b commit ce1cb5e0a7e3425bd3e817a9c8714046ee4152f1 @jordansissel committed Jan 22, 2011
Showing with 27 additions and 6 deletions.
  1. +4 −1 lib/fpm/source/gem.rb
  2. +5 −1 lib/fpm/target/rpm.rb
  3. +18 −4 templates/rpm.erb
View
@@ -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])
View
@@ -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
View
@@ -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
@@ -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.