gem-nice-install 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
data/MIT ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2012 Vít Ondruch, Bohuslav Kabrda, Ivan Nečas
2
+ Copyright (c) 2012 Red Hat, Inc.
3
+
4
+ Permission is hereby granted, free of charge, to any person obtaining a copy
5
+ of this software and associated documentation files (the "Software"), to deal
6
+ in the Software without restriction, including without limitation the rights
7
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8
+ copies of the Software, and to permit persons to whom the Software is
9
+ furnished to do so, subject to the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be included in
12
+ all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
20
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,13 @@
1
+ # gem-nice-install
2
+
3
+ A RubyGems plugin that improves gem installation user experience.
4
+
5
+ ## usage
6
+
7
+ You don't need to do nothing special, just use 'gem install' as you always do. gem-nice-install will not stand in your way, but it will try to install system dependencies needed to install your gems with binary extensions.
8
+
9
+ Please note, that the currently, only Fedora is supported. However, it should be pretty forward to add support for your favorite system in similar manner.
10
+
11
+ ## license
12
+
13
+ This software is licensed under terms of MIT license.
data/data/fedora.yml ADDED
@@ -0,0 +1,152 @@
1
+ basic_build_deps:
2
+ - gcc
3
+ - ruby-devel
4
+ - make
5
+ gems:
6
+ atk:
7
+ - atk-devel
8
+ atk-devel:
9
+ - atk-devel
10
+ bigdecimal:
11
+ - db4-devel
12
+ - gdbm-devel
13
+ - libffi-devel
14
+ - libyaml-devel
15
+ - ncurses-devel
16
+ - openssl-devel
17
+ - readline-devel
18
+ - tk-devel
19
+ cairo:
20
+ - cairo-devel
21
+ cairo-devel:
22
+ - cairo-devel
23
+ curb:
24
+ - libcurl-devel
25
+ eventmachine:
26
+ - openssl-devel
27
+ ffi:
28
+ - libffi-devel
29
+ gdk_pixbuf2:
30
+ - gdk-pixbuf2-devel
31
+ - rubygem-cairo-devel
32
+ gdk_pixbuf2-devel:
33
+ - gdk-pixbuf2-devel
34
+ - rubygem-cairo-devel
35
+ glib2:
36
+ - glib2-devel
37
+ glib2-devel:
38
+ - glib2-devel
39
+ gtk2:
40
+ - gtk2-devel
41
+ - rubygem-cairo-devel
42
+ gtk2-devel:
43
+ - gtk2-devel
44
+ - rubygem-cairo-devel
45
+ gtksourceview2:
46
+ - gtksourceview2-devel
47
+ gtksourceview2-devel:
48
+ - gtksourceview2-devel
49
+ idn:
50
+ - libidn-devel
51
+ io-console:
52
+ - db4-devel
53
+ - gdbm-devel
54
+ - libffi-devel
55
+ - libyaml-devel
56
+ - ncurses-devel
57
+ - openssl-devel
58
+ - readline-devel
59
+ - tk-devel
60
+ krb5-auth:
61
+ - krb5-devel
62
+ mkrf:
63
+ - libxml2-devel
64
+ nokogiri:
65
+ - libxml2-devel
66
+ - libxslt-devel
67
+ pango:
68
+ - pango-devel
69
+ - rubygem-cairo-devel
70
+ pango-devel:
71
+ - pango-devel
72
+ - rubygem-cairo-devel
73
+ passenger:
74
+ - httpd-devel
75
+ - libcurl-devel
76
+ - libev-devel
77
+ - zlib-devel
78
+ passenger-devel:
79
+ - httpd-devel
80
+ - libcurl-devel
81
+ - libev-devel
82
+ - zlib-devel
83
+ passenger-native:
84
+ - httpd-devel
85
+ - libcurl-devel
86
+ - libev-devel
87
+ - zlib-devel
88
+ passenger-native-libs:
89
+ - httpd-devel
90
+ - libcurl-devel
91
+ - libev-devel
92
+ - zlib-devel
93
+ pg:
94
+ - postgresql-devel
95
+ pkg-config:
96
+ - cairo-devel
97
+ poppler:
98
+ - poppler-glib-devel
99
+ - rubygem-cairo-devel
100
+ - rubygem-gtk2-devel
101
+ poppler-devel:
102
+ - poppler-glib-devel
103
+ - rubygem-cairo-devel
104
+ - rubygem-gtk2-devel
105
+ qpid:
106
+ - qpid-cpp-client-devel
107
+ rake:
108
+ - db4-devel
109
+ - gdbm-devel
110
+ - libffi-devel
111
+ - libyaml-devel
112
+ - ncurses-devel
113
+ - openssl-devel
114
+ - readline-devel
115
+ - tk-devel
116
+ rdoc:
117
+ - db4-devel
118
+ - gdbm-devel
119
+ - libffi-devel
120
+ - libyaml-devel
121
+ - ncurses-devel
122
+ - openssl-devel
123
+ - readline-devel
124
+ - tk-devel
125
+ rsvg2:
126
+ - librsvg2-devel
127
+ - rubygem-cairo-devel
128
+ rsvg2-devel:
129
+ - librsvg2-devel
130
+ - rubygem-cairo-devel
131
+ ruby-opengl:
132
+ - freeglut-devel
133
+ - libGL-devel
134
+ - libGLU-devel
135
+ sqlite3:
136
+ - sqlite-devel
137
+ thin:
138
+ - libcurl-devel
139
+ typhoeus:
140
+ - libcurl-devel
141
+ vte:
142
+ - vte-devel
143
+ vte-devel:
144
+ - vte-devel
145
+ xmlparser:
146
+ - expat-devel
147
+ zoom:
148
+ - libgcrypt-devel
149
+ - libgpg-error-devel
150
+ - libxslt-devel
151
+ - libyaz-devel
152
+ - tcp_wrappers-devel
@@ -0,0 +1,41 @@
1
+
2
+ module Gem
3
+ pre_install do |gem_installer|
4
+ unless gem_installer.spec.extensions.empty?
5
+ gem_installer.extend Gem::Installer::Nice
6
+ end
7
+ end
8
+
9
+
10
+ class Installer
11
+ module Nice
12
+ require 'rubygems/nice_install/distro_guesser'
13
+
14
+ def build_extensions
15
+ super
16
+ rescue ExtensionBuildError => e
17
+ # Install platform dependencies and try the build again.
18
+ if install_platform_dependencies
19
+ super
20
+ else
21
+ raise
22
+ end
23
+ end
24
+
25
+ def install_platform_dependencies
26
+ if ext_installer = DistroGuesser.distro_ext_installer
27
+ missing_deps = ext_installer.gem_ext_dependencies_for(spec.name).delete_if do |t|
28
+ ext_installer.ext_dependency_present?(t)
29
+ end
30
+
31
+ unless missing_deps.empty?
32
+ unless ext_installer.install_ext_dependencies_for(spec.name, missing_deps)
33
+ raise Gem::InstallError, "Failed to install native dependencies for '#{spec.name}'."
34
+ end
35
+ end
36
+ return true
37
+ end
38
+ end
39
+ end
40
+ end
41
+ end
@@ -0,0 +1,49 @@
1
+ require 'yaml'
2
+ module Gem::Installer::Nice
3
+ class BaseExtInstaller
4
+ def default_ext_dependencies
5
+ raise NotImplementedError
6
+ end
7
+
8
+ def gem_ext_dependencies_for gem_name
9
+ raise NotImplementedError
10
+ end
11
+
12
+ def ext_dependency_present? dep_name
13
+ raise NotImplementedError
14
+ end
15
+
16
+ def install_ext_dependencies_for gem_name, deps
17
+ raise NotImplementedError
18
+ end
19
+
20
+ def dep_files
21
+ raise NotImplementedError
22
+ end
23
+
24
+ def get_basic_deps
25
+ load_dep_files
26
+ @deps["basic_build_deps"]
27
+ end
28
+
29
+ def get_deps(gem)
30
+ load_dep_files
31
+ @deps["gems"][gem]
32
+ end
33
+
34
+ private
35
+
36
+ def load_dep_files
37
+ return @deps if defined? @deps
38
+ @deps = dep_files.reduce({}) do |ret, file|
39
+ ret.merge!(load_dep_file(file))
40
+ end
41
+ end
42
+
43
+ def load_dep_file(file)
44
+ base_dir = File.expand_path("../../../../data", __FILE__)
45
+ YAML.load_file(File.join(base_dir, file))
46
+ end
47
+
48
+ end
49
+ end
@@ -0,0 +1,40 @@
1
+ require 'rubygems/nice_install/base_ext_installer'
2
+
3
+ module Gem::Installer::Nice
4
+ class DistroGuesser
5
+ def self.distro
6
+ @distro ||= if !release_files.grep(/fedora/).empty?
7
+ :fedora
8
+ elsif !release_files.grep(/redhat/).empty?
9
+ # Use Fedora for RHEL ATM.
10
+ :fedora
11
+ elsif !release_files.grep(/SuSe/).empty?
12
+ :opensuse
13
+ else
14
+ :base
15
+ end
16
+ end
17
+
18
+ def self.distro_ext_installer
19
+ require "rubygems/nice_install/#{distro}_ext_installer"
20
+ klass = Gem::Installer::Nice.const_get("#{distro.capitalize}ExtInstaller")
21
+ klass.new if klass && klass != BaseExtInstaller
22
+ end
23
+
24
+ def self.version
25
+ versions = []
26
+
27
+ release_files.each do |file|
28
+ /\d+/ =~ File.open(file).readline
29
+ versions << Regexp.last_match.to_s.to_i if Regexp.last_match
30
+ end
31
+
32
+ versions.uniq!.first or 1
33
+ end
34
+
35
+ def self.release_files
36
+ @@release_files ||=
37
+ Dir.glob('/etc/*{_version,-release}*').select {|e| File.file? e}
38
+ end
39
+ end
40
+ end
@@ -0,0 +1,26 @@
1
+ module Gem::Installer::Nice
2
+ class FedoraExtInstaller < BaseExtInstaller
3
+
4
+ def dep_files
5
+ %w[fedora.yml]
6
+ end
7
+
8
+ def default_ext_dependencies
9
+ get_basic_deps
10
+ end
11
+
12
+ def gem_ext_dependencies_for gem_name
13
+ default_ext_dependencies + get_deps(gem_name)
14
+ end
15
+
16
+ def ext_dependency_present? dep_name
17
+ system("rpm -q #{dep_name} > /dev/null 2>&1")
18
+ end
19
+
20
+ def install_ext_dependencies_for gem_name, deps
21
+ puts "Yum installing these native dependencies for Gem '#{gem_name}':"
22
+ puts deps.join ' '
23
+ system("sudo yum install #{deps.join ' '}")
24
+ end
25
+ end
26
+ end
@@ -0,0 +1 @@
1
+ require 'rubygems/nice_install'
metadata ADDED
@@ -0,0 +1,60 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: gem-nice-install
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Vít Ondruch
9
+ - Bohuslav Kabrda
10
+ - Ivan Nečas
11
+ autorequire:
12
+ bindir: bin
13
+ cert_chain: []
14
+ date: 2012-10-16 00:00:00.000000000 Z
15
+ dependencies: []
16
+ description: ! 'A RubyGems plugin that improves gem installation user experience.
17
+ If binary extension build fails,
18
+
19
+ it tries to install its development dependencies.
20
+
21
+ '
22
+ email: vondruch@gmail.com
23
+ executables: []
24
+ extensions: []
25
+ extra_rdoc_files: []
26
+ files:
27
+ - README.md
28
+ - MIT
29
+ - data/fedora.yml
30
+ - lib/rubygems/nice_install/fedora_ext_installer.rb
31
+ - lib/rubygems/nice_install/base_ext_installer.rb
32
+ - lib/rubygems/nice_install/distro_guesser.rb
33
+ - lib/rubygems/nice_install.rb
34
+ - lib/rubygems_plugin.rb
35
+ homepage: https://github.com/voxik/gem-nice-install
36
+ licenses:
37
+ - MIT
38
+ post_install_message:
39
+ rdoc_options: []
40
+ require_paths:
41
+ - lib
42
+ required_ruby_version: !ruby/object:Gem::Requirement
43
+ none: false
44
+ requirements:
45
+ - - ! '>='
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ required_rubygems_version: !ruby/object:Gem::Requirement
49
+ none: false
50
+ requirements:
51
+ - - ! '>='
52
+ - !ruby/object:Gem::Version
53
+ version: '0'
54
+ requirements: []
55
+ rubyforge_project:
56
+ rubygems_version: 1.8.24
57
+ signing_key:
58
+ specification_version: 3
59
+ summary: A RubyGems plugin that improves gem installation user experience.
60
+ test_files: []