forked from fedora-ruby/gem2rpm
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Rakefile
96 lines (75 loc) · 2.21 KB
/
Rakefile
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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
# -*- ruby -*-
require 'rubygems'
require 'rake/gempackagetask'
require 'rake/clean'
require 'rake/testtask'
# Determine the current version
PKG_NAME="gem2rpm"
SPEC_FILE="rubygem-gem2rpm.spec"
if `ruby -Ilib -rubygems ./bin/gem2rpm --version` =~ /\S+$/
CURRENT_VERSION = $&
else
CURRENT_VERSION = "0.0.0"
end
if ENV['REL']
PKG_VERSION = ENV['REL']
else
PKG_VERSION = CURRENT_VERSION
end
PKG_FILES = FileList[
'bin/**/*',
'lib/**/*',
'templates/*',
'test/**/*',
'AUTHORS',
'LICENSE',
'README',
'Rakefile',
SPEC_FILE
]
spec = Gem::Specification.new do |s|
#### Basic information.
s.name = 'gem2rpm'
s.version = PKG_VERSION
s.summary = "Generate rpm specfiles from gems"
s.description = <<-EOF
Generate source rpms and rpm spec files from a Ruby Gem.
The spec file tries to follow the gem as closely as possible
EOF
#### Dependencies and requirements.
s.files = PKG_FILES.to_a
#### Load-time details: library and application (you will need one or both).
s.require_path = 'lib' # Use these for libraries.
s.bindir = "bin" # Use these for applications.
s.executables = ["gem2rpm"]
s.default_executable = "gem2rpm"
#### Documentation and testing.
s.has_rdoc = false
s.extra_rdoc_files = ['AUTHORS', 'README', 'LICENSE']
#### Author and project details.
s.author = "David Lutterkort"
s.email = "[email protected]"
s.homepage = "http://rubyforge.org/projects/gem2rpm/"
end
Rake::GemPackageTask.new(spec) do |pkg|
pkg.need_zip = true
pkg.need_tar = true
end
CLEAN.include("pkg")
desc "Run tests by default"
task :default => [:test]
desc "Run unit tests"
Rake::TestTask.new(:test) do |t|
t.test_files = FileList['test/*.rb']
end
desc "Build (S)RPM for #{PKG_NAME}"
task :rpm => [ :package ] do |t|
system("sed -e 's/@VERSION@/#{PKG_VERSION}/' #{SPEC_FILE} > pkg/#{SPEC_FILE}")
Dir::chdir("pkg") do |dir|
dir = File::expand_path(".")
system("rpmbuild --define '_topdir #{dir}' --define '_sourcedir #{dir}' --define '_srcrpmdir #{dir}' --define '_rpmdir #{dir}' -ba #{SPEC_FILE} > rpmbuild.log 2>&1")
if $? != 0
raise "rpmbuild failed"
end
end
end