tirofinale 0.1.2 → 0.1.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +30 -8
- data/bin/experiment/list_all_alpine_linux_ruby_package_makedepends.rb +28 -0
- data/data/ruby-packages +122 -0
- data/exe/tirofinale +129 -28
- data/lib/tirofinale/version.rb +1 -1
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 054f5fa1b2cd389a6df5590b52c6620089a5a0f1
|
4
|
+
data.tar.gz: 48036daba2ace54d30203efa3c028d307082d9f9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 09f43d7e14bb8a8c2dd0f816c9e8f5cb0589a37ce016daffd2ca1fd67a0c1f9649de0d10f3e53d73a12d757d0c6b9a54a7c6879ab156bbf537595c308336c3cd
|
7
|
+
data.tar.gz: 6d1cc2354cab6300b5282af825ffc730f303b983be8fb041384b89f5cdc84993cf88c54975b5d75b4de73dcd1648cdfb184539db48218c1daf6e2be10d6073ea
|
data/README.md
CHANGED
@@ -17,29 +17,51 @@ Alpine Linux from v2.6 to v3.4 only.
|
|
17
17
|
## Usage
|
18
18
|
|
19
19
|
~~~~
|
20
|
+
$ tirofinale --help
|
20
21
|
Usage: tirofinale [options]
|
22
|
+
--dependency
|
21
23
|
--dist-version VERSION
|
22
24
|
--gem GEM_NAME
|
25
|
+
--pretty-print
|
26
|
+
--debug-local-aports PATH
|
23
27
|
~~~~
|
24
28
|
|
25
|
-
|
29
|
+
Default output format is optimized to shell.
|
30
|
+
You can install required packages to install `nokogiri` gem by `apk` command following line.
|
26
31
|
|
27
32
|
~~~~
|
28
|
-
|
29
|
-
ruby-dev libxml2-dev libxslt-dev
|
33
|
+
# apk add `tirofinale --gem nokogiri`
|
30
34
|
~~~~
|
31
35
|
|
32
|
-
|
36
|
+
Human readable output gettable by `--pretty-print` option.
|
33
37
|
|
34
38
|
~~~~
|
35
|
-
$ tirofinale --gem nokogiri
|
36
|
-
|
39
|
+
$ tirofinale --gem nokogiri --pretty-print
|
40
|
+
This environment require following packages to install gem 'nokogiri'.
|
41
|
+
ruby-dev
|
42
|
+
libxml2-dev
|
43
|
+
libxslt-dev
|
37
44
|
~~~~
|
38
45
|
|
39
|
-
|
46
|
+
Distribution version is detected automatically when you run `tirofinale` on Alpine Linux environment.
|
47
|
+
If you specify version manually, you can use `--dist-version VERSION` option.
|
48
|
+
The following line show packages which are required to build `nokogiri` gem on Alpine Linux v3.4 on any environment.
|
40
49
|
|
41
50
|
~~~~
|
42
|
-
|
51
|
+
$ tirofinale --dist-version 3.4 --gem nokogiri
|
52
|
+
~~~~
|
53
|
+
|
54
|
+
Dependency of gem to gems will be resolved by Tirofinale's `--dependency` option.
|
55
|
+
For example, `thin` gem depends on `daemons` gem, `eventmachine` gem and `rack` gem.
|
56
|
+
And, `openssl-dev` package is required to build `eventmachine` on Alpine Linux.
|
57
|
+
In folowing example, Tirofinale show distribution packages dependent by `thin` gem and `thin` gem depdns on gems.
|
58
|
+
|
59
|
+
~~~~
|
60
|
+
$ tirofinale --gem thin --dependency --pretty-print
|
61
|
+
This environment require following packages to install gem 'thin'.
|
62
|
+
ruby-dev
|
63
|
+
openssl-dev
|
64
|
+
ruby
|
43
65
|
~~~~
|
44
66
|
|
45
67
|
## License
|
@@ -0,0 +1,28 @@
|
|
1
|
+
load '../../exe/tirofinale'
|
2
|
+
require 'pp'
|
3
|
+
|
4
|
+
path_to_aports = ARGV[0]
|
5
|
+
|
6
|
+
init_logger()
|
7
|
+
|
8
|
+
all_deps = []
|
9
|
+
|
10
|
+
ruby_packages = open('../../data/ruby-packages'){|f| f.read}
|
11
|
+
ruby_packages.each_line{|l|
|
12
|
+
begin
|
13
|
+
name = l.match(/ruby-(.+)$/)[1]
|
14
|
+
deps = fetch_build_dep_packages_alpine(name, '3.4', path_to_aports)
|
15
|
+
|
16
|
+
all_deps << {:name => name, :deps => deps}
|
17
|
+
rescue => e
|
18
|
+
puts "Error occured name='#{name}'"
|
19
|
+
p e.inspect
|
20
|
+
pp e.backtrace
|
21
|
+
end
|
22
|
+
}
|
23
|
+
|
24
|
+
all_deps.sort_by!{|dep| dep[:deps].size}
|
25
|
+
|
26
|
+
all_deps.each{|dep|
|
27
|
+
puts "#{dep[:name]} => [#{dep[:deps].join(', ')}]"
|
28
|
+
}
|
data/data/ruby-packages
ADDED
@@ -0,0 +1,122 @@
|
|
1
|
+
main/ruby-augeas
|
2
|
+
main/ruby-bundler
|
3
|
+
unmaintained/ruby-railties4.2
|
4
|
+
unmaintained/ruby-isbn
|
5
|
+
unmaintained/ruby-rack14
|
6
|
+
unmaintained/ruby-tilt
|
7
|
+
unmaintained/ruby-openid
|
8
|
+
unmaintained/ruby-rbpdf-font
|
9
|
+
unmaintained/ruby-mini_portile
|
10
|
+
unmaintained/ruby-unicorn
|
11
|
+
unmaintained/ruby-metaclass
|
12
|
+
unmaintained/ruby-mysql2
|
13
|
+
unmaintained/ruby-sinatra
|
14
|
+
unmaintained/ruby-rails-deprecated_sanitizer4.2
|
15
|
+
unmaintained/ruby-amazon-ec2
|
16
|
+
unmaintained/ruby-mocha
|
17
|
+
unmaintained/ruby-diff-lcs
|
18
|
+
unmaintained/ruby-crack
|
19
|
+
unmaintained/ruby-rails4.2
|
20
|
+
unmaintained/ruby-actionpack4.2
|
21
|
+
unmaintained/ruby-tzinfo
|
22
|
+
unmaintained/ruby-useragent
|
23
|
+
unmaintained/ruby-rack-ssl
|
24
|
+
unmaintained/ruby-globalid
|
25
|
+
unmaintained/ruby-mini_portile2
|
26
|
+
unmaintained/ruby-protected_attributes4.2
|
27
|
+
unmaintained/ruby-rack-protection
|
28
|
+
unmaintained/ruby-actionpack-action_caching4.2
|
29
|
+
unmaintained/ruby-sprockets-rails4.2
|
30
|
+
unmaintained/ruby-net-ldap
|
31
|
+
unmaintained/ruby-htmlentities
|
32
|
+
unmaintained/ruby-gollum_rails-github-markup
|
33
|
+
unmaintained/ruby-gollum_rails-charlock_holmes
|
34
|
+
unmaintained/ruby-rouge
|
35
|
+
unmaintained/ruby-puma
|
36
|
+
unmaintained/ruby-shoulda
|
37
|
+
unmaintained/ruby-activerecord4.2
|
38
|
+
unmaintained/ruby-activesupport4.2
|
39
|
+
unmaintained/ruby-i18n
|
40
|
+
unmaintained/ruby-coderay
|
41
|
+
unmaintained/ruby-pry
|
42
|
+
unmaintained/ruby-mustache
|
43
|
+
unmaintained/ruby-gollum_rails-gitlab-grit
|
44
|
+
unmaintained/ruby-thread_safe
|
45
|
+
unmaintained/ruby-rack-cache
|
46
|
+
unmaintained/ruby-sanitize
|
47
|
+
unmaintained/ruby-jquery-rails4.2
|
48
|
+
unmaintained/ruby-net-http-digest_auth
|
49
|
+
unmaintained/ruby-http-cookie
|
50
|
+
unmaintained/ruby-hoe
|
51
|
+
unmaintained/ruby-shoulda-matchers
|
52
|
+
unmaintained/ruby-pg
|
53
|
+
unmaintained/ruby-mechanize
|
54
|
+
unmaintained/ruby-daemon-controller
|
55
|
+
unmaintained/ruby-github-markdown
|
56
|
+
unmaintained/ruby-rack-test
|
57
|
+
unmaintained/ruby-posix-spawn
|
58
|
+
unmaintained/ruby-mail
|
59
|
+
unmaintained/ruby-curb
|
60
|
+
unmaintained/ruby-rbpdf
|
61
|
+
unmaintained/ruby-hike
|
62
|
+
unmaintained/ruby-erubis
|
63
|
+
unmaintained/ruby-roadie
|
64
|
+
unmaintained/ruby-kgio
|
65
|
+
unmaintained/ruby-net-http-persistent
|
66
|
+
unmaintained/ruby-addressable
|
67
|
+
unmaintained/ruby-thor
|
68
|
+
unmaintained/ruby-rails-dom-testing4.2
|
69
|
+
unmaintained/ruby-rmagick
|
70
|
+
unmaintained/ruby-gollum-lib-github-markup
|
71
|
+
unmaintained/ruby-loofah
|
72
|
+
unmaintained/ruby-activemodel4.2
|
73
|
+
unmaintained/ruby-charlock_holmes
|
74
|
+
unmaintained/ruby-polyglot
|
75
|
+
unmaintained/ruby-github-markup
|
76
|
+
unmaintained/ruby-yard
|
77
|
+
unmaintained/ruby-sprockets
|
78
|
+
unmaintained/ruby-ntlm-http
|
79
|
+
unmaintained/ruby-arel
|
80
|
+
unmaintained/ruby-multi_json
|
81
|
+
unmaintained/ruby-stringex
|
82
|
+
unmaintained/ruby-activejob4.2
|
83
|
+
unmaintained/ruby-fcgi
|
84
|
+
unmaintained/ruby-thin
|
85
|
+
unmaintained/ruby-treetop
|
86
|
+
unmaintained/ruby-file-tail
|
87
|
+
unmaintained/ruby-rack
|
88
|
+
unmaintained/ruby-require
|
89
|
+
unmaintained/ruby-nokogiri
|
90
|
+
unmaintained/ruby-fastercsv
|
91
|
+
unmaintained/ruby-gitlab-grit
|
92
|
+
unmaintained/ruby-mime-types
|
93
|
+
unmaintained/ruby-network_interface
|
94
|
+
unmaintained/ruby-rack-openid
|
95
|
+
unmaintained/ruby-actionview4.2
|
96
|
+
unmaintained/ruby-sequel
|
97
|
+
unmaintained/ruby-test-unit
|
98
|
+
unmaintained/ruby-raindrops
|
99
|
+
unmaintained/ruby-redcarpet
|
100
|
+
unmaintained/ruby-xml-simple
|
101
|
+
unmaintained/ruby-actionmailer4.2
|
102
|
+
unmaintained/ruby-uuidtools
|
103
|
+
unmaintained/ruby-webrobots
|
104
|
+
unmaintained/ruby-bcrypt
|
105
|
+
unmaintained/ruby-rails-html-sanitizer
|
106
|
+
unmaintained/ruby-unf-ext
|
107
|
+
unmaintained/ruby-shoulda-context
|
108
|
+
unmaintained/ruby-roadie-rails
|
109
|
+
unmaintained/ruby-fastthread
|
110
|
+
unmaintained/ruby-actionpack-xml_parser4.2
|
111
|
+
unmaintained/ruby-abn
|
112
|
+
unmaintained/ruby-safe_yaml
|
113
|
+
unmaintained/ruby-tins
|
114
|
+
unmaintained/ruby-builder
|
115
|
+
unmaintained/ruby-unf
|
116
|
+
unmaintained/ruby-css_parser
|
117
|
+
unmaintained/ruby-sqlite
|
118
|
+
unmaintained/ruby-eventmachine
|
119
|
+
unmaintained/ruby-request_store
|
120
|
+
unmaintained/ruby-daemons
|
121
|
+
unmaintained/ruby-spruz
|
122
|
+
unmaintained/ruby-domain_name
|
data/exe/tirofinale
CHANGED
@@ -1,7 +1,16 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
require 'open-uri'
|
3
3
|
require 'optparse'
|
4
|
-
require '
|
4
|
+
require 'yaml'
|
5
|
+
require 'logger'
|
6
|
+
|
7
|
+
def init_logger
|
8
|
+
$logger = Logger.new(STDERR)
|
9
|
+
$logger.level = 4
|
10
|
+
if level = ENV['LOG_LEVEL']
|
11
|
+
$logger.level = level.to_i
|
12
|
+
end
|
13
|
+
end
|
5
14
|
|
6
15
|
def detect_version_alpine
|
7
16
|
content = open('/etc/alpine-release'){|f| f.read }
|
@@ -9,14 +18,20 @@ def detect_version_alpine
|
|
9
18
|
major_minor ? major_minor[1] : nil
|
10
19
|
end
|
11
20
|
|
12
|
-
def search_apkbuild(gem_name, alpine_version)
|
21
|
+
def search_apkbuild(gem_name, alpine_version, debug_local_aports = nil)
|
13
22
|
dir_list = ['community', 'main', 'non-free', 'testing', 'unmaintained']
|
14
23
|
dir_list.each{|dir_name|
|
15
24
|
apkbuild_url = "http://git.alpinelinux.org/cgit/aports/plain/#{dir_name}/ruby-#{gem_name}/APKBUILD?h=#{alpine_version + '-stable'}"
|
25
|
+
if debug_local_aports
|
26
|
+
apkbuild_url = "#{debug_local_aports}/#{dir_name}/ruby-#{gem_name}/APKBUILD"
|
27
|
+
end
|
28
|
+
|
16
29
|
begin
|
17
30
|
return open(apkbuild_url){|f| f.read}
|
18
31
|
rescue OpenURI::HTTPError => e
|
19
32
|
next
|
33
|
+
rescue Errno::ENOENT => e
|
34
|
+
next
|
20
35
|
end
|
21
36
|
}
|
22
37
|
false
|
@@ -25,50 +40,136 @@ end
|
|
25
40
|
def extract_makedepends(apkbuild)
|
26
41
|
variables = []
|
27
42
|
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
value = m[2]
|
32
|
-
|
33
|
-
variables << {:key => key, :value => value}
|
34
|
-
end
|
43
|
+
# extract quoted variable
|
44
|
+
apkbuild.scan(/^([a-z_]+)="(.*?)"/m){|m|
|
45
|
+
variables << ({:name => m[0], :value => m[1].gsub(/\s+/, ' ')})
|
35
46
|
}
|
36
47
|
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
if m = var[:value].match(/^"(.*)"$/)
|
41
|
-
var[:value] = m[1]
|
42
|
-
end
|
48
|
+
# extract not quoted variable
|
49
|
+
apkbuild.scan(/^([a-z_]+)=([^"]*?)$/){|m|
|
50
|
+
variables << ({:name => m[0], :value => m[1].gsub(/\s+/, ' ')})
|
43
51
|
}
|
44
52
|
|
53
|
+
variables.sort_by!{|var| var[:name].length * -1}
|
54
|
+
|
45
55
|
variables.each{|var|
|
46
56
|
while var[:value].include?('$')
|
47
57
|
result = nil
|
48
58
|
variables.each{|var2|
|
49
|
-
result = result || var[:value].gsub!("$#{var2[:
|
59
|
+
result = result || var[:value].gsub!("$#{var2[:name]}", var2[:value])
|
50
60
|
}
|
51
61
|
break unless result
|
52
62
|
end
|
53
63
|
}
|
54
64
|
|
55
|
-
variables.select{|var| var[:
|
65
|
+
makedepends = variables.select{|var| var[:name] == 'makedepends'}.first
|
66
|
+
makedepends ? makedepends[:value] : ''
|
67
|
+
end
|
68
|
+
|
69
|
+
def fetch_dep_gems(gem_name, checked = [], level = 0)
|
70
|
+
$logger.debug("fetch_dep_gems(). Args:[#{[gem_name, checked, level].join(', ')}]")
|
71
|
+
|
72
|
+
if level > 10
|
73
|
+
return []
|
74
|
+
end
|
75
|
+
|
76
|
+
dep_gems = []
|
77
|
+
|
78
|
+
url = "https://rubygems.org/api/v1/gems/#{gem_name}.yaml"
|
79
|
+
runtime_dep = open(url){|f|
|
80
|
+
YAML.load(f.read)['dependencies']['runtime'].map{|dep| dep['name']}
|
81
|
+
}
|
82
|
+
|
83
|
+
dep_gems.push(*runtime_dep)
|
84
|
+
checked << gem_name
|
85
|
+
|
86
|
+
runtime_dep.each{|dep|
|
87
|
+
unless checked.include?(dep)
|
88
|
+
dep_gems.push(*fetch_dep_gems(dep, checked, level + 1))
|
89
|
+
end
|
90
|
+
}
|
91
|
+
|
92
|
+
dep_gems.uniq
|
93
|
+
|
94
|
+
$logger.info("Gem '#{gem_name}' depends on [#{dep_gems.join(', ')}].")
|
95
|
+
|
96
|
+
dep_gems
|
97
|
+
end
|
98
|
+
|
99
|
+
def fetch_build_dep_packages_alpine(gem_name, alpine_version, debug_local_aports)
|
100
|
+
$logger.info("Fetch Alpine Linux #{alpine_version} dependency packages to build '#{gem_name}'.")
|
101
|
+
apkbuild = search_apkbuild(gem_name, alpine_version, debug_local_aports)
|
102
|
+
unless apkbuild
|
103
|
+
$logger.warn("Alpine Linux does not have binary package for '#{gem_name}'.")
|
104
|
+
return []
|
105
|
+
end
|
106
|
+
makedepends = extract_makedepends(apkbuild)
|
107
|
+
packages = makedepends.strip.split(' ')
|
108
|
+
$logger.info("Alpine Linux build dependency packages [#{packages.join(', ')}] for '#{gem_name}'.")
|
109
|
+
packages
|
110
|
+
rescue => e
|
111
|
+
$logger.error(e.inspect)
|
112
|
+
$logger.error(e.backtrace)
|
113
|
+
raise e
|
56
114
|
end
|
57
115
|
|
58
|
-
|
59
|
-
|
116
|
+
def run
|
117
|
+
init_logger()
|
118
|
+
|
119
|
+
opts = {}
|
60
120
|
|
61
|
-
op = OptionParser.new
|
62
|
-
op.on('--
|
63
|
-
op.on('--
|
64
|
-
op.
|
121
|
+
op = OptionParser.new
|
122
|
+
op.on('--dependency'){|val| opts[:dependency] = true}
|
123
|
+
op.on('--dist-version VERSION'){|val| opts[:alpine_version] = val}
|
124
|
+
op.on('--gem GEM_NAME'){|val| opts[:gem_name] = val}
|
125
|
+
op.on('--pretty-print'){|val| opts[:pretty_print] = true}
|
126
|
+
op.on('--debug-local-aports PATH'){|val| opts[:debug_local_aports] = val}
|
127
|
+
op.parse(ARGV)
|
65
128
|
|
66
|
-
|
129
|
+
$logger.info "Tirofinale start with #{opts}."
|
67
130
|
|
68
|
-
|
131
|
+
alpine_version = opts[:alpine_version]
|
132
|
+
gem_name = opts[:gem_name]
|
133
|
+
dependency = opts[:dependency]
|
134
|
+
debug_local_aports = opts[:debug_local_aports]
|
135
|
+
pretty_print = opts[:pretty_print]
|
69
136
|
|
70
|
-
|
137
|
+
unless alpine_version
|
138
|
+
$logger.info('Attempt to auto detect Alpine Linux version.')
|
139
|
+
alpine_version = detect_version_alpine()
|
140
|
+
$logger.info("Alpine Linux version '#{alpine_version}' was detected.")
|
141
|
+
end
|
71
142
|
|
72
|
-
packages =
|
143
|
+
packages = fetch_build_dep_packages_alpine(gem_name, alpine_version, debug_local_aports)
|
73
144
|
|
74
|
-
|
145
|
+
if dependency
|
146
|
+
dep_gem_list = fetch_dep_gems(gem_name)
|
147
|
+
|
148
|
+
dep_gem_list.each{|dep_gem_name|
|
149
|
+
dep_packages = fetch_build_dep_packages_alpine(dep_gem_name, alpine_version, debug_local_aports)
|
150
|
+
packages.push(*dep_packages) unless dep_packages.empty?
|
151
|
+
}
|
152
|
+
|
153
|
+
packages.uniq!
|
154
|
+
end
|
155
|
+
|
156
|
+
$logger.info("This environment require packages [#{packages.join(', ')}] to install gem '#{gem_name}'.")
|
157
|
+
|
158
|
+
if pretty_print
|
159
|
+
puts "This environment require following packages to install gem '#{gem_name}'."
|
160
|
+
packages.each{|package|
|
161
|
+
puts " #{package}"
|
162
|
+
}
|
163
|
+
else
|
164
|
+
print packages.join(' ')
|
165
|
+
end
|
166
|
+
|
167
|
+
$logger.info "Tirofinale done."
|
168
|
+
end
|
169
|
+
|
170
|
+
if $0 == __FILE__
|
171
|
+
# execute directory
|
172
|
+
run()
|
173
|
+
else
|
174
|
+
# not to do something by require/load this file
|
175
|
+
end
|
data/lib/tirofinale/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: tirofinale
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- xmisao
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-08-
|
11
|
+
date: 2016-08-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -68,7 +68,9 @@ files:
|
|
68
68
|
- README.md
|
69
69
|
- Rakefile
|
70
70
|
- bin/console
|
71
|
+
- bin/experiment/list_all_alpine_linux_ruby_package_makedepends.rb
|
71
72
|
- bin/setup
|
73
|
+
- data/ruby-packages
|
72
74
|
- exe/tirofinale
|
73
75
|
- lib/tirofinale.rb
|
74
76
|
- lib/tirofinale/version.rb
|