gem2rpm 0.11.1 → 1.0.2
Sign up to get free protection for your applications and to get access to all the features.
- 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
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: '086b2a558ce9da7aaf91e3594e282dbd32990b3a9efd83188dca07e60e43c6bf'
|
4
|
+
data.tar.gz: 40d16bcea05765aebff465241453c666b99eabc5940ef1c62b2e413bf05f321a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c8a0f9accd90101da8ef84f1551d46a1dbfc1611a81710375e1d27a0875fd766ee710109a81d3b97ec0bde723b3ef4e445982858e3af21659cf98f3e83c7523b
|
7
|
+
data.tar.gz: 8261b9eee3e9403023c83750955534f6af915e50140ed2906457fc10e8643ceb540dba9591f94288dc259b5e8b17419150ec924d0cd6fc3451632067cd237590
|
data/AUTHORS
CHANGED
data/README.md
CHANGED
@@ -15,7 +15,7 @@ $ gem install gem2rpm
|
|
15
15
|
or download gem2rpm from Fedora repositories as RPM package:
|
16
16
|
|
17
17
|
```
|
18
|
-
#
|
18
|
+
# dnf install rubygem-gem2rpm
|
19
19
|
```
|
20
20
|
|
21
21
|
## Usage
|
@@ -41,8 +41,7 @@ You can also use the `--fetch` flag to fetch the (latest) gem before generating
|
|
41
41
|
$ gem2rpm --fetch GEM
|
42
42
|
```
|
43
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.
|
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 customarily provided in rpm's, most notably the license and the changelog.
|
46
45
|
|
47
46
|
|
48
47
|
Rather than editing the generated specfile, edit the template from which
|
@@ -58,18 +57,30 @@ $ gem2rpm -T > rubygem-GEM.spec.template
|
|
58
57
|
Now you can edit the template and then run gem2rpm to generate the spec file using the edited template:
|
59
58
|
|
60
59
|
```
|
61
|
-
$ gem2rpm -t rubygem-GEM.spec.template > rubygem-GEM.spec
|
60
|
+
$ gem2rpm -t rubygem-GEM.spec.template GEM-1.2.3.gem > rubygem-GEM.spec
|
62
61
|
```
|
63
62
|
|
64
63
|
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
64
|
|
65
|
+
To see all available templates that are shipped and can be directly used with gem2rpm run:
|
66
|
+
|
67
|
+
```
|
68
|
+
$ gem2rpm --templates
|
69
|
+
```
|
70
|
+
|
66
71
|
## Templates
|
67
72
|
|
68
|
-
The template is a standard ERB file that comes with
|
73
|
+
The template is a standard ERB file that comes with several variables:
|
69
74
|
|
70
75
|
- `package` - the `Gem::Package` for the gem
|
71
76
|
- `spec` - the `Gem::Specification` for the gem (the same as `format.spec`)
|
72
77
|
- `config` - the `Gem2Rpm::Configuration` that can redefine default macros or rules used in `spec` template helpers
|
78
|
+
- `runtime_dependencies` - the `Gem2Rpm::RpmDependencyList` providing list of package runtime dependencies
|
79
|
+
- `development_dependencies` - the `Gem2Rpm::RpmDependencyList` providing list of package development dependencies
|
80
|
+
- `tests` - the `Gem2Rpm::TestSuite` providing list of test frameworks allowing their execution
|
81
|
+
- `files` - the `Gem2Rpm::RpmFileList` providing unfiltered list of files in package
|
82
|
+
- `main_files` - the `Gem2Rpm::RpmFileList` providing list of files suitable for main package
|
83
|
+
- `doc_files` - the `Gem2Rpm::RpmFileList` providing list of files suitable for -doc subpackage
|
73
84
|
|
74
85
|
The following variables still work, but are now deprecated:
|
75
86
|
|
@@ -77,7 +88,7 @@ The following variables still work, but are now deprecated:
|
|
77
88
|
|
78
89
|
### Template Configuration
|
79
90
|
|
80
|
-
To make the templates lighter and more complete, Gem2Rpm introduced in version 0.11.0 new configurable
|
91
|
+
To make the templates lighter and more complete, Gem2Rpm introduced in version 0.11.0 new configurable template variables such as `main_files` or `doc_files` that can be further configured via local `config` variable as follows:
|
81
92
|
|
82
93
|
```ruby
|
83
94
|
# Change macros for Vagrant packaging
|
@@ -99,17 +110,13 @@ $ irb -rgem2rpm
|
|
99
110
|
|
100
111
|
## Conventions
|
101
112
|
|
102
|
-
A typical source RPM for a gem should consist of
|
103
|
-
itself
|
104
|
-
the template will be included in the source RPM, it must be listed as one
|
105
|
-
of the sources in the spec file.
|
113
|
+
A typical source RPM for a gem should consist of two files: the gem file
|
114
|
+
itself and the spec file.
|
106
115
|
|
107
116
|
The resulting RPMs should follow the naming convention 'rubygem-$GEM'
|
108
|
-
where GEM is the name of the packaged gem.
|
109
|
-
sure that the resulting package provides 'ruby($GEM)', according to general
|
110
|
-
packaging conventions for scripting languages.
|
117
|
+
where GEM is the name of the packaged gem.
|
111
118
|
|
112
|
-
##
|
119
|
+
## Limitations
|
113
120
|
|
114
121
|
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
122
|
|
data/bin/gem2rpm
CHANGED
@@ -1,140 +1,114 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
# -*- ruby -*-
|
3
3
|
|
4
|
-
|
4
|
+
$LOAD_PATH.push(File.expand_path(File.dirname(__FILE__) + "/../lib"))
|
5
5
|
|
6
6
|
require 'gem2rpm'
|
7
|
-
require 'optparse'
|
8
7
|
require 'fileutils'
|
8
|
+
require 'tmpdir'
|
9
9
|
require 'open-uri'
|
10
10
|
require 'uri'
|
11
11
|
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
print_template_file = nil
|
18
|
-
template_file = nil
|
19
|
-
output_file = nil
|
20
|
-
local = false
|
21
|
-
srpm = false
|
22
|
-
deps = false
|
23
|
-
nongem = false
|
24
|
-
doc_subpackage = true
|
25
|
-
fetch = false
|
26
|
-
|
27
|
-
opts.separator("")
|
28
|
-
opts.separator(" Options:")
|
29
|
-
opts.on("-T", "--current-template", "Print the current template") do |val|
|
30
|
-
print_template_file = true
|
31
|
-
end
|
32
|
-
opts.on("-t", "--template TEMPLATE", "Use TEMPLATE for the specfile") do |val|
|
33
|
-
template_file = val
|
34
|
-
end
|
35
|
-
opts.on("-v", "--version", "Print gem2rpm's version and exit") do
|
36
|
-
puts Gem2Rpm::VERSION
|
37
|
-
exit 0
|
38
|
-
end
|
39
|
-
opts.on("-o", "--output FILE", "Send the specfile to FILE") do |val|
|
40
|
-
output_file = val
|
41
|
-
end
|
42
|
-
opts.on("-s", "--srpm", "Create a source RPM") do |val|
|
43
|
-
srpm = true
|
44
|
-
end
|
45
|
-
opts.on("-l", "--local", "Do not retrieve Gem information over
|
46
|
-
#{' '*36} the network. Use on disconnected machines") do |val|
|
47
|
-
local = true
|
48
|
-
end
|
49
|
-
opts.on("-d", "--dependencies", "Print the dependencies of the gem") do |val|
|
50
|
-
deps = true
|
51
|
-
end
|
52
|
-
opts.on("-n", "--nongem", "Generate a subpackage for non-gem use") do |val|
|
53
|
-
nongem = true
|
12
|
+
options = begin
|
13
|
+
Gem2Rpm::Configuration.instance.options
|
14
|
+
rescue Gem2Rpm::Configuration::InvalidOption => e
|
15
|
+
Gem2Rpm.show_message(e)
|
16
|
+
exit(1)
|
54
17
|
end
|
55
|
-
|
56
|
-
|
18
|
+
if options[:templates]
|
19
|
+
Gem2Rpm.show_templates
|
20
|
+
exit(0)
|
57
21
|
end
|
58
|
-
|
59
|
-
|
22
|
+
if options[:version]
|
23
|
+
Gem2Rpm.show_version
|
24
|
+
exit(0)
|
60
25
|
end
|
61
|
-
opts.separator("")
|
62
|
-
opts.separator(" Arguments:")
|
63
|
-
opts.separator(" GEM the path to locally stored gem package file or the name")
|
64
|
-
opts.separator(" of the gem when using --fetch.")
|
65
|
-
opts.separator("")
|
66
26
|
|
67
|
-
rest =
|
27
|
+
rest = options[:args]
|
68
28
|
|
69
29
|
template = begin
|
70
|
-
Gem2Rpm::Template.find template_file, :gem_file => rest[0]
|
71
|
-
rescue Gem2Rpm::Template::TemplateError
|
72
|
-
$stderr.puts
|
30
|
+
Gem2Rpm::Template.find options[:template_file], :gem_file => rest[0]
|
31
|
+
rescue Gem2Rpm::Template::TemplateError => e
|
32
|
+
$stderr.puts e
|
73
33
|
exit(1)
|
74
34
|
end
|
75
35
|
|
76
|
-
if print_template_file
|
36
|
+
if options[:print_template_file]
|
77
37
|
puts template.read
|
78
38
|
exit 0
|
79
39
|
end
|
80
40
|
|
81
41
|
if rest.size != 1
|
82
|
-
|
83
|
-
|
84
|
-
exit(1)
|
42
|
+
Gem2Rpm.show_message('Missing GEMFILE')
|
43
|
+
exit(1)
|
85
44
|
end
|
86
45
|
gemfile = rest[0]
|
46
|
+
out_dir = options[:directory]
|
47
|
+
unless File.directory?(out_dir)
|
48
|
+
Gem2Rpm.show_message("No such directory #{out_dir}")
|
49
|
+
exit(1)
|
50
|
+
end
|
87
51
|
|
88
|
-
if fetch
|
52
|
+
if options[:fetch]
|
89
53
|
gem_uri = ''
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
54
|
+
begin
|
55
|
+
URI("https://rubygems.org/api/v1/gems/#{gemfile}.json").open do |f|
|
56
|
+
gem_uri = f.read.match(/"gem_uri":\s*"(.*?)",/m)[1]
|
57
|
+
gemfile = URI.parse(gem_uri).path.split('/').last
|
58
|
+
gemfile = File.join(out_dir, gemfile)
|
59
|
+
open(gemfile, 'w') do |gf|
|
60
|
+
gf.write(URI(gem_uri).open.read)
|
61
|
+
end
|
95
62
|
end
|
63
|
+
rescue OpenURI::HTTPError => e
|
64
|
+
Gem2Rpm.show_message("Gem fetch failed with error: #{e.message}")
|
65
|
+
exit(1)
|
96
66
|
end
|
97
67
|
end
|
98
68
|
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
if output_file.nil?
|
108
|
-
output_file = specfile
|
109
|
-
end
|
69
|
+
unless File.exist?(gemfile)
|
70
|
+
Gem2Rpm.show_message("Invalid GEMFILE #{gemfile}")
|
71
|
+
exit(1)
|
72
|
+
end
|
73
|
+
|
74
|
+
if options[:deps]
|
75
|
+
Gem2Rpm.print_dependencies(gemfile)
|
76
|
+
exit 0
|
110
77
|
end
|
111
78
|
|
112
|
-
|
113
|
-
|
114
|
-
|
79
|
+
output_spec = StringIO.new
|
80
|
+
Gem2Rpm.convert(gemfile, template, output_spec, options[:nongem], options[:local], options[:doc_subpackage])
|
81
|
+
|
82
|
+
# Save or print a specfile.
|
83
|
+
if options[:output_file]
|
84
|
+
File.open(options[:output_file], "w") do |f|
|
85
|
+
f.puts(output_spec.string)
|
86
|
+
end
|
115
87
|
else
|
116
|
-
|
117
|
-
out = open(output_file, "w")
|
118
|
-
Gem2Rpm::convert(gemfile, template, out, nongem, local, doc_subpackage)
|
119
|
-
ensure
|
120
|
-
out.close()
|
121
|
-
end
|
88
|
+
puts output_spec.string unless options[:srpm]
|
122
89
|
end
|
123
90
|
|
124
|
-
# Create a
|
125
|
-
if srpm
|
126
|
-
|
127
|
-
|
91
|
+
# Create a SRPM.
|
92
|
+
if options[:srpm]
|
93
|
+
gemname = Gem2Rpm::Package.new(gemfile).spec.name
|
94
|
+
Dir.mktmpdir "gem2rpm-#{gemname}-" do |srpmdir|
|
95
|
+
specfile = File.join(srpmdir, "rubygem-#{gemname}.spec")
|
96
|
+
|
97
|
+
File.open(specfile, "w") do |f|
|
98
|
+
f.puts(output_spec.string)
|
128
99
|
end
|
129
|
-
FileUtils::copy(gemfile, srpmdir)
|
130
100
|
|
131
|
-
|
132
|
-
|
101
|
+
FileUtils.copy(gemfile, srpmdir)
|
102
|
+
|
103
|
+
command =
|
104
|
+
"rpmbuild -bs --nodeps " +
|
105
|
+
"--define '_sourcedir #{srpmdir}' " +
|
106
|
+
"--define '_srcrpmdir #{out_dir}' " +
|
107
|
+
specfile
|
133
108
|
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
puts "rubygem(#{dep.name}) #{r}"
|
109
|
+
unless system(command)
|
110
|
+
Gem2Rpm.show_message("Command failed: #{command}")
|
111
|
+
exit(1)
|
138
112
|
end
|
139
113
|
end
|
140
114
|
end
|
data/lib/gem2rpm.rb
CHANGED
@@ -1,17 +1,20 @@
|
|
1
1
|
require 'erb'
|
2
2
|
require 'socket'
|
3
|
-
require 'gem2rpm/package'
|
4
3
|
require 'gem2rpm/distro'
|
5
|
-
require 'gem2rpm/format'
|
6
|
-
require 'gem2rpm/
|
7
|
-
require 'gem2rpm/
|
4
|
+
require 'gem2rpm/gem/format'
|
5
|
+
require 'gem2rpm/gem/package'
|
6
|
+
require 'gem2rpm/gem/spec_fetcher'
|
7
|
+
require 'gem2rpm/gem/specification'
|
8
|
+
require 'gem2rpm/rpm_dependency_list'
|
9
|
+
require 'gem2rpm/rpm_file_list'
|
8
10
|
require 'gem2rpm/template_helpers'
|
9
11
|
require 'gem2rpm/template'
|
12
|
+
require 'gem2rpm/test_suite'
|
10
13
|
|
11
14
|
module Gem2Rpm
|
12
15
|
extend Gem2Rpm::TemplateHelpers
|
13
16
|
|
14
|
-
Gem2Rpm::VERSION = "0.
|
17
|
+
Gem2Rpm::VERSION = "1.0.2".freeze
|
15
18
|
|
16
19
|
class Exception < RuntimeError; end
|
17
20
|
class DownloadUrlError < Exception; end
|
@@ -23,15 +26,33 @@ module Gem2Rpm
|
|
23
26
|
'r'
|
24
27
|
end
|
25
28
|
|
29
|
+
def self.show_message(message, obj = nil, out = $stderr)
|
30
|
+
out.puts("#{message}\n\n")
|
31
|
+
out.puts obj if obj
|
32
|
+
end
|
33
|
+
|
34
|
+
def self.show_templates(out = $stdout)
|
35
|
+
out.puts "Available templates in #{Gem2Rpm::Template.default_location}:\n\n"
|
36
|
+
template_list = Gem2Rpm::Template.list.map do |t|
|
37
|
+
t = t.gsub(/(.*)\.spec.erb/, '\\1')
|
38
|
+
t.gsub(/^/, t == Distro.nature ? '* ' : ' ')
|
39
|
+
end.join("\n")
|
40
|
+
out.puts template_list
|
41
|
+
end
|
42
|
+
|
43
|
+
def self.show_version(out = $stdout)
|
44
|
+
out.puts Gem2Rpm::VERSION
|
45
|
+
end
|
46
|
+
|
26
47
|
def self.find_download_url(name, version)
|
27
48
|
dep = Gem::Dependency.new(name, "=#{version}")
|
28
49
|
fetcher = Gem2Rpm::SpecFetcher.new(Gem::SpecFetcher.fetcher)
|
29
50
|
|
30
51
|
spec_and_source, errors = fetcher.spec_for_dependency(dep, false)
|
31
52
|
|
32
|
-
|
53
|
+
fail DownloadUrlError, errors.first.error.message unless errors.empty?
|
33
54
|
|
34
|
-
|
55
|
+
_spec, source = spec_and_source.first
|
35
56
|
|
36
57
|
if source && source.uri
|
37
58
|
download_path = source.uri.to_s
|
@@ -41,13 +62,24 @@ module Gem2Rpm
|
|
41
62
|
download_path
|
42
63
|
end
|
43
64
|
|
44
|
-
def
|
45
|
-
|
65
|
+
def self.convert(fname, template, out = $stdout, nongem = true, local = false,
|
66
|
+
doc_subpackage = true)
|
46
67
|
package = Gem2Rpm::Package.new(fname)
|
47
68
|
# Deprecate, kept just for backward compatibility.
|
48
69
|
format = Gem2Rpm::Format.new(package)
|
49
70
|
spec = Gem2Rpm::Specification.new(package.spec)
|
50
|
-
|
71
|
+
|
72
|
+
config = Configuration.instance.reset
|
73
|
+
|
74
|
+
runtime_dependencies = Gem2Rpm::RpmDependencyList.new(spec.runtime_dependencies)
|
75
|
+
development_dependencies = Gem2Rpm::RpmDependencyList.new(spec.development_dependencies)
|
76
|
+
|
77
|
+
tests = TestSuite.new(spec)
|
78
|
+
|
79
|
+
files = RpmFileList.new(spec.files)
|
80
|
+
main_files = files.top_level_entries.main_entries
|
81
|
+
doc_files = files.top_level_entries.doc_entries
|
82
|
+
|
51
83
|
download_path = ""
|
52
84
|
unless local
|
53
85
|
begin
|
@@ -64,30 +96,38 @@ module Gem2Rpm
|
|
64
96
|
puts e
|
65
97
|
end
|
66
98
|
|
99
|
+
# Print gem dependencies to the specified output ($stdout by default).
|
100
|
+
def self.print_dependencies(gemfile, out = $stdout)
|
101
|
+
dl = RpmDependencyList.new(Gem2Rpm::Package.new(gemfile).spec.dependencies)
|
102
|
+
out.puts dl.virtualize.to_rpm
|
103
|
+
end
|
104
|
+
|
67
105
|
# Returns the email address of the packager (i.e., the person running
|
68
106
|
# gem2spec). Taken from RPM macros if present, constructed from system
|
69
107
|
# username and hostname otherwise.
|
70
|
-
def
|
108
|
+
def self.packager
|
71
109
|
packager = `rpmdev-packager 2> /dev/null`.chomp rescue ''
|
72
110
|
|
73
111
|
if packager.empty?
|
74
112
|
packager = `rpm --eval '%{packager}' 2> /dev/null`.chomp rescue ''
|
75
113
|
end
|
76
114
|
|
77
|
-
if packager.empty?
|
78
|
-
passwd_entry = Etc
|
79
|
-
packager = "#{(passwd_entry && passwd_entry.gecos) || Etc
|
115
|
+
if packager.empty? || (packager == '%{packager}')
|
116
|
+
passwd_entry = Etc.getpwnam(Etc.getlogin)
|
117
|
+
packager = "#{(passwd_entry && passwd_entry.gecos) || Etc.getlogin} <#{Etc.getlogin}@#{Socket.gethostname}>"
|
80
118
|
end
|
81
119
|
|
82
120
|
packager
|
83
121
|
end
|
84
122
|
|
85
|
-
|
86
|
-
|
87
|
-
file = File.join(Template::default_location, "#{Distro.nature.to_s}-vagrant-plugin.spec.erb")
|
88
|
-
Template.new(file) if File.exist? file
|
123
|
+
def self.rubygem_template
|
124
|
+
Template.new(File.join(Template.default_location, "#{Distro.nature}.spec.erb"))
|
89
125
|
end
|
90
126
|
|
127
|
+
def self.vagrant_plugin_template
|
128
|
+
file = File.join(Template.default_location, "#{Distro.nature}-vagrant-plugin.spec.erb")
|
129
|
+
Template.new(file)
|
130
|
+
end
|
91
131
|
end
|
92
132
|
|
93
133
|
# Local Variables:
|