gem2rpm 0.11.1 → 1.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +5 -5
- data/AUTHORS +1 -0
- data/README.md +21 -14
- data/bin/gem2rpm +72 -98
- data/lib/gem2rpm.rb +58 -18
- data/lib/gem2rpm/configuration.rb +172 -12
- data/lib/gem2rpm/distro.rb +11 -13
- data/lib/gem2rpm/{dependency.rb → gem/dependency.rb} +1 -1
- data/lib/gem2rpm/{format.rb → gem/format.rb} +0 -0
- data/lib/gem2rpm/{package.rb → gem/package.rb} +0 -0
- data/lib/gem2rpm/{spec_fetcher.rb → gem/spec_fetcher.rb} +1 -1
- data/lib/gem2rpm/{specification.rb → gem/specification.rb} +14 -6
- data/lib/gem2rpm/helpers.rb +2 -46
- data/lib/gem2rpm/rpm_dependency.rb +49 -0
- data/lib/gem2rpm/rpm_dependency_list.rb +60 -0
- data/lib/gem2rpm/rpm_file.rb +51 -0
- data/lib/gem2rpm/rpm_file_list.rb +55 -0
- data/lib/gem2rpm/template.rb +9 -8
- data/lib/gem2rpm/template_helpers.rb +8 -7
- data/lib/gem2rpm/test_suite.rb +46 -0
- data/templates/{fedora-21-rawhide-vagrant-plugin.spec.erb → fedora-21-25-vagrant-plugin.spec.erb} +0 -3
- data/templates/{fedora-21-rawhide.spec.erb → fedora-21-25.spec.erb} +0 -0
- data/templates/fedora-26-vagrant-plugin.spec.erb +112 -0
- data/templates/fedora-26.spec.erb +119 -0
- data/templates/fedora-27-rawhide-vagrant-plugin.spec.erb +108 -0
- data/templates/fedora-27-rawhide.spec.erb +115 -0
- metadata +24 -38
- checksums.yaml.gz.sig +0 -3
- data.tar.gz.sig +0 -0
- metadata.gz.sig +0 -2
@@ -0,0 +1,60 @@
|
|
1
|
+
require 'gem2rpm/rpm_dependency'
|
2
|
+
|
3
|
+
module Gem2Rpm
|
4
|
+
class RpmDependencyList
|
5
|
+
include Enumerable
|
6
|
+
|
7
|
+
def initialize(dependencies)
|
8
|
+
@items = dependencies.map { |r| RpmDependency.new(r) }
|
9
|
+
end
|
10
|
+
|
11
|
+
# Calls the given block once for each element in self, passing that
|
12
|
+
# element as a parameter. Returns the array itself.
|
13
|
+
# If no block is given, an Enumerator is returned.
|
14
|
+
def each
|
15
|
+
# Return Enumerator when called withoug block.
|
16
|
+
return to_enum(__callee__) unless block_given?
|
17
|
+
|
18
|
+
@items.each { |item| yield item }
|
19
|
+
end
|
20
|
+
|
21
|
+
# Returns a new array containing the items in self for which the given
|
22
|
+
# block is not true. The ordering of non-rejected elements is maintained.
|
23
|
+
# If no block is given, an Enumerator is returned instead.
|
24
|
+
def reject
|
25
|
+
# Return Enumerator when called withoug block.
|
26
|
+
return to_enum(__callee__) unless block_given?
|
27
|
+
|
28
|
+
self.class.new(@items.reject { |item| yield item })
|
29
|
+
end
|
30
|
+
|
31
|
+
# Convert to rubygem() virtual provide dependencies.
|
32
|
+
def virtualize
|
33
|
+
dep_list = self.map(&:virtualize)
|
34
|
+
|
35
|
+
self.class.new dep_list
|
36
|
+
end
|
37
|
+
|
38
|
+
# Output dependencies with RPM requires tag.
|
39
|
+
def with_requires
|
40
|
+
dep_list = self.map(&:with_requires)
|
41
|
+
|
42
|
+
self.class.new dep_list
|
43
|
+
end
|
44
|
+
|
45
|
+
# Comment out the dependency.
|
46
|
+
def comment_out
|
47
|
+
dep_list = self.map(&:comment_out)
|
48
|
+
|
49
|
+
self.class.new dep_list
|
50
|
+
end
|
51
|
+
|
52
|
+
# Returns string with all dependencies from the list converted into entries
|
53
|
+
# suitable for RPM .spec file. Thise entries should include all necessary
|
54
|
+
# macros depending on file categorization.
|
55
|
+
def to_rpm
|
56
|
+
s = entries.map(&:to_rpm).join("\n")
|
57
|
+
s += "\n" unless s.empty?
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
@@ -0,0 +1,51 @@
|
|
1
|
+
require 'pathname'
|
2
|
+
require 'gem2rpm/helpers'
|
3
|
+
|
4
|
+
module Gem2Rpm
|
5
|
+
class RpmFile < String
|
6
|
+
# Returns string with entry suitable for RPM .spec file. This typically
|
7
|
+
# includes all necessary macros depending on file categorization.
|
8
|
+
def to_rpm
|
9
|
+
config = Gem2Rpm::Configuration.instance
|
10
|
+
|
11
|
+
case
|
12
|
+
when license?
|
13
|
+
"#{config.macro_for(:license)} #{config.macro_for(:instdir)}/#{self}".strip
|
14
|
+
when doc?
|
15
|
+
"#{config.macro_for(:doc)} #{config.macro_for(:instdir)}/#{self}".strip
|
16
|
+
when ignore?
|
17
|
+
"#{config.macro_for(:ignore)} #{config.macro_for(:instdir)}/#{self}".strip
|
18
|
+
# /lib should have its own macro
|
19
|
+
when self == 'lib'
|
20
|
+
"#{config.macro_for(:libdir)}"
|
21
|
+
else
|
22
|
+
"#{config.macro_for(:instdir)}/#{self}"
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
# Returs true for documentation files.
|
27
|
+
def doc?
|
28
|
+
Helpers.check_str_on_conditions(self, Gem2Rpm::Configuration.instance.rule_for(:doc))
|
29
|
+
end
|
30
|
+
|
31
|
+
# Returns true for license files.
|
32
|
+
def license?
|
33
|
+
Helpers.check_str_on_conditions(self, Gem2Rpm::Configuration.instance.rule_for(:license))
|
34
|
+
end
|
35
|
+
|
36
|
+
# Returns true for files which should be ommited from the package.
|
37
|
+
def ignore?
|
38
|
+
Helpers.check_str_on_conditions(self, Gem2Rpm::Configuration.instance.rule_for(:ignore))
|
39
|
+
end
|
40
|
+
|
41
|
+
# Returns true for files which are part of package test suite.
|
42
|
+
def test?
|
43
|
+
Helpers.check_str_on_conditions(self, Gem2Rpm::Configuration.instance.rule_for(:test))
|
44
|
+
end
|
45
|
+
|
46
|
+
# Returns true for other known miscellaneous files.
|
47
|
+
def misc?
|
48
|
+
Helpers.check_str_on_conditions(self, Gem2Rpm::Configuration.instance.rule_for(:misc))
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
@@ -0,0 +1,55 @@
|
|
1
|
+
require 'gem2rpm/rpm_file'
|
2
|
+
|
3
|
+
module Gem2Rpm
|
4
|
+
class RpmFileList
|
5
|
+
include Enumerable
|
6
|
+
|
7
|
+
# Returns a new file list created from the array of files (e.g.
|
8
|
+
# Gem2Rpm::Specification.files).
|
9
|
+
def initialize(files)
|
10
|
+
@items = files.map { |f| RpmFile.new(f) }
|
11
|
+
end
|
12
|
+
|
13
|
+
# Calls the given block once for each element in self, passing that
|
14
|
+
# element as a parameter. Returns the array itself.
|
15
|
+
# If no block is given, an Enumerator is returned.
|
16
|
+
def each
|
17
|
+
# Return Enumerator when called withoug block.
|
18
|
+
return to_enum(__callee__) unless block_given?
|
19
|
+
|
20
|
+
@items.each { |item| yield item }
|
21
|
+
end
|
22
|
+
|
23
|
+
# Returns a new array containing the items in self for which the given
|
24
|
+
# block is not true. The ordering of non-rejected elements is maintained.
|
25
|
+
# If no block is given, an Enumerator is returned instead.
|
26
|
+
def reject
|
27
|
+
# Return Enumerator when called withoug block.
|
28
|
+
return to_enum(__callee__) unless block_given?
|
29
|
+
|
30
|
+
self.class.new(@items.reject { |item| yield item })
|
31
|
+
end
|
32
|
+
|
33
|
+
# Returns a list of top level directories and files, omit all subdirectories.
|
34
|
+
def top_level_entries
|
35
|
+
self.class.new(entries.map { |f| f.gsub!(/([^\/]*).*/, '\1') }.uniq)
|
36
|
+
end
|
37
|
+
|
38
|
+
# Returns new list of files suitable for main.
|
39
|
+
def main_entries
|
40
|
+
self.class.new(entries.delete_if { |f| (f.doc? && !f.license?) || f.misc? || f.test? })
|
41
|
+
end
|
42
|
+
|
43
|
+
# Returns new list of files suitable for -doc subpackage.
|
44
|
+
def doc_entries
|
45
|
+
self.class.new(entries.delete_if { |f| !((f.doc? && !f.license?) || f.misc? || f.test?) })
|
46
|
+
end
|
47
|
+
|
48
|
+
# Returns string with all files from the list converted into entries
|
49
|
+
# suitable for RPM .spec file. Thise entries should include all necessary
|
50
|
+
# macros depending on file categorization.
|
51
|
+
def to_rpm
|
52
|
+
entries.map(&:to_rpm).join("\n")
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
data/lib/gem2rpm/template.rb
CHANGED
@@ -25,18 +25,19 @@ module Gem2Rpm
|
|
25
25
|
# when looking for vagrant templates for example.
|
26
26
|
def self.find(name = nil, options = {})
|
27
27
|
if name.nil?
|
28
|
-
|
28
|
+
gem_file = File.basename(options[:gem_file]) if options[:gem_file]
|
29
|
+
case gem_file
|
29
30
|
when /^vagrant(-|_).*/
|
30
|
-
Gem2Rpm
|
31
|
+
Gem2Rpm.vagrant_plugin_template
|
31
32
|
else
|
32
|
-
Gem2Rpm
|
33
|
+
Gem2Rpm.rubygem_template
|
33
34
|
end
|
34
35
|
else
|
35
36
|
begin
|
36
|
-
|
37
|
+
if File.exist?(name)
|
37
38
|
Gem2Rpm::Template.new(name)
|
38
39
|
else
|
39
|
-
Gem2Rpm::Template.new(File.join(Gem2Rpm::Template
|
40
|
+
Gem2Rpm::Template.new(File.join(Gem2Rpm::Template.default_location, name + '.spec.erb'))
|
40
41
|
end
|
41
42
|
rescue TemplateError
|
42
43
|
raise TemplateError, "Could not locate template #{name}"
|
@@ -47,17 +48,17 @@ module Gem2Rpm
|
|
47
48
|
# Create instance of Template class of specified template filename.
|
48
49
|
# TemplateError is raised when the template file does not exists.
|
49
50
|
def initialize(filename)
|
50
|
-
if File.
|
51
|
+
if File.exist? filename
|
51
52
|
@filename = filename
|
52
53
|
else
|
53
|
-
|
54
|
+
fail TemplateError, "Could not locate template #{filename}"
|
54
55
|
end
|
55
56
|
end
|
56
57
|
|
57
58
|
# Read the content of the template file.
|
58
59
|
def read
|
59
60
|
@content ||= begin
|
60
|
-
File.open(@filename, OPEN_MODE
|
61
|
+
File.open(@filename, OPEN_MODE, &:read)
|
61
62
|
end
|
62
63
|
end
|
63
64
|
end
|
@@ -1,23 +1,24 @@
|
|
1
|
+
require 'gem2rpm/rpm_file_list'
|
2
|
+
require 'gem2rpm/rpm_dependency'
|
3
|
+
|
1
4
|
module Gem2Rpm
|
2
5
|
module TemplateHelpers
|
3
6
|
# File list block for the main package
|
4
7
|
def main_file_entries(spec)
|
5
|
-
entries =
|
6
|
-
entries.
|
7
|
-
Helpers.file_entries_to_rpm(entries)
|
8
|
+
entries = RpmFileList.new(spec.files).top_level_entries.main_entries
|
9
|
+
entries.to_rpm
|
8
10
|
end
|
9
11
|
|
10
12
|
# File list block for the doc sub-package
|
11
13
|
def doc_file_entries(spec)
|
12
|
-
entries =
|
13
|
-
entries.
|
14
|
-
Helpers.file_entries_to_rpm(entries)
|
14
|
+
entries = RpmFileList.new(spec.files).top_level_entries.doc_entries
|
15
|
+
entries.to_rpm
|
15
16
|
end
|
16
17
|
|
17
18
|
# Provides well formatted requirement with version.
|
18
19
|
def requirement(name, version = nil)
|
19
20
|
version = nil if version && version.to_s.empty?
|
20
|
-
|
21
|
+
RpmDependency.new(Gem::Dependency.new(name, version)).to_rpm
|
21
22
|
end
|
22
23
|
end
|
23
24
|
end
|
@@ -0,0 +1,46 @@
|
|
1
|
+
require 'gem2rpm/rpm_file_list'
|
2
|
+
|
3
|
+
module Gem2Rpm
|
4
|
+
class TestSuite
|
5
|
+
include Enumerable
|
6
|
+
|
7
|
+
TestFramework = Struct.new :name, :command
|
8
|
+
|
9
|
+
TEST_FRAMEWORKS = [
|
10
|
+
TestFramework.new('cucumber', %|cucumber|),
|
11
|
+
TestFramework.new('minitest', %|ruby -e 'Dir.glob "./test/**/*_test.rb", &method(:require)'|),
|
12
|
+
TestFramework.new('rspec', %|rspec spec|),
|
13
|
+
TestFramework.new('shindo', %|shindont|),
|
14
|
+
TestFramework.new('test-unit', %|ruby -e 'Dir.glob "./test/**/*_test.rb", &method(:require)'|),
|
15
|
+
TestFramework.new('bacon', %|bacon -a|),
|
16
|
+
].freeze
|
17
|
+
|
18
|
+
# Returns new test suite list detected from Gem::Specification.
|
19
|
+
def initialize(spec)
|
20
|
+
@items = detect_test_frameworks(spec)
|
21
|
+
end
|
22
|
+
|
23
|
+
# Calls the given block once for each element in self, passing that
|
24
|
+
# element as a parameter. Returns the array itself.
|
25
|
+
# If no block is given, an Enumerator is returned.
|
26
|
+
def each
|
27
|
+
# Return Enumerator when called withoug block.
|
28
|
+
return to_enum(__callee__) unless block_given?
|
29
|
+
|
30
|
+
@items.each { |item| yield item }
|
31
|
+
end
|
32
|
+
|
33
|
+
private
|
34
|
+
|
35
|
+
def detect_test_frameworks(spec)
|
36
|
+
from_development_dependencies(spec)
|
37
|
+
# TODO: Try to guess the test framework from spec.files. This could
|
38
|
+
# improve the test execution command a bit, but might not be reliable.
|
39
|
+
end
|
40
|
+
|
41
|
+
def from_development_dependencies(spec)
|
42
|
+
deps = spec.development_dependencies.map(&:name)
|
43
|
+
TEST_FRAMEWORKS.select { |tf| deps.include?(tf.name) }.map(&:dup)
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
data/templates/{fedora-21-rawhide-vagrant-plugin.spec.erb → fedora-21-25-vagrant-plugin.spec.erb}
RENAMED
@@ -14,9 +14,6 @@ Source0: <%= download_path %>%{vagrant_plugin_name}-%{version}.gem
|
|
14
14
|
Requires(posttrans): vagrant
|
15
15
|
Requires(preun): vagrant
|
16
16
|
Requires: vagrant
|
17
|
-
BuildRequires: ruby(release)
|
18
|
-
BuildRequires: rubygems-devel
|
19
|
-
BuildRequires: ruby
|
20
17
|
BuildRequires: vagrant
|
21
18
|
<% if spec.extensions.empty? -%>
|
22
19
|
BuildArch: noarch
|
File without changes
|
@@ -0,0 +1,112 @@
|
|
1
|
+
# Generated from <%= spec.file_name %> by gem2rpm -*- rpm-spec -*-
|
2
|
+
%global vagrant_plugin_name <%= spec.name %>
|
3
|
+
|
4
|
+
Name: %{vagrant_plugin_name}
|
5
|
+
Version: <%= spec.version %>
|
6
|
+
Release: 1%{?dist}
|
7
|
+
Summary: <%= spec.summary.gsub(/\.$/, "") %>
|
8
|
+
License: <%= spec.licenses.join(" and ") %>
|
9
|
+
<% if spec.homepage -%>
|
10
|
+
URL: <%= spec.homepage %>
|
11
|
+
<% end -%>
|
12
|
+
Source0: <%= download_path %>%{vagrant_plugin_name}-%{version}.gem
|
13
|
+
Requires: vagrant
|
14
|
+
BuildRequires: vagrant
|
15
|
+
<% if spec.extensions.empty? -%>
|
16
|
+
BuildArch: noarch
|
17
|
+
<% end -%>
|
18
|
+
Provides: vagrant(%{vagrant_plugin_name}) = %{version}
|
19
|
+
|
20
|
+
%description
|
21
|
+
<%= spec.description %>
|
22
|
+
|
23
|
+
<% if doc_subpackage -%>
|
24
|
+
%package doc
|
25
|
+
Summary: Documentation for %{name}
|
26
|
+
Requires: %{name} = %{version}-%{release}
|
27
|
+
BuildArch: noarch
|
28
|
+
|
29
|
+
%description doc
|
30
|
+
Documentation for %{name}.
|
31
|
+
<% end # if doc_subpackage -%>
|
32
|
+
|
33
|
+
%prep
|
34
|
+
gem unpack %{SOURCE0}
|
35
|
+
|
36
|
+
%setup -q -D -T -n %{vagrant_plugin_name}-%{version}
|
37
|
+
|
38
|
+
gem spec %{SOURCE0} -l --ruby > %{vagrant_plugin_name}.gemspec
|
39
|
+
|
40
|
+
%build
|
41
|
+
# Create the gem as gem install only works on a gem file
|
42
|
+
gem build %{vagrant_plugin_name}.gemspec
|
43
|
+
|
44
|
+
# %%vagrant_plugin_install compiles any C extensions and installs the gem into ./%%gem_dir
|
45
|
+
# by default, so that we can move it into the buildroot in %%install
|
46
|
+
%vagrant_plugin_install
|
47
|
+
|
48
|
+
%install
|
49
|
+
mkdir -p %{buildroot}%{vagrant_plugin_dir}
|
50
|
+
cp -a .%{vagrant_plugin_dir}/* \
|
51
|
+
%{buildroot}%{vagrant_plugin_dir}/
|
52
|
+
|
53
|
+
<% unless spec.extensions.empty? -%>
|
54
|
+
mkdir -p %{buildroot}%{vagrant_plugin_extdir_mri}
|
55
|
+
cp -a .%{vagrant_plugin_extdir_mri}/{gem.build_complete,*.so} %{buildroot}%{vagrant_plugin_extdir_mri}/
|
56
|
+
|
57
|
+
<% for ext in spec.extensions -%>
|
58
|
+
# Prevent dangling symlink in -debuginfo (rhbz#878863).
|
59
|
+
rm -rf %{buildroot}%{vagrant_plugin_instdir}/<%= ext.split(File::SEPARATOR).first %>/
|
60
|
+
<% end -%>
|
61
|
+
<% end -%>
|
62
|
+
|
63
|
+
<% unless spec.executables.empty? -%>
|
64
|
+
mkdir -p %{buildroot}%{_bindir}
|
65
|
+
cp -a .%{_bindir}/* \
|
66
|
+
%{buildroot}%{_bindir}/
|
67
|
+
|
68
|
+
find %{buildroot}%{vagrant_plugin_instdir}/<%= spec.bindir %> -type f | xargs chmod a+x
|
69
|
+
<% end -%>
|
70
|
+
|
71
|
+
%check
|
72
|
+
pushd .%{gem_instdir}
|
73
|
+
<% if tests.entries.empty? -%>
|
74
|
+
# Run the test suite.
|
75
|
+
<% end -%>
|
76
|
+
<% for t in tests -%>
|
77
|
+
# <%= t.command %>
|
78
|
+
<% end -%>
|
79
|
+
popd
|
80
|
+
|
81
|
+
<%
|
82
|
+
# Change macros for Vagrant packaging
|
83
|
+
config.macros[:instdir] = '%{vagrant_plugin_instdir}'
|
84
|
+
config.macros[:libdir] = '%{vagrant_plugin_libdir}'
|
85
|
+
-%>
|
86
|
+
%files
|
87
|
+
%dir %{vagrant_plugin_instdir}
|
88
|
+
<% for f in spec.executables -%>
|
89
|
+
%{_bindir}/<%= f %>
|
90
|
+
<% end -%>
|
91
|
+
<% unless spec.extensions.empty? -%>
|
92
|
+
%{vagrant_plugin_extdir_mri}
|
93
|
+
<% end -%>
|
94
|
+
<%= main_files.reject do |item|
|
95
|
+
spec.extensions.detect { |extension| item =~ /^#{extension.split(File::SEPARATOR).first}$/}
|
96
|
+
end.to_rpm %>
|
97
|
+
<% unless doc_subpackage -%>
|
98
|
+
%doc %{vagrant_plugin_docdir}
|
99
|
+
<%= doc_files.to_rpm %>
|
100
|
+
<% end -%>
|
101
|
+
%exclude %{vagrant_plugin_cache}
|
102
|
+
%{vagrant_plugin_spec}
|
103
|
+
|
104
|
+
<% if doc_subpackage -%>
|
105
|
+
%files doc
|
106
|
+
%doc %{vagrant_plugin_docdir}
|
107
|
+
<%= files.top_level_entries.doc_entries.to_rpm %>
|
108
|
+
<% end # if doc_subpackage -%>
|
109
|
+
|
110
|
+
%changelog
|
111
|
+
* <%= Time.now.strftime("%a %b %d %Y") %> <%= packager %> - <%= spec.version %>-1
|
112
|
+
- Initial package
|
@@ -0,0 +1,119 @@
|
|
1
|
+
# Generated from <%= spec.file_name %> by gem2rpm -*- rpm-spec -*-
|
2
|
+
%global gem_name <%= spec.name %>
|
3
|
+
|
4
|
+
Name: rubygem-%{gem_name}
|
5
|
+
Version: <%= spec.version %>
|
6
|
+
Release: 1%{?dist}
|
7
|
+
Summary: <%= spec.summary.gsub(/\.$/, "") %>
|
8
|
+
License: <%= spec.licenses.join(" and ") %>
|
9
|
+
<% if spec.homepage -%>
|
10
|
+
URL: <%= spec.homepage %>
|
11
|
+
<% end -%>
|
12
|
+
Source0: <%= download_path %>%{gem_name}-%{version}.gem
|
13
|
+
BuildRequires: ruby(release)
|
14
|
+
<% for req in spec.required_rubygems_version -%>
|
15
|
+
BuildRequires: <%= requirement 'rubygems-devel', req %>
|
16
|
+
<% end -%>
|
17
|
+
<% for req in spec.required_ruby_version -%>
|
18
|
+
BuildRequires: <%= requirement "ruby#{'-devel' unless spec.extensions.empty?}", req %>
|
19
|
+
<% end -%>
|
20
|
+
<% unless spec.extensions.empty? -%>
|
21
|
+
# Compiler is required for build of gem binary extension.
|
22
|
+
# https://fedoraproject.org/wiki/Packaging:C_and_C++#BuildRequires_and_Requires
|
23
|
+
BuildRequires: gcc
|
24
|
+
<% end -%>
|
25
|
+
<%= development_dependencies.reject do |d|
|
26
|
+
["rdoc", "rake", "bundler"].include? d.name
|
27
|
+
end.virtualize.with_requires.comment_out.to_rpm -%>
|
28
|
+
<% if spec.extensions.empty? -%>
|
29
|
+
BuildArch: noarch
|
30
|
+
<% end -%>
|
31
|
+
|
32
|
+
%description
|
33
|
+
<%= spec.description %>
|
34
|
+
|
35
|
+
<% if doc_subpackage -%>
|
36
|
+
%package doc
|
37
|
+
Summary: Documentation for %{name}
|
38
|
+
Requires: %{name} = %{version}-%{release}
|
39
|
+
BuildArch: noarch
|
40
|
+
|
41
|
+
%description doc
|
42
|
+
Documentation for %{name}.
|
43
|
+
<% end # if doc_subpackage -%>
|
44
|
+
|
45
|
+
%prep
|
46
|
+
gem unpack %{SOURCE0}
|
47
|
+
|
48
|
+
%setup -q -D -T -n %{gem_name}-%{version}
|
49
|
+
|
50
|
+
gem spec %{SOURCE0} -l --ruby > %{gem_name}.gemspec
|
51
|
+
|
52
|
+
%build
|
53
|
+
# Create the gem as gem install only works on a gem file
|
54
|
+
gem build %{gem_name}.gemspec
|
55
|
+
|
56
|
+
# %%gem_install compiles any C extensions and installs the gem into ./%%gem_dir
|
57
|
+
# by default, so that we can move it into the buildroot in %%install
|
58
|
+
%gem_install
|
59
|
+
|
60
|
+
%install
|
61
|
+
mkdir -p %{buildroot}%{gem_dir}
|
62
|
+
cp -a .%{gem_dir}/* \
|
63
|
+
%{buildroot}%{gem_dir}/
|
64
|
+
|
65
|
+
<% unless spec.extensions.empty? -%>
|
66
|
+
mkdir -p %{buildroot}%{gem_extdir_mri}
|
67
|
+
cp -a .%{gem_extdir_mri}/{gem.build_complete,*.so} %{buildroot}%{gem_extdir_mri}/
|
68
|
+
|
69
|
+
<% for ext in spec.extensions -%>
|
70
|
+
# Prevent dangling symlink in -debuginfo (rhbz#878863).
|
71
|
+
rm -rf %{buildroot}%{gem_instdir}/<%= ext.split(File::SEPARATOR).first %>/
|
72
|
+
<% end -%>
|
73
|
+
<% end -%>
|
74
|
+
|
75
|
+
<% unless spec.executables.empty? -%>
|
76
|
+
mkdir -p %{buildroot}%{_bindir}
|
77
|
+
cp -a .%{_bindir}/* \
|
78
|
+
%{buildroot}%{_bindir}/
|
79
|
+
|
80
|
+
find %{buildroot}%{gem_instdir}/<%= spec.bindir %> -type f | xargs chmod a+x
|
81
|
+
<% end -%>
|
82
|
+
|
83
|
+
%check
|
84
|
+
pushd .%{gem_instdir}
|
85
|
+
<% if tests.entries.empty? -%>
|
86
|
+
# Run the test suite.
|
87
|
+
<% end -%>
|
88
|
+
<% for t in tests -%>
|
89
|
+
# <%= t.command %>
|
90
|
+
<% end -%>
|
91
|
+
popd
|
92
|
+
|
93
|
+
%files
|
94
|
+
%dir %{gem_instdir}
|
95
|
+
<% for f in spec.executables -%>
|
96
|
+
%{_bindir}/<%= f %>
|
97
|
+
<% end -%>
|
98
|
+
<% unless spec.extensions.empty? -%>
|
99
|
+
%{gem_extdir_mri}
|
100
|
+
<% end -%>
|
101
|
+
<%= main_files.reject do |item|
|
102
|
+
spec.extensions.detect { |extension| item =~ /^#{extension.split(File::SEPARATOR).first}$/}
|
103
|
+
end.to_rpm %>
|
104
|
+
<% unless doc_subpackage -%>
|
105
|
+
%doc %{gem_docdir}
|
106
|
+
<%= doc_files.to_rpm %>
|
107
|
+
<% end -%>
|
108
|
+
%exclude %{gem_cache}
|
109
|
+
%{gem_spec}
|
110
|
+
|
111
|
+
<% if doc_subpackage -%>
|
112
|
+
%files doc
|
113
|
+
%doc %{gem_docdir}
|
114
|
+
<%= doc_files.to_rpm %>
|
115
|
+
<% end # if doc_subpackage -%>
|
116
|
+
|
117
|
+
%changelog
|
118
|
+
* <%= Time.now.strftime("%a %b %d %Y") %> <%= packager %> - <%= spec.version %>-1
|
119
|
+
- Initial package
|