forked from jordansissel/fpm
-
Notifications
You must be signed in to change notification settings - Fork 0
/
rpm.rb
28 lines (24 loc) · 926 Bytes
/
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
require "fpm/source"
require "fpm/util"
class FPM::Source::RPM < FPM::Source
def get_metadata
@rpm = @paths.first
self[:name] = %x{rpm -q --qf '%{name}' -p #{@rpm}}.chomp
self[:version] = %x{rpm -q --qf '%{version}' -p #{@rpm}}.chomp
self[:iteration] = %x{rpm -q --qf '%{release}' -p #{@rpm}}.chomp
self[:summary] = %x{rpm -q --qf '%{summary}' -p #{@rpm}}.chomp
#self[:description] = %x{rpm -q --qf '%{description}' -p #{@rpm}}
self[:dependencies] = %x{rpm -qRp #{@rpm}}.split("\n")\
.collect { |line| line.strip }
@paths = %x{rpm -qlp #{@rpm}}.split("\n")
end
def make_tarball!(tar_path, builddir)
tmpdir = "#{tar_path}.dir"
::Dir.mkdir(tmpdir)
safesystem("rpm2cpio #{@rpm} | (cd #{tmpdir}; cpio -i --make-directories)")
tar(tar_path, ".", tmpdir)
@paths = ["."]
# TODO(sissel): Make a helper method.
safesystem(*["gzip", "-f", tar_path])
end
end