Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

- Make rpm target work

- Get fpm -s rpm -t rpm working (should provide a useful test case)
- Allow 'output' (-p <path>) to be a directory
  • Loading branch information...
commit fb53230879e7e278e854dc1a6f7122068eb2e1e9 1 parent 675cbc7
Jordan Sissel authored
2  lib/fpm/builder.rb
View
@@ -51,7 +51,7 @@ def assemble!
output.gsub!(/VERSION/, "#{@source[:version]}-#{@source[:iteration]}")
output.gsub!(/ARCH/, @package.architecture)
- File.delete(output) if File.exists?(output)
+ File.delete(output) if File.exists?(output) && !File.directory?(output)
make_builddir!
6 lib/fpm/source/rpm.rb
View
@@ -10,12 +10,16 @@ def get_metadata
#self[:description] = %x{rpm -q --qf '%{description}' -p #{@paths.first}}
self[:dependencies] = %x{rpm -qRp #{@paths.first}}.split("\n")\
.collect { |line| line.strip }
+
+ @rpm = @paths.first
+ @paths = %x{rpm -qlp #{@paths.first}}.split("\n")
+
end
def make_tarball!(tar_path)
tmpdir = "#{tar_path}.dir"
::Dir.mkdir(tmpdir)
- system("rpm2cpio #{@paths.first} | (cd #{tmpdir}; cpio -i --make-directories)")
+ system("rpm2cpio #{@rpm} | (cd #{tmpdir}; cpio -i --make-directories)")
tar(tar_path, ".", tmpdir)
# TODO(sissel): Make a helper method.
33 lib/fpm/target/rpm.rb
View
@@ -1,28 +1,19 @@
require "fpm/package"
class FPM::Target::Rpm < FPM::Package
- def assemble(params)
- # TODO [Jay] a lot of this is duplication from deb.rb,
- # and can be factored out.
+ def specfile(builddir)
+ "#{builddir}/#{name}.spec"
+ end
+ def build!(params)
raise "No package name given. Can't assemble package" if !@name
-
- root = params['root'] || '.'
- paths = params['paths']
- output = params['output']
-
- type = "rpm"
-
- output.gsub!(/VERSION/, "#{@version}-#{@iteration}")
- output.gsub!(/ARCH/, @architecture)
-
- builddir = "#{Dir.pwd}/build-#{type}-#{File.basename(output)}"
-
- Dir.mkdir(builddir) if !File.directory?(builddir)
-
- Dir.chdir root do
- tar("#{builddir}/data.tar", paths)
- system(*["gzip", "-f", "#{builddir}/data.tar"])
- end
+ Dir.mkdir("BUILD")
+ args = ["rpmbuild", "-ba",
+ "--define", "buildroot #{Dir.pwd}/BUILD",
+ "--define", "_topdir #{Dir.pwd}",
+ "--define", "_sourcedir #{Dir.pwd}",
+ "--define", "_rpmdir #{params[:output]}",
+ "#{name}.spec"]
+ system(*args)
end
end
11 templates/rpm.erb
View
@@ -1,6 +1,3 @@
-# eruby_subtype=spec
-%define rbname <%= spec.name %>
-
Name: <%= @name %>
Version: <%= @version %>
Release: <%= @iteration %>
@@ -15,13 +12,17 @@ License: <%= @license %>
Source0: %{_sourcedir}/data.tar.gz
BuildRoot: %(mktemp -ud %{_tmppath}/%{name}-%{version}-%{release}-XXXXXX)
+<% if @dependencies && !@dependencies.empty? %>
Requires: <%= @dependencies.join(", ") %>
+<% end %>
%description
<%= @summary %>
%prep
-#noop
+echo "PREP"
+pwd
+tar -zvxf %SOURCE0
%build
#noop
@@ -35,6 +36,6 @@ rm -rf $RPM_BUILD_ROOT
%files
%defattr(-,root,root,-)
-<%= paths %>
+<%= @source.paths.join("\n") %>
%changelog
Please sign in to comment.
Something went wrong with that request. Please try again.