rpgem 0.1.1 → 0.1.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (4) hide show
  1. data/bin/rpgem +17 -7
  2. data/lib/rpgem.rb +15 -7
  3. data/lib/template.spec.erb +24 -15
  4. metadata +4 -4
data/bin/rpgem CHANGED
@@ -64,21 +64,31 @@ begin
64
64
 
65
65
  opts.on('-d DEPENDS',
66
66
  '--depends DEPENDS',
67
- 'Specify a non-gem dependency (e.g. mysql-devel, etc.)'
67
+ 'Specify a non-gem dependency (e.g. mysql, etc.)'
68
68
  ) do |d|
69
69
  options[:dependencies] ||= []
70
70
  options[:dependencies] << d
71
71
  end
72
+
73
+ opts.on('-B BD',
74
+ '--build-dependency BD',
75
+ 'Specify a build dependency (e.g. mysql-devel)'
76
+ ) do |bd|
77
+ options[:build_dependencies] ||= []
78
+ options[:build_dependencies] << bd
79
+ end
80
+
81
+ opts.on('-E',
82
+ '--ree',
83
+ 'Use Ruby Enterprise Edition'
84
+ ) do
85
+ options[:ree] = true
86
+ end
72
87
  end.parse!
73
88
 
74
89
  options.rmerge!({
75
- :version => nil,
76
90
  :recursive => false,
77
- :version_reqs => [],
78
- :action => :build!,
79
- :ruby_cmd => "ruby",
80
- :prefix => '/usr',
81
- :dependencies => []
91
+ :action => :build!
82
92
  })
83
93
 
84
94
  p [options, ARGV]
data/lib/rpgem.rb CHANGED
@@ -49,13 +49,17 @@ class RPGem
49
49
 
50
50
  def initialize(name, options={})
51
51
  @name = name
52
- @options = options.rmerge({
52
+ @options = options.rmerge!({
53
53
  :version => nil,
54
- :version_reqs => [],
55
54
  :recursive => false,
55
+ :version_reqs => [],
56
56
  :ruby_cmd => "ruby",
57
- :dependencies => []
57
+ :prefix => '/usr',
58
+ :dependencies => [],
59
+ :build_dependencies => [],
60
+ :ree => false
58
61
  })
62
+
59
63
  @options.each do |k,v|
60
64
  instance_variable_set("@#{k}", v)
61
65
  end
@@ -139,7 +143,7 @@ class RPGem
139
143
  end
140
144
 
141
145
  def make_spec!
142
- puts "rendering the specfile..."
146
+ puts "Rendering specfile for #{self.to_s}"
143
147
  template = File.read("#{LIB_DIR}/template.spec.erb")
144
148
  specfile = ERB.new(template).result(binding)
145
149
  puts "rendered:"
@@ -152,11 +156,12 @@ class RPGem
152
156
 
153
157
  def build!
154
158
  make_spec!
155
- puts "-*- Building RPM -*-"
159
+ puts
160
+ puts "-*- Building RPM rpgem-#{self.to_s} -*-"
156
161
  FileUtils.in_dir RPMBUILD_DIR do
157
162
  system("rpmbuild -ba #{spec_loc}")
158
163
  end
159
- puts "-*- Done Building RPM -*-"
164
+ puts "-*- Done Building RPM rpgem-#{self.to_s} -*-"
160
165
  end
161
166
 
162
167
  def recurse!(action=:setup!)
@@ -164,10 +169,13 @@ class RPGem
164
169
  #TODO: don't choke on circular dependencies
165
170
  deps = self.spec.runtime_dependencies
166
171
  deps.each do |d|
172
+ puts
173
+ puts "#{self.to_s} depends on #{d.name}"
167
174
  g = self.class.new(d.name,
168
175
  :version_reqs => d.requirements_list,
169
176
  :recursive => true,
170
- :ruby_cmd => @ruby_cmd
177
+ :prefix => @prefix,
178
+ :ree => @ree
171
179
  )
172
180
  g.fetch!
173
181
  g.recurse!(action)
@@ -8,6 +8,18 @@
8
8
  v == ">= 0" ? "" : " #{v}"
9
9
  end
10
10
 
11
+ ruby = @ree ? "ruby-enterprise" : "ruby"
12
+ rubygems = @ree ? "ruby-enterprise-rubygems" : "rubygems"
13
+
14
+ requires = "#{ruby}#{ruby_ver}, #{rubygems}#{rubygems_ver}#{
15
+ (spec.runtime_dependencies.map do |d|
16
+ ", rpgem-#{d.name} #{d.requirements_list.first.gsub(/~>/,'>=')}"
17
+ end.join + @dependencies.map do |d|
18
+ ", #{d}"
19
+ end.join)
20
+ }"
21
+ build_requires = "ruby#{ruby_ver}, rubygems#{rubygems_ver}" +
22
+ (@dependencies + @build_dependencies).map { |d| ", #{d}"}.join
11
23
  %>
12
24
  %define rbname <%= spec.name %>
13
25
 
@@ -17,24 +29,18 @@ Release: 1%{?dist}
17
29
  Summary: <%= spec.summary || spec.description %>
18
30
 
19
31
  Group: Development/Languages/Ruby
20
- License: <%= spec.license || "#FIXME - this gem has an unspecified license!" %>
21
- URL: <%= spec.homepage %>
32
+ License: <%= spec.license || "#FIXME - this gem has an unspecified license" %>
33
+ <%= "Url: #{spec.homepage}" unless spec.homepage.empty? %>
22
34
  Source0: %{_sourcedir}/%{rbname}-%{version}.gem
23
35
  BuildRoot: %(mktemp -ud %{_tmppath}/%{name}-%{version}-%{release}-XXXXXX)
24
- Vendor: <%= spec.author %>
25
-
26
- BuildRequires: ruby<%=ruby_ver%>, rubygems<%=rubygems_ver%>
27
- Requires: ruby<%=ruby_ver%>, rubygems<%=rubygems_ver%><%=
28
- spec.runtime_dependencies.map do |d|
29
- ", rpgem-#{d.name} #{d.requirements_list.first.gsub(/~>/,'>=')}"
30
- end.join
31
- %><%=
32
- @dependencies.map {|d| ", #{d}"}.join
33
- %>
36
+ <%= "Vendor: #{spec.author}" unless spec.author.empty? %>
37
+
38
+ BuildRequires: <%= build_requires %>
39
+ Requires: <%= requires %>
34
40
 
35
41
  Prefix: <%=@prefix%>
36
42
 
37
- %define gem_prefix %{prefix}/lib/gems/%(%{prefix}/bin/ruby -e "puts VERSION.split('.')[0..1].join('.')")
43
+ %define gem_prefix %{prefix}/lib/ruby/gems/%(%{prefix}/bin/ruby -e "puts VERSION.split('.')[0..1].join('.')")
38
44
 
39
45
  %description
40
46
  <%= spec.description %>
@@ -45,14 +51,17 @@ Prefix: <%=@prefix%>
45
51
  %build
46
52
  rm -rf $RPM_BUILD_ROOT
47
53
  mkdir $RPM_BUILD_ROOT
48
- %{prefix}/bin/gem install %{SOURCE0} --force --local --no-rdoc --no-ri --install-dir=.
54
+ gem install %{SOURCE0} --force --local --no-rdoc --no-ri --install-dir=.
49
55
 
50
56
  %install
51
57
 
52
- echo %{gem_prefix}
53
58
  rm -rf $RPM_BUILD_ROOT%{gem_prefix}
54
59
  mkdir -p $RPM_BUILD_ROOT%{gem_prefix}
55
60
  mv * $RPM_BUILD_ROOT%{gem_prefix}
61
+
62
+ #remove test and spec files, or RPM throws a fit.
63
+ rm -rf $RPM_BUILD_ROOT%{gem_prefix}/gems/%{rbname}-%{version}/{test,spec}
64
+
56
65
  chmod -R 0755 $RPM_BUILD_ROOT%{gem_prefix}
57
66
 
58
67
  %clean
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rpgem
3
3
  version: !ruby/object:Gem::Version
4
- hash: 25
4
+ hash: 31
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 1
9
- - 1
10
- version: 0.1.1
9
+ - 2
10
+ version: 0.1.2
11
11
  platform: ruby
12
12
  authors:
13
13
  - Jay Adkisson
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2010-05-17 00:00:00 -07:00
18
+ date: 2010-05-18 00:00:00 -07:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency