Pistos-emerge-gem 0.3.1
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.
- data/LICENCE +21 -0
- data/README +33 -0
- data/bin/emerge-gem +10 -0
- data/lib/emerge-gem/ebuild.rb +82 -0
- data/lib/emerge-gem.rb +100 -0
- metadata +58 -0
data/LICENCE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
The MIT Licence
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2009 Pistos
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
|
13
|
+
all copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
21
|
+
THE SOFTWARE.
|
data/README
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
## emerge-gem
|
|
2
|
+
|
|
3
|
+
Goal: Transparently install gems into Portage. Should be as easy as "emerge-gem gemname".
|
|
4
|
+
|
|
5
|
+
### Setup
|
|
6
|
+
|
|
7
|
+
gem install Pistos-emerge-gem --source http://gems.github.com
|
|
8
|
+
|
|
9
|
+
In /etc/make.conf set (or append to) PORTDIR_OVERLAY:
|
|
10
|
+
|
|
11
|
+
PORTDIR_OVERLAY=/usr/local/portage
|
|
12
|
+
|
|
13
|
+
### Usage
|
|
14
|
+
|
|
15
|
+
emerge-gem rack -- -atv
|
|
16
|
+
|
|
17
|
+
emerge-gem will also determine gem dependencies and emerge them, too.
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
### Notes
|
|
22
|
+
|
|
23
|
+
USE emerge-gem AT YOUR OWN RISK! It is still very much alpha software as of
|
|
24
|
+
2009-03-01. If you have been using the gem command to install gems outside of
|
|
25
|
+
Portage's control, you are advised to make use of "gem list -l" and
|
|
26
|
+
"gem uninstall" to check for and remove previously installed gems. This lets
|
|
27
|
+
Portage operate with a clean slate. After you emerge-gem, you can use
|
|
28
|
+
"gem list -l gemname" to verify that emerge-gem installed the gem correctly.
|
|
29
|
+
|
|
30
|
+
emerge-gem works by using the Rubygems system/library to find gem sources and
|
|
31
|
+
dependencies, and to automatically create wrapper ebuilds for them. It then
|
|
32
|
+
issues an emerge command. By default, it uses the local overlay. Use --help
|
|
33
|
+
for CLI switches you can use to specify directories.
|
data/bin/emerge-gem
ADDED
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
class Ebuild
|
|
2
|
+
attr_accessor :spec, :source, :dependencies, :local_path
|
|
3
|
+
|
|
4
|
+
def initialize( spec_pair )
|
|
5
|
+
@spec, @source = spec_pair
|
|
6
|
+
@dependencies = []
|
|
7
|
+
end
|
|
8
|
+
|
|
9
|
+
def filename
|
|
10
|
+
"#{p}.ebuild"
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
def p
|
|
14
|
+
"#{pn}-#{pv}"
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
def pn
|
|
18
|
+
spec.name.downcase
|
|
19
|
+
end
|
|
20
|
+
alias :name :pn
|
|
21
|
+
|
|
22
|
+
def pv
|
|
23
|
+
spec.version.version
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
def atom_of( dependency )
|
|
27
|
+
"dev-ruby/#{dependency.name}"
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
def uri
|
|
31
|
+
"#{source}/gems/#{p}.gem"
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
def write( target_dir = 'ebuilds' )
|
|
35
|
+
ebuild_dir = "#{target_dir}/#{name}"
|
|
36
|
+
FileUtils.mkdir_p ebuild_dir
|
|
37
|
+
output = eruby.result( binding )
|
|
38
|
+
@local_path = "#{ebuild_dir}/#{filename}"
|
|
39
|
+
File.open( @local_path, 'w' ) do |f|
|
|
40
|
+
f.write output
|
|
41
|
+
end
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
protected
|
|
45
|
+
|
|
46
|
+
def eruby
|
|
47
|
+
unless @eruby
|
|
48
|
+
@eruby = ERB.new( %{
|
|
49
|
+
# Copyright 1999-2009 Gentoo Foundation
|
|
50
|
+
# Distributed under the terms of the GNU General Public License v2
|
|
51
|
+
# $Header: $
|
|
52
|
+
|
|
53
|
+
inherit gems
|
|
54
|
+
|
|
55
|
+
DESCRIPTION="<%= spec.summary %>"
|
|
56
|
+
HOMEPAGE="<%= spec.homepage %>"
|
|
57
|
+
SRC_URI="<%= uri %>"
|
|
58
|
+
|
|
59
|
+
LICENSE="MIT"
|
|
60
|
+
SLOT="0"
|
|
61
|
+
KEYWORDS="x86"
|
|
62
|
+
IUSE=""
|
|
63
|
+
RESTRICT="test"
|
|
64
|
+
|
|
65
|
+
<% unless spec.dependencies.empty? %>
|
|
66
|
+
DEPEND="
|
|
67
|
+
<% spec.dependencies.each do |dependency| %>
|
|
68
|
+
<%= atom_of(dependency) %>
|
|
69
|
+
<% end %>
|
|
70
|
+
"
|
|
71
|
+
<% end %>
|
|
72
|
+
}.strip )
|
|
73
|
+
end
|
|
74
|
+
@eruby
|
|
75
|
+
end
|
|
76
|
+
|
|
77
|
+
def self.create_from_spec_lookup( package )
|
|
78
|
+
@@inst ||= Gem::DependencyInstaller.new
|
|
79
|
+
spec_pair = @@inst.find_spec_by_name_and_version( package ).first
|
|
80
|
+
self.new( spec_pair )
|
|
81
|
+
end
|
|
82
|
+
end
|
data/lib/emerge-gem.rb
ADDED
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
require 'rubygems/dependency_installer'
|
|
2
|
+
require 'erb'
|
|
3
|
+
|
|
4
|
+
require 'emerge-gem/ebuild'
|
|
5
|
+
|
|
6
|
+
class EmergeGem
|
|
7
|
+
def print_usage_and_exit
|
|
8
|
+
puts "#{$0} [options] <gem name> [gem name...] [-- <emerge options>]"
|
|
9
|
+
puts " -h --help show usage"
|
|
10
|
+
puts " --portage-base-dir (default /usr/local/portage)"
|
|
11
|
+
puts " --portage-path relative to portage base dir (default dev-ruby)"
|
|
12
|
+
exit 1
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
def initialize( argv )
|
|
16
|
+
@gems = []
|
|
17
|
+
@emerge_options = []
|
|
18
|
+
portage_base_dir = '/usr/local/portage'
|
|
19
|
+
portage_path = 'dev-ruby'
|
|
20
|
+
|
|
21
|
+
collecting_emerge_options = false
|
|
22
|
+
while argv.any?
|
|
23
|
+
arg = argv.shift
|
|
24
|
+
case arg
|
|
25
|
+
when '--'
|
|
26
|
+
collecting_emerge_options = true
|
|
27
|
+
when '-h', '--help'
|
|
28
|
+
print_usage_and_exit
|
|
29
|
+
when '--portage-base-dir'
|
|
30
|
+
portage_base_dir = arg
|
|
31
|
+
when '--portage-path'
|
|
32
|
+
portage_path = arg
|
|
33
|
+
else
|
|
34
|
+
if collecting_emerge_options
|
|
35
|
+
@emerge_options << arg
|
|
36
|
+
else
|
|
37
|
+
@gems << arg
|
|
38
|
+
end
|
|
39
|
+
end
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
if @gems.empty?
|
|
43
|
+
print_usage_and_exit
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
@ebuild_dest ||= "#{portage_base_dir}/#{portage_path}"
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
def run
|
|
50
|
+
gather_ebuilds
|
|
51
|
+
write_ebuilds
|
|
52
|
+
digest_ebuilds
|
|
53
|
+
emerge
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
def gather_ebuilds
|
|
57
|
+
@ebuilds = {}
|
|
58
|
+
while @gems.any?
|
|
59
|
+
next_package = @gems.shift
|
|
60
|
+
|
|
61
|
+
if ! @ebuilds[ next_package ]
|
|
62
|
+
puts "Gathering info about #{next_package}..."
|
|
63
|
+
@ebuilds[ next_package ] = Ebuild.create_from_spec_lookup( next_package )
|
|
64
|
+
else
|
|
65
|
+
puts "(already know about #{next_package})"
|
|
66
|
+
end
|
|
67
|
+
|
|
68
|
+
@ebuilds[ next_package ].spec.dependencies.each do |dependency|
|
|
69
|
+
next if @ebuilds[ dependency.name ]
|
|
70
|
+
puts "Need to lookup dependency #{dependency.name}"
|
|
71
|
+
@gems.push dependency.name
|
|
72
|
+
end
|
|
73
|
+
end
|
|
74
|
+
end
|
|
75
|
+
|
|
76
|
+
def write_ebuilds
|
|
77
|
+
@ebuilds.each do |name, ebuild|
|
|
78
|
+
puts "Writing out #{ebuild.filename}"
|
|
79
|
+
ebuild.write @ebuild_dest
|
|
80
|
+
end
|
|
81
|
+
end
|
|
82
|
+
|
|
83
|
+
def digest_ebuilds
|
|
84
|
+
@ebuilds.each do |name, ebuild|
|
|
85
|
+
shell "ebuild #{ebuild.local_path} digest"
|
|
86
|
+
end
|
|
87
|
+
end
|
|
88
|
+
|
|
89
|
+
def emerge
|
|
90
|
+
ebuild_names = @ebuilds.values.map { |e| e.name }.join( ' ' )
|
|
91
|
+
shell "emerge #{@emerge_options} #{ebuild_names}"
|
|
92
|
+
end
|
|
93
|
+
|
|
94
|
+
def shell( command )
|
|
95
|
+
puts "\033[1m#{command}\033[0m"
|
|
96
|
+
system( command ) or
|
|
97
|
+
exit $?
|
|
98
|
+
end
|
|
99
|
+
end
|
|
100
|
+
|
metadata
ADDED
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
|
+
name: Pistos-emerge-gem
|
|
3
|
+
version: !ruby/object:Gem::Version
|
|
4
|
+
version: 0.3.1
|
|
5
|
+
platform: ruby
|
|
6
|
+
authors:
|
|
7
|
+
- Pistos
|
|
8
|
+
autorequire:
|
|
9
|
+
bindir: bin
|
|
10
|
+
cert_chain: []
|
|
11
|
+
|
|
12
|
+
date: 2009-02-25 00:00:00 -08:00
|
|
13
|
+
default_executable:
|
|
14
|
+
dependencies: []
|
|
15
|
+
|
|
16
|
+
description: Gentoo tool to emerge gems as if there were already downstream ebuilds for them.
|
|
17
|
+
email: pistos at purepistos dot net
|
|
18
|
+
executables:
|
|
19
|
+
- emerge-gem
|
|
20
|
+
extensions: []
|
|
21
|
+
|
|
22
|
+
extra_rdoc_files:
|
|
23
|
+
- README
|
|
24
|
+
- LICENCE
|
|
25
|
+
files:
|
|
26
|
+
- README
|
|
27
|
+
- LICENCE
|
|
28
|
+
- bin/emerge-gem
|
|
29
|
+
- lib/emerge-gem.rb
|
|
30
|
+
- lib/emerge-gem/ebuild.rb
|
|
31
|
+
has_rdoc: false
|
|
32
|
+
homepage: http://github.com/Pistos/emerge-gem
|
|
33
|
+
post_install_message:
|
|
34
|
+
rdoc_options: []
|
|
35
|
+
|
|
36
|
+
require_paths:
|
|
37
|
+
- lib
|
|
38
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
|
39
|
+
requirements:
|
|
40
|
+
- - ">="
|
|
41
|
+
- !ruby/object:Gem::Version
|
|
42
|
+
version: "0"
|
|
43
|
+
version:
|
|
44
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
45
|
+
requirements:
|
|
46
|
+
- - ">="
|
|
47
|
+
- !ruby/object:Gem::Version
|
|
48
|
+
version: "0"
|
|
49
|
+
version:
|
|
50
|
+
requirements: []
|
|
51
|
+
|
|
52
|
+
rubyforge_project:
|
|
53
|
+
rubygems_version: 1.2.0
|
|
54
|
+
signing_key:
|
|
55
|
+
specification_version: 2
|
|
56
|
+
summary: Gentoo tool to emerge gems as if there were already downstream ebuilds for them.
|
|
57
|
+
test_files: []
|
|
58
|
+
|