forked from jordansissel/fpm
-
Notifications
You must be signed in to change notification settings - Fork 0
/
rpm.rb
55 lines (48 loc) · 1.56 KB
/
rpm.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
require "fpm/package"
require "fpm/util"
class FPM::Target::Rpm < FPM::Package
def architecture
case @architecture
when nil
return %x{uname -m}.chomp # default to current arch
when "native"
return %x{uname -m}.chomp # 'native' is current arch
when "all"
# Translate fpm "all" arch to what it means in RPM.
return "noarch"
else
return @architecture
end
end # def architecture
def specfile(builddir)
"#{builddir}/#{name}.spec"
end
def url
if @url.nil? || @url.empty?
'http://nourlgiven.example.com'
else
@url
end
end
def build!(params)
raise "No package name given. Can't assemble package" if !@name
# TODO(sissel): Abort if 'rpmbuild' tool not found.
if !replaces.empty?
$stderr.puts "Warning: RPM does not support 'replaces'"
$stderr.puts "If you have suggstions as to what --replaces means to RPM"
$stderr.puts "Please let me know: https://github.com/jordansissel/fpm/issues"
end
%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"]
safesystem(*args)
Dir["#{Dir.pwd}/RPMS/**/*.rpm"].each do |path|
# This should only output one rpm, should we verify this?
safesystem("mv", path, params[:output])
end
end # def build!
end # class FPM::Target::RPM