Class: FPM::Target::Rpm

Inherits:
Package show all
Defined in:
lib/fpm/target/rpm.rb

Instance Attribute Summary

Attributes inherited from Package

#architecture, #category, #dependencies, #iteration, #license, #maintainer, #name, #summary, #url, #version

Instance Method Summary collapse

Methods inherited from Package

#default_output, #generate_md5sums, #generate_specfile, #initialize, #render_spec, #template, #type

Constructor Details

This class inherits a constructor from FPM::Package

Instance Method Details

#build!(params) ⇒ Object



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/fpm/target/rpm.rb', line 8

def build!(params)
  raise "No package name given. Can't assemble package" if !@name
  %w(BUILD RPMS SRPMS SOURCES SPECS).each { |d| Dir.mkdir(d) }
  args = ["rpmbuild", "-ba", 
         "--define", "buildroot #{Dir.pwd}/BUILD",
         "--define", "_topdir #{Dir.pwd}",
         "--define", "_sourcedir #{Dir.pwd}",
         "--define", "_rpmdir #{Dir.pwd}/RPMS",
         "#{name}.spec"]
  ret = system(*args)
  if !ret
    raise "rpmbuild failed (exit code: #{$?.exitstatus})"
  end

  Dir["#{Dir.pwd}/RPMS/**/*.rpm"].each do |path|
    # This should only output one rpm, should we verify this?
    system("mv", path, params[:output])
  end

end

#specfile(builddir) ⇒ Object



4
5
6
# File 'lib/fpm/target/rpm.rb', line 4

def specfile(builddir)
  "#{builddir}/#{name}.spec"
end