gem2rpm 0.10.1 → 0.11.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/AUTHORS +17 -8
- data/README.md +122 -0
- data/bin/gem2rpm +6 -14
- data/lib/gem2rpm/configuration.rb +55 -0
- data/lib/gem2rpm/distro.rb +54 -31
- data/lib/gem2rpm/helpers.rb +51 -0
- data/lib/gem2rpm/specification.rb +4 -1
- data/lib/gem2rpm/template.rb +64 -0
- data/lib/gem2rpm/template_helpers.rb +23 -0
- data/lib/gem2rpm.rb +23 -10
- data/templates/{fedora-19-21.spec.erb → fedora-19-20.spec.erb} +0 -0
- data/templates/fedora-21-rawhide-vagrant-plugin.spec.erb +123 -0
- data/templates/fedora-21-rawhide.spec.erb +6 -11
- data/templates/pld.spec.erb +92 -0
- metadata +19 -13
- data/README +0 -105
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0e853558c4d17632fc6eff4d64b1917c7f07c5f8
|
4
|
+
data.tar.gz: bdbc295c35e951f0021397087b9bd6e094b67444
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 44b51cfa1e4e131254cef25cfb4c35355c22ddf68150450893821a01d07cb1bb1ef1ec0821c1a3c1f7080e2e079bf73633ee708f1a7d6c117fd79448d666b01e
|
7
|
+
data.tar.gz: 3384aa940e54ab4cb438fd2fdc3cf1a7b72c4a3a2f557b48e679b6d4aa81c137bb6d2b1ba2eb39f13bb7c7bda627f7115b597337ca4ea2b8abe61efc411c89a9
|
data/AUTHORS
CHANGED
@@ -3,16 +3,25 @@ gem2rpm Authors
|
|
3
3
|
|
4
4
|
Initiated and maintained by:
|
5
5
|
|
6
|
-
David Lutterkort
|
6
|
+
David Lutterkort lutter@watzmann.net
|
7
7
|
|
8
8
|
Maintained by:
|
9
|
-
Vít Ondruch
|
9
|
+
Vít Ondruch vondruch at gmail dot com
|
10
|
+
Josef Strzibny strzibny at strzibny.name
|
10
11
|
|
11
12
|
Patches from:
|
12
13
|
|
13
|
-
Brian Candler
|
14
|
-
Josh Kelley
|
15
|
-
Paul Nasrat
|
16
|
-
Chris Ess
|
17
|
-
Matthew Kent
|
18
|
-
Michal Fojtík
|
14
|
+
Brian Candler B.Candler at pobox dot com
|
15
|
+
Josh Kelley joshkel at gmail dot com
|
16
|
+
Paul Nasrat pauln at truemesh.com
|
17
|
+
Chris Ess caess at ithiriel.com
|
18
|
+
Matthew Kent mattkent at rubyforge.com
|
19
|
+
Michal Fojtík mi at mifo dot sk
|
20
|
+
Elan Ruusamäe glen at delfi.ee
|
21
|
+
Achilleas Pipinellis axilleas at archlinux.gr
|
22
|
+
Russell Harrison rharriso at redhat.com
|
23
|
+
Nicolas Dupeux nicolas.dupeux at arkea.com
|
24
|
+
Ken Dreyer ktdreyer at ktdreyer.com
|
25
|
+
Bohuslav Kabrda bkabrda@redhat.com
|
26
|
+
Saleem Ansari tuxdna@gmail.com
|
27
|
+
Sergio Rubio rubiojr@frameos.org
|
data/README.md
ADDED
@@ -0,0 +1,122 @@
|
|
1
|
+
[![Build Status](https://travis-ci.org/fedora-ruby/gem2rpm.svg?branch=master)](https://travis-ci.org/fedora-ruby/gem2rpm)
|
2
|
+
|
3
|
+
# gem2rpm
|
4
|
+
|
5
|
+
gem2rpm converts RubyGems packages to RPM spec files.
|
6
|
+
|
7
|
+
## Installation
|
8
|
+
|
9
|
+
You can install gem2rpm as any other gem from RubyGems.org:
|
10
|
+
|
11
|
+
```
|
12
|
+
$ gem install gem2rpm
|
13
|
+
```
|
14
|
+
|
15
|
+
or download gem2rpm from Fedora repositories as RPM package:
|
16
|
+
|
17
|
+
```
|
18
|
+
# yum install rubygem-gem2rpm
|
19
|
+
```
|
20
|
+
|
21
|
+
## Usage
|
22
|
+
|
23
|
+
Run `gem2rpm --help` to see all of the options.
|
24
|
+
|
25
|
+
At its simplest, download a gem (let's call it GEM) in its latest
|
26
|
+
version (e.g. 1.2.3):
|
27
|
+
|
28
|
+
```
|
29
|
+
$ gem fetch GEM
|
30
|
+
```
|
31
|
+
|
32
|
+
and run gem2rpm:
|
33
|
+
|
34
|
+
```
|
35
|
+
$ gem2rpm GEM-1.2.3.gem
|
36
|
+
```
|
37
|
+
|
38
|
+
You can also use the `--fetch` flag to fetch the (latest) gem before generating the spec file, achieving the same effect as running 'gem fetch GEM' plus 'gem2rpm GEM-1.2.3.gem':
|
39
|
+
|
40
|
+
```
|
41
|
+
$ gem2rpm --fetch GEM
|
42
|
+
```
|
43
|
+
|
44
|
+
This will print an rpm spec file based on the information contained in the gem's spec file. In general, it is necessary to edit the generated spec file because the gem is missing some important information that is
|
45
|
+
customarily provided in rpm's, most notably the license and the changelog.
|
46
|
+
|
47
|
+
|
48
|
+
Rather than editing the generated specfile, edit the template from which
|
49
|
+
the specfile is generated. This will make it easier to update the RPM when a new version of the Gem becomes available.
|
50
|
+
|
51
|
+
To support this process, it is recommended to first save the default
|
52
|
+
template somewhere:
|
53
|
+
|
54
|
+
```
|
55
|
+
$ gem2rpm -T > rubygem-GEM.spec.template
|
56
|
+
```
|
57
|
+
|
58
|
+
Now you can edit the template and then run gem2rpm to generate the spec file using the edited template:
|
59
|
+
|
60
|
+
```
|
61
|
+
$ gem2rpm -t rubygem-GEM.spec.template > rubygem-GEM.spec
|
62
|
+
```
|
63
|
+
|
64
|
+
With this new template you can now build your RPM as usual and when a new version of the gem becomes available, you just edit the saved template and rerun gem2rpm over it.
|
65
|
+
|
66
|
+
## Templates
|
67
|
+
|
68
|
+
The template is a standard ERB file that comes with three main variables:
|
69
|
+
|
70
|
+
- `package` - the `Gem::Package` for the gem
|
71
|
+
- `spec` - the `Gem::Specification` for the gem (the same as `format.spec`)
|
72
|
+
- `config` - the `Gem2Rpm::Configuration` that can redefine default macros or rules used in `spec` template helpers
|
73
|
+
|
74
|
+
The following variables still work, but are now deprecated:
|
75
|
+
|
76
|
+
- `format` - The `Gem::Format` for the gem. Please note that this is kept just for compatibility reasons, since RubyGems 2.0 removed this class.
|
77
|
+
|
78
|
+
### Template Configuration
|
79
|
+
|
80
|
+
To make the templates lighter and more complete, Gem2Rpm introduced in version 0.11.0 new configurable `spec` helpers such as `spec.main_file_entries` or `spec.doc_file_entries` that can be further configured via local `config` variable as follows:
|
81
|
+
|
82
|
+
```ruby
|
83
|
+
# Change macros for Vagrant packaging
|
84
|
+
config.macros[:instdir] = '%{vagrant_plugin_instdir}'
|
85
|
+
config.macros[:libdir] = '%{vagrant_plugin_libdir}'
|
86
|
+
|
87
|
+
# Change what files go to the -doc sub-package
|
88
|
+
config.rules[:doc] = [/\/?doc(\/.*)?/]
|
89
|
+
|
90
|
+
```
|
91
|
+
|
92
|
+
To see all the defaults that can be changed (from https://github.com/fedora-ruby/gem2rpm/blob/master/lib/gem2rpm/configuration.rb):
|
93
|
+
|
94
|
+
```ruby
|
95
|
+
$ irb -rgem2rpm
|
96
|
+
> Gem2Rpm::Configuration::DEFAULT_MACROS
|
97
|
+
> Gem2Rpm::Configuration::DEFAULT_RULES
|
98
|
+
```
|
99
|
+
|
100
|
+
## Conventions
|
101
|
+
|
102
|
+
A typical source RPM for a gem should consist of three files: the gem file
|
103
|
+
itself, the template for the spec file and the spec file. To ensure that
|
104
|
+
the template will be included in the source RPM, it must be listed as one
|
105
|
+
of the sources in the spec file.
|
106
|
+
|
107
|
+
The resulting RPMs should follow the naming convention 'rubygem-$GEM'
|
108
|
+
where GEM is the name of the packaged gem. The default template also makes
|
109
|
+
sure that the resulting package provides 'ruby($GEM)', according to general
|
110
|
+
packaging conventions for scripting languages.
|
111
|
+
|
112
|
+
## Limitiations
|
113
|
+
|
114
|
+
Because of the differences between the two packaging schemes, it is impossible to come up with a completely automated way of doing the conversion, but the spec files produced by this package should be good enough for most pure-ruby gems.
|
115
|
+
|
116
|
+
## See also
|
117
|
+
|
118
|
+
Fedora ruby and rubygem packaging guidelines:
|
119
|
+
- http://fedoraproject.org/wiki/Packaging/Ruby
|
120
|
+
|
121
|
+
Project website
|
122
|
+
- https://github.com/fedora-ruby/gem2rpm
|
data/bin/gem2rpm
CHANGED
@@ -66,23 +66,15 @@ opts.separator("")
|
|
66
66
|
|
67
67
|
rest = opts.permute(ARGV)
|
68
68
|
|
69
|
-
template =
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
f = open(template_file, "r") if File.exists?(template_file)
|
75
|
-
f = open(File.join(Gem2Rpm.template_dir, template_file + '.spec.erb'), "r") unless f
|
76
|
-
rescue Errno::ENOENT
|
77
|
-
$stderr.puts "Could not open template #{template_file}. Aborting"
|
78
|
-
exit(1)
|
79
|
-
end
|
80
|
-
template = f.read
|
81
|
-
f.close
|
69
|
+
template = begin
|
70
|
+
Gem2Rpm::Template.find template_file, :gem_file => rest[0]
|
71
|
+
rescue Gem2Rpm::Template::TemplateError
|
72
|
+
$stderr.puts "Could not open template #{template_file}. Aborting"
|
73
|
+
exit(1)
|
82
74
|
end
|
83
75
|
|
84
76
|
if print_template_file
|
85
|
-
puts template
|
77
|
+
puts template.read
|
86
78
|
exit 0
|
87
79
|
end
|
88
80
|
|
@@ -0,0 +1,55 @@
|
|
1
|
+
require 'singleton'
|
2
|
+
|
3
|
+
module Gem2Rpm
|
4
|
+
class Configuration
|
5
|
+
include Singleton
|
6
|
+
|
7
|
+
# The defaults should mostly work
|
8
|
+
DEFAULT_MACROS = {
|
9
|
+
:instdir => '%{gem_instdir}',
|
10
|
+
:libdir => '%{gem_libdir}',
|
11
|
+
:doc => '%doc',
|
12
|
+
:license => '%license',
|
13
|
+
:ignore => '%exclude'
|
14
|
+
}
|
15
|
+
|
16
|
+
DEFAULT_RULES = {
|
17
|
+
:doc => [/\/?CHANGELOG.*/i, /\/?CONTRIBUTING.*/i, /\/?CONTRIBUTORS.*/i,
|
18
|
+
/\/?AUTHORS.*/i,/\/?README.*/i, /\/?History.*/i, /\/?Release.*/i,
|
19
|
+
/\/?doc(\/.*)?/, 'NEWS'],
|
20
|
+
:license => [/\/?MIT/, /\/?GPLv[0-9]+/, /\/?.*LICEN(C|S)E/, /\/?COPYING/],
|
21
|
+
:ignore => ['.gemtest', '.gitignore', '.travis.yml', '.yardopts', '.rvmrc',
|
22
|
+
'.rubocop.yml', /^\..*rc$/i],
|
23
|
+
# Other files including test files that are not required for
|
24
|
+
# runtime and therefore currently included in -doc
|
25
|
+
:misc => [/.*.gemspec/, /Gemfile.*/, 'Rakefile', 'rakefile.rb', 'Vagrantfile',
|
26
|
+
/^spec.*/, /^rspec.*/, /^test(s|)/, /^examples.*/]
|
27
|
+
}
|
28
|
+
|
29
|
+
# Set the configuration back to default
|
30
|
+
def to_default
|
31
|
+
@_macros = nil
|
32
|
+
@_rules = nil
|
33
|
+
self
|
34
|
+
end
|
35
|
+
|
36
|
+
# Hash with macros for files categories
|
37
|
+
def macros
|
38
|
+
@_macros ||= DEFAULT_MACROS.dup
|
39
|
+
end
|
40
|
+
|
41
|
+
# Hash with rules for file categorization
|
42
|
+
def rules
|
43
|
+
@_rules ||= DEFAULT_RULES.dup
|
44
|
+
end
|
45
|
+
|
46
|
+
def macro_for(category)
|
47
|
+
macros[category] ||= ''
|
48
|
+
end
|
49
|
+
|
50
|
+
def rule_for(category)
|
51
|
+
rules[category] ||= ''
|
52
|
+
end
|
53
|
+
|
54
|
+
end
|
55
|
+
end
|
data/lib/gem2rpm/distro.rb
CHANGED
@@ -1,52 +1,76 @@
|
|
1
1
|
module Gem2Rpm
|
2
2
|
class Distro
|
3
3
|
FEDORA = :fedora
|
4
|
+
PLD = :pld
|
4
5
|
OPENSUSE = :opensuse
|
5
6
|
DEFAULT = :default
|
6
7
|
|
7
|
-
|
8
|
-
if Object.const_defined? :Encoding
|
9
|
-
'r:UTF-8'
|
10
|
-
else
|
11
|
-
'r'
|
12
|
-
end
|
8
|
+
ROLLING_RELEASES = ['rawhide', 'factory', 'tumbleweed']
|
13
9
|
|
14
|
-
|
15
|
-
|
16
|
-
|
10
|
+
OsRelease = Struct.new :os, :version
|
11
|
+
|
12
|
+
def self.os_release
|
13
|
+
@os_release ||= begin
|
14
|
+
os_release = OsRelease.new DEFAULT
|
15
|
+
|
16
|
+
# Try os-release first.
|
17
|
+
if !release_files.grep(/os-release/).empty?
|
18
|
+
content = File.open(release_files.grep(/os-release/).first, Gem2Rpm::OPEN_MODE) do |f|
|
19
|
+
f.read
|
20
|
+
end
|
17
21
|
|
18
|
-
|
19
|
-
|
20
|
-
versions << Regexp.last_match.to_s if Regexp.last_match
|
22
|
+
os_release.os = content[/^ID=(.*)$/, 1].to_sym rescue
|
23
|
+
os_release.version = content[/^VERSION_ID=(.*)$/, 1]
|
21
24
|
end
|
22
25
|
|
23
|
-
|
26
|
+
# If os-release failed (it is empty or has not enough information),
|
27
|
+
# try some other release files.
|
28
|
+
if os_release.os == DEFAULT
|
29
|
+
if !release_files.grep(/fedora/).empty?
|
30
|
+
os_release.os = FEDORA
|
31
|
+
versions = []
|
24
32
|
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
33
|
+
release_files.each do |file|
|
34
|
+
/\d+/ =~ File.open(file, OPEN_MODE).readline
|
35
|
+
versions << Regexp.last_match.to_s if Regexp.last_match
|
36
|
+
end
|
37
|
+
|
38
|
+
versions.uniq!
|
39
|
+
|
40
|
+
os_release.version = versions.first if versions.length == 1
|
41
|
+
elsif !release_files.grep(/redhat/).empty?
|
42
|
+
# Use Fedora's template for RHEL ATM.
|
43
|
+
os_release.os = FEDORA
|
44
|
+
elsif !release_files.grep(/SuSE/).empty?
|
45
|
+
os_release.os = OPENSUSE
|
46
|
+
elsif !release_files.grep(/pld/).empty?
|
47
|
+
os_release.os = PLD
|
48
|
+
end
|
29
49
|
end
|
30
|
-
|
31
|
-
|
32
|
-
FEDORA
|
33
|
-
elsif !release_files.grep(/SuSE/).empty?
|
34
|
-
OPENSUSE
|
35
|
-
else
|
36
|
-
DEFAULT
|
50
|
+
|
51
|
+
os_release
|
37
52
|
end
|
38
53
|
end
|
39
54
|
|
55
|
+
def self.nature
|
56
|
+
template_by_os_version(os_release.os, os_release.version) || DEFAULT
|
57
|
+
end
|
58
|
+
|
40
59
|
def self.release_files
|
41
|
-
|
42
|
-
Dir.glob('/etc
|
60
|
+
@release_files ||=
|
61
|
+
Dir.glob('/etc/{os-release,*{_version,-release}}*').uniq.select {|e| File.file? e}
|
62
|
+
end
|
63
|
+
|
64
|
+
def self.release_files=(files)
|
65
|
+
@release_files = files
|
43
66
|
end
|
44
67
|
|
45
68
|
def self.template_by_os_version(os, version)
|
46
|
-
|
69
|
+
Template.list.each do |file|
|
47
70
|
next if file =~ /^\./
|
48
|
-
|
49
|
-
|
71
|
+
# We want only distro RubyGems templates to get the right versions
|
72
|
+
next unless file =~ /^#{os}((-([0-9]+\.{0,1}[0-9]+){0,}){0,}(-(#{ROLLING_RELEASES.join('|')})){0,1}).spec.erb/
|
73
|
+
return file.gsub('.spec.erb', '') if Regexp.last_match and in_range?(version, Regexp.last_match[1].to_s.split('-').drop(1))
|
50
74
|
end
|
51
75
|
|
52
76
|
nil
|
@@ -59,7 +83,7 @@ module Gem2Rpm
|
|
59
83
|
return true if range.first.to_s == version.to_s
|
60
84
|
else # range: [xx, yy]
|
61
85
|
if range[0].to_s <= version.to_s
|
62
|
-
return true if range[1]
|
86
|
+
return true if ROLLING_RELEASES.include? range[1] or version.to_s <= range[1].to_s
|
63
87
|
end
|
64
88
|
end
|
65
89
|
|
@@ -67,4 +91,3 @@ module Gem2Rpm
|
|
67
91
|
end
|
68
92
|
end
|
69
93
|
end
|
70
|
-
|
data/lib/gem2rpm/helpers.rb
CHANGED
@@ -40,5 +40,56 @@ module Gem2Rpm
|
|
40
40
|
version == Gem::Version.new(0) ? "" : "#{op} #{version}"
|
41
41
|
end
|
42
42
|
end
|
43
|
+
|
44
|
+
def self.file_entries_to_rpm(entries)
|
45
|
+
rpm_file_list = entries.map{ |e| self.file_entry_to_rpm(e) }
|
46
|
+
rpm_file_list.join("\n")
|
47
|
+
end
|
48
|
+
|
49
|
+
def self.doc_file?(file)
|
50
|
+
check_str_on_conditions(file, Gem2Rpm::Configuration.instance.rule_for(:doc))
|
51
|
+
end
|
52
|
+
|
53
|
+
def self.license_file?(file)
|
54
|
+
check_str_on_conditions(file, Gem2Rpm::Configuration.instance.rule_for(:license))
|
55
|
+
end
|
56
|
+
|
57
|
+
def self.ignore_file?(file)
|
58
|
+
check_str_on_conditions(file, Gem2Rpm::Configuration.instance.rule_for(:ignore))
|
59
|
+
end
|
60
|
+
|
61
|
+
def self.misc_file?(file)
|
62
|
+
check_str_on_conditions(file, Gem2Rpm::Configuration.instance.rule_for(:misc))
|
63
|
+
end
|
64
|
+
|
65
|
+
def self.file_entry_to_rpm(entry)
|
66
|
+
config = Gem2Rpm::Configuration.instance
|
67
|
+
case true
|
68
|
+
when doc_file?(entry)
|
69
|
+
"#{config.macro_for(:doc)} #{config.macro_for(:instdir)}/#{entry}".strip
|
70
|
+
when license_file?(entry)
|
71
|
+
"#{config.macro_for(:license)} #{config.macro_for(:instdir)}/#{entry}".strip
|
72
|
+
when ignore_file?(entry)
|
73
|
+
"#{config.macro_for(:ignore)} #{config.macro_for(:instdir)}/#{entry}".strip
|
74
|
+
# /lib should have its own macro
|
75
|
+
when entry == 'lib'
|
76
|
+
"#{config.macro_for(:libdir)}"
|
77
|
+
else
|
78
|
+
"#{config.macro_for(:instdir)}/#{entry}"
|
79
|
+
end
|
80
|
+
end
|
81
|
+
|
82
|
+
# Returns a list of top level directories and files
|
83
|
+
# out of an array of file_list
|
84
|
+
def self.top_level_from_file_list(file_list)
|
85
|
+
file_list.map{ |f| f.gsub!(/([^\/]*).*/,"\\1") }.uniq
|
86
|
+
end
|
87
|
+
|
88
|
+
# Compares string to the given regexp conditions
|
89
|
+
def self.check_str_on_conditions(str, conditions)
|
90
|
+
conditions.any? do |condition|
|
91
|
+
condition.is_a?(Regexp) ? condition.match(str) : condition == str
|
92
|
+
end
|
93
|
+
end
|
43
94
|
end
|
44
95
|
end
|
@@ -1,13 +1,16 @@
|
|
1
1
|
require 'delegate'
|
2
|
+
require 'gem2rpm/configuration'
|
2
3
|
require 'gem2rpm/dependency'
|
3
4
|
require 'gem2rpm/helpers'
|
4
5
|
|
5
6
|
module Gem2Rpm
|
6
7
|
class Specification < SimpleDelegator
|
8
|
+
|
7
9
|
# A long description of gem wrapped to 78 characters.
|
8
10
|
def description
|
9
11
|
d = super.to_s.chomp
|
10
|
-
d.
|
12
|
+
d = summary.to_s.chomp if d.empty?
|
13
|
+
d.gsub!(/([^.!?])\Z/, "\\1.")
|
11
14
|
Helpers::word_wrap(d, 78) + "\n"
|
12
15
|
end
|
13
16
|
|
@@ -0,0 +1,64 @@
|
|
1
|
+
module Gem2Rpm
|
2
|
+
class Template
|
3
|
+
class TemplateError < Exception; end
|
4
|
+
|
5
|
+
attr_accessor :filename
|
6
|
+
|
7
|
+
def self.default_location
|
8
|
+
@@location ||= File.join(File.dirname(__FILE__), '..', '..', 'templates')
|
9
|
+
end
|
10
|
+
|
11
|
+
def self.default_location=(location)
|
12
|
+
@@location = location
|
13
|
+
@@list = nil
|
14
|
+
end
|
15
|
+
|
16
|
+
def self.list
|
17
|
+
@@list ||= Dir.chdir(default_location) do
|
18
|
+
Dir.glob('*').sort
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
# Returns instance of Template class. If the 'name' parameter is specified
|
23
|
+
# it tries to instantiate the template of specific name first. When
|
24
|
+
# options[:gem_file] is specified, it can be taken into consideration
|
25
|
+
# when looking for vagrant templates for example.
|
26
|
+
def self.find(name = nil, options = {})
|
27
|
+
if name.nil?
|
28
|
+
case options[:gem_file]
|
29
|
+
when /^vagrant(-|_).*/
|
30
|
+
Gem2Rpm::VAGRANT_PLUGIN_TEMPLATE
|
31
|
+
else
|
32
|
+
Gem2Rpm::RUBYGEM_TEMPLATE
|
33
|
+
end
|
34
|
+
else
|
35
|
+
begin
|
36
|
+
if File.exists?(name)
|
37
|
+
Gem2Rpm::Template.new(name)
|
38
|
+
else
|
39
|
+
Gem2Rpm::Template.new(File.join(Gem2Rpm::Template::default_location, name + '.spec.erb'))
|
40
|
+
end
|
41
|
+
rescue TemplateError
|
42
|
+
raise TemplateError, "Could not locate template #{name}"
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
# Create instance of Template class of specified template filename.
|
48
|
+
# TemplateError is raised when the template file does not exists.
|
49
|
+
def initialize(filename)
|
50
|
+
if File.exists? filename
|
51
|
+
@filename = filename
|
52
|
+
else
|
53
|
+
raise TemplateError, "Could not locate template #{filename}"
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
# Read the content of the template file.
|
58
|
+
def read
|
59
|
+
@content ||= begin
|
60
|
+
File.open(@filename, OPEN_MODE) {|f| f.read }
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
module Gem2Rpm
|
2
|
+
module TemplateHelpers
|
3
|
+
# File list block for the main package
|
4
|
+
def main_file_entries(spec)
|
5
|
+
entries = Helpers.top_level_from_file_list(spec.files)
|
6
|
+
entries.delete_if{ |f| Helpers.doc_file?(f) || Helpers.misc_file?(f) }
|
7
|
+
Helpers.file_entries_to_rpm(entries)
|
8
|
+
end
|
9
|
+
|
10
|
+
# File list block for the doc sub-package
|
11
|
+
def doc_file_entries(spec)
|
12
|
+
entries = Helpers.top_level_from_file_list(spec.files)
|
13
|
+
entries.delete_if{ |f| !(Helpers.doc_file?(f) || Helpers.misc_file?(f)) }
|
14
|
+
Helpers.file_entries_to_rpm(entries)
|
15
|
+
end
|
16
|
+
|
17
|
+
# Provides well formatted requirement with version.
|
18
|
+
def requirement(name, version = nil)
|
19
|
+
version = nil if version && version.to_s.empty?
|
20
|
+
[name, version].compact.join(' ')
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
data/lib/gem2rpm.rb
CHANGED
@@ -5,13 +5,24 @@ require 'gem2rpm/distro'
|
|
5
5
|
require 'gem2rpm/format'
|
6
6
|
require 'gem2rpm/spec_fetcher'
|
7
7
|
require 'gem2rpm/specification'
|
8
|
+
require 'gem2rpm/template_helpers'
|
9
|
+
require 'gem2rpm/template'
|
8
10
|
|
9
11
|
module Gem2Rpm
|
10
|
-
Gem2Rpm::
|
12
|
+
extend Gem2Rpm::TemplateHelpers
|
13
|
+
|
14
|
+
Gem2Rpm::VERSION = "0.11.0"
|
11
15
|
|
12
16
|
class Exception < RuntimeError; end
|
13
17
|
class DownloadUrlError < Exception; end
|
14
18
|
|
19
|
+
OPEN_MODE = # :nodoc:
|
20
|
+
if Object.const_defined? :Encoding
|
21
|
+
'r:UTF-8'
|
22
|
+
else
|
23
|
+
'r'
|
24
|
+
end
|
25
|
+
|
15
26
|
def self.find_download_url(name, version)
|
16
27
|
dep = Gem::Dependency.new(name, "=#{version}")
|
17
28
|
fetcher = Gem2Rpm::SpecFetcher.new(Gem::SpecFetcher.fetcher)
|
@@ -30,13 +41,13 @@ module Gem2Rpm
|
|
30
41
|
download_path
|
31
42
|
end
|
32
43
|
|
33
|
-
def Gem2Rpm.convert(fname, template=
|
44
|
+
def Gem2Rpm.convert(fname, template=RUBYGEM_TEMPLATE, out=$stdout,
|
34
45
|
nongem=true, local=false, doc_subpackage = true)
|
35
46
|
package = Gem2Rpm::Package.new(fname)
|
36
47
|
# Deprecate, kept just for backward compatibility.
|
37
48
|
format = Gem2Rpm::Format.new(package)
|
38
49
|
spec = Gem2Rpm::Specification.new(package.spec)
|
39
|
-
|
50
|
+
config = Gem2Rpm::Configuration.instance.to_default
|
40
51
|
download_path = ""
|
41
52
|
unless local
|
42
53
|
begin
|
@@ -46,8 +57,9 @@ module Gem2Rpm
|
|
46
57
|
$stderr.puts e.inspect
|
47
58
|
end
|
48
59
|
end
|
49
|
-
|
50
|
-
|
60
|
+
|
61
|
+
erb = ERB.new(template.read, 0, '-')
|
62
|
+
out.puts erb.result(binding)
|
51
63
|
rescue Gem::Exception => e
|
52
64
|
puts e
|
53
65
|
end
|
@@ -56,10 +68,10 @@ module Gem2Rpm
|
|
56
68
|
# gem2spec). Taken from RPM macros if present, constructed from system
|
57
69
|
# username and hostname otherwise.
|
58
70
|
def Gem2Rpm.packager()
|
59
|
-
packager = `rpmdev-packager`.chomp rescue ''
|
71
|
+
packager = `rpmdev-packager 2> /dev/null`.chomp rescue ''
|
60
72
|
|
61
73
|
if packager.empty?
|
62
|
-
packager = `rpm --eval '%{packager}'`.chomp rescue ''
|
74
|
+
packager = `rpm --eval '%{packager}' 2> /dev/null`.chomp rescue ''
|
63
75
|
end
|
64
76
|
|
65
77
|
if packager.empty? or packager == '%{packager}'
|
@@ -70,11 +82,12 @@ module Gem2Rpm
|
|
70
82
|
packager
|
71
83
|
end
|
72
84
|
|
73
|
-
|
74
|
-
|
85
|
+
RUBYGEM_TEMPLATE = Template.new(File.join(Template::default_location, "#{Distro.nature.to_s}.spec.erb"))
|
86
|
+
VAGRANT_PLUGIN_TEMPLATE = begin
|
87
|
+
file = File.join(Template::default_location, "#{Distro.nature.to_s}-vagrant-plugin.spec.erb")
|
88
|
+
Template.new(file) if File.exist? file
|
75
89
|
end
|
76
90
|
|
77
|
-
TEMPLATE = File.read File.join(template_dir, "#{Distro.nature.to_s}.spec.erb")
|
78
91
|
end
|
79
92
|
|
80
93
|
# Local Variables:
|
File without changes
|
@@ -0,0 +1,123 @@
|
|
1
|
+
# Generated from <%= package.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
|
+
Group: Development/Languages
|
9
|
+
License: <%= spec.licenses.join(" and ") %>
|
10
|
+
<% if spec.homepage -%>
|
11
|
+
URL: <%= spec.homepage %>
|
12
|
+
<% end -%>
|
13
|
+
Source0: <%= download_path %>%{vagrant_plugin_name}-%{version}.gem
|
14
|
+
Requires(posttrans): vagrant
|
15
|
+
Requires(preun): vagrant
|
16
|
+
Requires: vagrant
|
17
|
+
BuildRequires: ruby(release)
|
18
|
+
BuildRequires: rubygems-devel
|
19
|
+
BuildRequires: ruby
|
20
|
+
BuildRequires: vagrant
|
21
|
+
<% if spec.extensions.empty? -%>
|
22
|
+
BuildArch: noarch
|
23
|
+
<% end -%>
|
24
|
+
Provides: vagrant(%{vagrant_plugin_name}) = %{version}
|
25
|
+
|
26
|
+
%description
|
27
|
+
<%= spec.description %>
|
28
|
+
|
29
|
+
<% if doc_subpackage -%>
|
30
|
+
%package doc
|
31
|
+
Summary: Documentation for %{name}
|
32
|
+
Group: Documentation
|
33
|
+
Requires: %{name} = %{version}-%{release}
|
34
|
+
BuildArch: noarch
|
35
|
+
|
36
|
+
%description doc
|
37
|
+
Documentation for %{name}.
|
38
|
+
<% end # if doc_subpackage -%>
|
39
|
+
|
40
|
+
%prep
|
41
|
+
gem unpack %{SOURCE0}
|
42
|
+
|
43
|
+
%setup -q -D -T -n %{vagrant_plugin_name}-%{version}
|
44
|
+
|
45
|
+
gem spec %{SOURCE0} -l --ruby > %{vagrant_plugin_name}.gemspec
|
46
|
+
|
47
|
+
%build
|
48
|
+
# Create the gem as gem install only works on a gem file
|
49
|
+
gem build %{vagrant_plugin_name}.gemspec
|
50
|
+
|
51
|
+
# %%vagrant_plugin_install compiles any C extensions and installs the gem into ./%%gem_dir
|
52
|
+
# by default, so that we can move it into the buildroot in %%install
|
53
|
+
%vagrant_plugin_install
|
54
|
+
|
55
|
+
%install
|
56
|
+
mkdir -p %{buildroot}%{vagrant_plugin_dir}
|
57
|
+
cp -a .%{vagrant_plugin_dir}/* \
|
58
|
+
%{buildroot}%{vagrant_plugin_dir}/
|
59
|
+
|
60
|
+
<% unless spec.extensions.empty? -%>
|
61
|
+
mkdir -p %{buildroot}%{vagrant_plugin_extdir_mri}
|
62
|
+
cp -a .%{vagrant_plugin_extdir_mri}/{gem.build_complete,*.so} %{buildroot}%{vagrant_plugin_extdir_mri}/
|
63
|
+
|
64
|
+
<% for ext in spec.extensions -%>
|
65
|
+
# Prevent dangling symlink in -debuginfo (rhbz#878863).
|
66
|
+
rm -rf %{buildroot}%{vagrant_plugin_instdir}/<%= ext.split(File::SEPARATOR).first %>/
|
67
|
+
<% end -%>
|
68
|
+
<% end -%>
|
69
|
+
|
70
|
+
<% unless spec.executables.nil? or spec.executables.empty? -%>
|
71
|
+
mkdir -p %{buildroot}%{_bindir}
|
72
|
+
cp -pa .%{_bindir}/* \
|
73
|
+
%{buildroot}%{_bindir}/
|
74
|
+
<% end -%>
|
75
|
+
|
76
|
+
<% unless spec.executables.empty? -%>
|
77
|
+
find %{buildroot}%{vagrant_plugin_instdir}/bin -type f | xargs chmod a+x
|
78
|
+
<% end -%>
|
79
|
+
|
80
|
+
# Run the test suite
|
81
|
+
%check
|
82
|
+
pushd .%{vagrant_plugin_instdir}
|
83
|
+
|
84
|
+
popd
|
85
|
+
|
86
|
+
%posttrans
|
87
|
+
%vagrant_plugin_register %{vagrant_plugin_name}
|
88
|
+
|
89
|
+
%preun
|
90
|
+
%vagrant_plugin_unregister %{vagrant_plugin_name}
|
91
|
+
|
92
|
+
<%
|
93
|
+
# Change macros for Vagrant packaging
|
94
|
+
config.macros[:instdir] = '%{vagrant_plugin_instdir}'
|
95
|
+
config.macros[:libdir] = '%{vagrant_plugin_libdir}'
|
96
|
+
-%>
|
97
|
+
%files
|
98
|
+
%dir %{vagrant_plugin_instdir}
|
99
|
+
<% unless spec.executables.nil? or spec.executables.empty? -%>
|
100
|
+
<% for f in spec.executables -%>
|
101
|
+
%{_bindir}/<%= f %>
|
102
|
+
<% end -%>
|
103
|
+
<% end -%>
|
104
|
+
<% unless spec.extensions.empty? -%>
|
105
|
+
%{vagrant_plugin_extdir_mri}
|
106
|
+
<% end -%>
|
107
|
+
<%= main_file_entries(spec) %>
|
108
|
+
<% unless doc_subpackage -%>
|
109
|
+
%doc %{vagrant_plugin_docdir}
|
110
|
+
<%= doc_file_entries(spec) -%>
|
111
|
+
<% end -%>
|
112
|
+
%exclude %{vagrant_plugin_cache}
|
113
|
+
%{vagrant_plugin_spec}
|
114
|
+
|
115
|
+
<% if doc_subpackage -%>
|
116
|
+
%files doc
|
117
|
+
%doc %{vagrant_plugin_docdir}
|
118
|
+
<%= doc_file_entries(spec) %>
|
119
|
+
<% end # if doc_subpackage -%>
|
120
|
+
|
121
|
+
%changelog
|
122
|
+
* <%= Time.now.strftime("%a %b %d %Y") %> <%= packager %> - <%= spec.version %>-1
|
123
|
+
- Initial package
|
@@ -13,15 +13,15 @@ URL: <%= spec.homepage %>
|
|
13
13
|
Source0: <%= download_path %>%{gem_name}-%{version}.gem
|
14
14
|
BuildRequires: ruby(release)
|
15
15
|
<% for req in spec.required_rubygems_version -%>
|
16
|
-
BuildRequires: rubygems-devel
|
16
|
+
BuildRequires: <%= requirement 'rubygems-devel', req %>
|
17
17
|
<% end -%>
|
18
18
|
<% for req in spec.required_ruby_version -%>
|
19
|
-
BuildRequires:
|
19
|
+
BuildRequires: <%= requirement "ruby#{'-devel' unless spec.extensions.empty?}", req %>
|
20
20
|
<% end -%>
|
21
21
|
<% for d in spec.development_dependencies -%>
|
22
22
|
<% unless ["rdoc", "rake", "bundler"].include? d.name -%>
|
23
23
|
<% for req in d.requirement -%>
|
24
|
-
# BuildRequires: rubygem(
|
24
|
+
# BuildRequires: <%= requirement "rubygem(#{d.name})", req %>
|
25
25
|
<% end -%>
|
26
26
|
<% end -%>
|
27
27
|
<% end -%>
|
@@ -95,17 +95,14 @@ popd
|
|
95
95
|
<% for f in spec.executables -%>
|
96
96
|
%{_bindir}/<%= f %>
|
97
97
|
<% end -%>
|
98
|
-
%{gem_instdir}/bin
|
99
98
|
<% end -%>
|
100
|
-
%{gem_libdir}
|
101
99
|
<% unless spec.extensions.empty? -%>
|
102
100
|
%{gem_extdir_mri}
|
103
101
|
<% end -%>
|
102
|
+
<%= main_file_entries(spec) %>
|
104
103
|
<% unless doc_subpackage -%>
|
105
104
|
%doc %{gem_docdir}
|
106
|
-
|
107
|
-
%doc %{gem_instdir}/<%= f %>
|
108
|
-
<% end -%>
|
105
|
+
<%= doc_file_entries(spec) -%>
|
109
106
|
<% end -%>
|
110
107
|
%exclude %{gem_cache}
|
111
108
|
%{gem_spec}
|
@@ -113,9 +110,7 @@ popd
|
|
113
110
|
<% if doc_subpackage -%>
|
114
111
|
%files doc
|
115
112
|
%doc %{gem_docdir}
|
116
|
-
|
117
|
-
%doc %{gem_instdir}/<%= f %>
|
118
|
-
<% end -%>
|
113
|
+
<%= doc_file_entries(spec) %>
|
119
114
|
<% end # if doc_subpackage -%>
|
120
115
|
|
121
116
|
%changelog
|
@@ -0,0 +1,92 @@
|
|
1
|
+
<% if ! spec.development_dependencies.empty? -%>
|
2
|
+
#
|
3
|
+
# Conditional build:
|
4
|
+
%bcond_without tests # build without tests
|
5
|
+
|
6
|
+
<% end -%>
|
7
|
+
%define pkgname <%= spec.name %>
|
8
|
+
Summary: <%= spec.summary %>
|
9
|
+
Name: ruby-%{pkgname}
|
10
|
+
Version: <%= spec.version %>
|
11
|
+
Release: 0.1
|
12
|
+
License: <%= spec.licenses.empty? ? "GPL v2+ or Ruby" : spec.licenses.join(", ") %>
|
13
|
+
Group: Development/Languages
|
14
|
+
Source0: http://rubygems.org/downloads/%{pkgname}-%{version}.gem
|
15
|
+
# Source0-md5: -
|
16
|
+
URL: <%= spec.homepage %>
|
17
|
+
BuildRequires: rpm-rubyprov
|
18
|
+
BuildRequires: rpmbuild(macros) >= 1.656
|
19
|
+
<% if ! spec.extensions.empty? -%>
|
20
|
+
BuildRequires: ruby-devel
|
21
|
+
<% end -%>
|
22
|
+
<% if ! spec.executables.empty? -%>
|
23
|
+
BuildRequires: sed >= 4.0
|
24
|
+
<% end -%>
|
25
|
+
<% if ! spec.development_dependencies.empty? -%>
|
26
|
+
%if %{with tests}
|
27
|
+
<% for d in spec.development_dependencies.sort -%>
|
28
|
+
<% for req in d.requirement -%>
|
29
|
+
BuildRequires: ruby-<%= d.name %> <%= req %>
|
30
|
+
<% end -%>
|
31
|
+
<% end -%>
|
32
|
+
%endif
|
33
|
+
<% end -%>
|
34
|
+
<% if ! spec.required_rubygems_version.empty? and ! spec.required_rubygems_version.first.empty? -%>
|
35
|
+
Requires: ruby-rubygems <%= spec.required_rubygems_version.first %>
|
36
|
+
<% end -%>
|
37
|
+
<% for d in spec.runtime_dependencies.sort -%>
|
38
|
+
<% for req in d.requirement -%>
|
39
|
+
Requires: ruby-<%= d.name %> <%= req %>
|
40
|
+
<% end -%>
|
41
|
+
<% end -%>
|
42
|
+
<% if spec.extensions.empty? -%>
|
43
|
+
BuildArch: noarch
|
44
|
+
<% end -%>
|
45
|
+
BuildRoot: %{tmpdir}/%{name}-%{version}-root-%(id -u -n)
|
46
|
+
|
47
|
+
%description
|
48
|
+
<%= spec.description %>
|
49
|
+
|
50
|
+
%prep
|
51
|
+
%setup -q -n %{pkgname}-%{version}
|
52
|
+
<% if ! spec.executables.empty? -%>
|
53
|
+
%{__sed} -i -e '1 s,#!.*ruby,#!%{__ruby},' bin/*
|
54
|
+
<% end -%>
|
55
|
+
|
56
|
+
%build
|
57
|
+
# write .gemspec
|
58
|
+
%__gem_helper spec
|
59
|
+
|
60
|
+
<% if !spec.extensions.empty? -%>
|
61
|
+
cd ext/%{pkgname}
|
62
|
+
%{__ruby} extconf.rb
|
63
|
+
%{__make} \
|
64
|
+
CC="%{__cc}" \
|
65
|
+
LDFLAGS="%{rpmldflags}" \
|
66
|
+
CFLAGS="%{rpmcflags} -fPIC"
|
67
|
+
<% end -%>
|
68
|
+
|
69
|
+
%install
|
70
|
+
rm -rf $RPM_BUILD_ROOT
|
71
|
+
<% if spec.executables.empty? -%>
|
72
|
+
install -d $RPM_BUILD_ROOT{%{ruby_vendorlibdir},%{ruby_specdir}}
|
73
|
+
<% else -%>
|
74
|
+
install -d $RPM_BUILD_ROOT{%{ruby_vendorlibdir},%{ruby_specdir},%{_bindir}}
|
75
|
+
<% end -%>
|
76
|
+
cp -a lib/* $RPM_BUILD_ROOT%{ruby_vendorlibdir}
|
77
|
+
<% if ! spec.executables.empty? -%>
|
78
|
+
cp -a bin/* $RPM_BUILD_ROOT%{_bindir}
|
79
|
+
<% end -%>
|
80
|
+
cp -p %{pkgname}-%{version}.gemspec $RPM_BUILD_ROOT%{ruby_specdir}
|
81
|
+
|
82
|
+
%clean
|
83
|
+
rm -rf $RPM_BUILD_ROOT
|
84
|
+
|
85
|
+
%files
|
86
|
+
%defattr(644,root,root,755)
|
87
|
+
<% for f in spec.executables.sort -%>
|
88
|
+
%attr(755,root,root) %{_bindir}/<%= f %>
|
89
|
+
<% end -%>
|
90
|
+
%{ruby_vendorlibdir}/%{pkgname}.rb
|
91
|
+
%{ruby_vendorlibdir}/%{pkgname}
|
92
|
+
%{ruby_specdir}/%{pkgname}-%{version}.gemspec
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: gem2rpm
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.11.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- David Lutterkort
|
@@ -9,21 +9,26 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2015-04-30 00:00:00.000000000 Z
|
13
13
|
dependencies: []
|
14
|
-
description:
|
15
|
-
|
14
|
+
description: |2
|
15
|
+
Generate source rpms and rpm spec files from a Ruby Gem.
|
16
|
+
The spec file tries to follow the gem as closely as possible
|
16
17
|
email: gem2rpm-devel@rubyforge.org
|
17
18
|
executables:
|
18
19
|
- gem2rpm
|
19
20
|
extensions: []
|
20
21
|
extra_rdoc_files:
|
21
22
|
- AUTHORS
|
22
|
-
- README
|
23
|
+
- README.md
|
23
24
|
- LICENSE
|
24
25
|
files:
|
26
|
+
- AUTHORS
|
27
|
+
- LICENSE
|
28
|
+
- README.md
|
25
29
|
- bin/gem2rpm
|
26
30
|
- lib/gem2rpm.rb
|
31
|
+
- lib/gem2rpm/configuration.rb
|
27
32
|
- lib/gem2rpm/dependency.rb
|
28
33
|
- lib/gem2rpm/distro.rb
|
29
34
|
- lib/gem2rpm/format.rb
|
@@ -31,16 +36,17 @@ files:
|
|
31
36
|
- lib/gem2rpm/package.rb
|
32
37
|
- lib/gem2rpm/spec_fetcher.rb
|
33
38
|
- lib/gem2rpm/specification.rb
|
39
|
+
- lib/gem2rpm/template.rb
|
40
|
+
- lib/gem2rpm/template_helpers.rb
|
34
41
|
- templates/default.spec.erb
|
35
42
|
- templates/fedora-17-18.spec.erb
|
36
|
-
- templates/fedora-19-
|
43
|
+
- templates/fedora-19-20.spec.erb
|
44
|
+
- templates/fedora-21-rawhide-vagrant-plugin.spec.erb
|
37
45
|
- templates/fedora-21-rawhide.spec.erb
|
38
46
|
- templates/fedora.spec.erb
|
39
47
|
- templates/opensuse.spec.erb
|
40
|
-
-
|
41
|
-
-
|
42
|
-
- AUTHORS
|
43
|
-
homepage: https://github.com/lutter/gem2rpm/
|
48
|
+
- templates/pld.spec.erb
|
49
|
+
homepage: https://github.com/fedora-ruby/gem2rpm
|
44
50
|
licenses: []
|
45
51
|
metadata: {}
|
46
52
|
post_install_message:
|
@@ -49,17 +55,17 @@ require_paths:
|
|
49
55
|
- lib
|
50
56
|
required_ruby_version: !ruby/object:Gem::Requirement
|
51
57
|
requirements:
|
52
|
-
- -
|
58
|
+
- - ">="
|
53
59
|
- !ruby/object:Gem::Version
|
54
60
|
version: '0'
|
55
61
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
56
62
|
requirements:
|
57
|
-
- -
|
63
|
+
- - ">="
|
58
64
|
- !ruby/object:Gem::Version
|
59
65
|
version: '0'
|
60
66
|
requirements: []
|
61
67
|
rubyforge_project:
|
62
|
-
rubygems_version: 2.
|
68
|
+
rubygems_version: 2.2.2
|
63
69
|
signing_key:
|
64
70
|
specification_version: 4
|
65
71
|
summary: Generate rpm specfiles from gems
|
data/README
DELETED
@@ -1,105 +0,0 @@
|
|
1
|
-
This package is a first attempt at converting ruby gems to rpm's. Because
|
2
|
-
of the differences between the two packaging schemes, it is impossible to
|
3
|
-
come up with a completely automated way of doing the conversion, but the
|
4
|
-
spec files produced by this package should be good enough for most
|
5
|
-
pure-ruby gems. I wouldn't put too much hope into automating the gem->rpm
|
6
|
-
process for gems with binary code such as database drivers. But even for
|
7
|
-
those, gem2rpm provides a good starting point for the packaging gems as
|
8
|
-
RPM's.
|
9
|
-
|
10
|
-
Installation
|
11
|
-
============
|
12
|
-
|
13
|
-
Download the ruby gem or an RPM (TODO: more detail)
|
14
|
-
|
15
|
-
Usage
|
16
|
-
=====
|
17
|
-
|
18
|
-
Run 'gem2rpm --help' for options
|
19
|
-
|
20
|
-
At its simplest, download a gem (let's call it GEM) in its latest
|
21
|
-
version (e.g. 1.2.3):
|
22
|
-
|
23
|
-
$ gem fetch GEM
|
24
|
-
|
25
|
-
and run gem2rpm above the downloaded file:
|
26
|
-
|
27
|
-
$ gem2rpm GEM-1.2.3.gem
|
28
|
-
|
29
|
-
You can also use the --fetch flag to fetch the (latest) gem before generating the spec file, achieving the same effect as running 'gem fetch GEM' plus 'gem2rpm GEM-1.2.3.gem':
|
30
|
-
|
31
|
-
$ gem2rpm --fetch GEM
|
32
|
-
|
33
|
-
This will print an rpm spec file based on the information contained in the
|
34
|
-
gem's spec file. In general, it is necessary to edit the generated spec
|
35
|
-
file because the gem is missing some important information that is
|
36
|
-
customarily provided in rpm's, most notably the license and the changelog.
|
37
|
-
|
38
|
-
|
39
|
-
Rather than editing the generated specfile, edit the template from which
|
40
|
-
the specfile is generated. This will make it easier to update the RPM when
|
41
|
-
a new version of the Gem becomes available.
|
42
|
-
|
43
|
-
To support this process, it is recommended to first save the default
|
44
|
-
template somewhere:
|
45
|
-
gem2rpm -T > rubygem-GEM.spec.template
|
46
|
-
|
47
|
-
Now, edit the template and then run gem2rpm to generate the spec file
|
48
|
-
using the edited template:
|
49
|
-
gem2rpm -t rubygem-GEM.spec.template > rubygem-GEM.spec
|
50
|
-
|
51
|
-
With that, you can now build your RPM as usual. When a new version of the
|
52
|
-
gem becomes available, you should edit the saved template and rerun
|
53
|
-
gem2rpm over it.
|
54
|
-
|
55
|
-
Template Details
|
56
|
-
================
|
57
|
-
|
58
|
-
The template is a standard erb file; there are two main variables available
|
59
|
-
in the template file:
|
60
|
-
|
61
|
-
package - The Gem::Package for the gem
|
62
|
-
spec - The Gem::Specification for the gem (the same as format.spec)
|
63
|
-
|
64
|
-
Deprecated:
|
65
|
-
|
66
|
-
format - The Gem::Format for the gem. Please note that this is kept
|
67
|
-
just for compatibility reasons, since RubyGems 2.0 removed
|
68
|
-
this class.
|
69
|
-
|
70
|
-
Conventions
|
71
|
-
===========
|
72
|
-
|
73
|
-
A typical source RPM for a gem should consist of three files: the gem file
|
74
|
-
itself, the template for the spec file and the spec file. To ensure that
|
75
|
-
the template will be included in the source RPM, it must be listed as one
|
76
|
-
of the sources in the spec file.
|
77
|
-
|
78
|
-
The resulting rpms should follow the naming convention 'rubygem-$GEM'
|
79
|
-
where GEM is the name of the packaged gem. The default template also makes
|
80
|
-
sure that the resulting package provides 'ruby($GEM)', according to general
|
81
|
-
packaging conventions for scripting languages.
|
82
|
-
|
83
|
-
Gem Limitiations
|
84
|
-
================
|
85
|
-
|
86
|
-
Gem has some important limitations that make it next to impossible to
|
87
|
-
fully automate the gem -> rpm conversion process. Amongst them are
|
88
|
-
|
89
|
-
- No license field
|
90
|
-
- No changelog
|
91
|
-
- No distinction between build and install time (important for gems with
|
92
|
-
binary components)
|
93
|
-
- Because of its nature as a separate packaging system, gems can not
|
94
|
-
capture dependencies on non-gem system components, e.g., the ruby
|
95
|
-
PostgreSQL driver can not properly describe its build- and
|
96
|
-
runtime-dependencies on the various pieces of the PostgreSQL database
|
97
|
-
|
98
|
-
See also
|
99
|
-
========
|
100
|
-
|
101
|
-
Fedora ruby and rubygem packaging guidelines:
|
102
|
-
http://fedoraproject.org/wiki/Packaging/Ruby
|
103
|
-
|
104
|
-
Project website
|
105
|
-
https://github.com/lutter/gem2rpm/
|