bubing 0.0.3 → 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/bin/bubing +19 -18
- data/lib/bubing.rb +61 -0
- data/lib/bubing/binary_info.rb +1 -1
- data/lib/bubing/bundler.rb +10 -11
- data/lib/bubing/executable_bundler.rb +13 -15
- metadata +58 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0184dc00837bd5b13ff3e410f0eb199f774279b9
|
4
|
+
data.tar.gz: 85a6e1d20ed15195b0db99fa520de9fc623fe90d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1a09a198a30079f2febdca3597c944a76efe607c7f5baf3e6b1217dd6cc0039ffb4606b2a68697c975b3688b180114b0b3ed046bfe422549b2c92bd046d87d53
|
7
|
+
data.tar.gz: 107b85c383f70df2668e878941b87c16c798a1235a566885ca338956ed213cb15c1e098f689087563a1b0f77972bef83716155cba50721139d88c45408f7e427
|
data/bin/bubing
CHANGED
@@ -7,11 +7,11 @@ options = {}
|
|
7
7
|
options[:plugins] = []
|
8
8
|
options[:plugin_dirs] = []
|
9
9
|
|
10
|
-
options[:files] =
|
11
|
-
options[:file_dirs] =
|
10
|
+
options[:files] = {}
|
11
|
+
options[:file_dirs] = {}
|
12
12
|
|
13
13
|
options[:ld_paths] = []
|
14
|
-
options[:envs] =
|
14
|
+
options[:envs] = {}
|
15
15
|
|
16
16
|
OptionParser.new do |opts|
|
17
17
|
opts.banner = 'Usage: bubing [options] BINARY DIRECTORY'
|
@@ -20,34 +20,35 @@ OptionParser.new do |opts|
|
|
20
20
|
options[:verbose] = v
|
21
21
|
end
|
22
22
|
|
23
|
-
opts.on('-
|
24
|
-
|
23
|
+
opts.on('-r', 'Run script name') do |v|
|
24
|
+
options[:run_script] = v
|
25
|
+
end
|
26
|
+
|
27
|
+
opts.on('-p', '--plugin LIBRARY', 'Add not linked library, eg plugin') do |plugin|
|
25
28
|
options[:plugins] << plugin
|
26
29
|
end
|
27
30
|
|
28
|
-
opts.on('-P', '--plugin_directory PATH',
|
29
|
-
'Add directory with additional libs, eg plugin directory') do |plugin_dir|
|
31
|
+
opts.on('-P', '--plugin_directory PATH', 'Add directory with additional libs, eg plugin directory') do |plugin_dir|
|
30
32
|
options[:plugin_dirs] << plugin_dir
|
31
33
|
end
|
32
34
|
|
33
|
-
opts.on('-f', '--file FILE=PATH',
|
34
|
-
|
35
|
-
options[:files]
|
35
|
+
opts.on('-f', '--file FILE=PATH', 'Add additional file, eg config') do |file|
|
36
|
+
from, to = file.split('=').map(&:strip)
|
37
|
+
options[:files][from] = to
|
36
38
|
end
|
37
39
|
|
38
|
-
opts.on('-F', '--file_directory PATH=PATH',
|
39
|
-
|
40
|
-
options[:file_dirs]
|
40
|
+
opts.on('-F', '--file_directory PATH=PATH', 'Add directory with additional files, eg configs') do |file_dir|
|
41
|
+
from, to = file_dir.split('=').map(&:strip)
|
42
|
+
options[:file_dirs][from] = to
|
41
43
|
end
|
42
44
|
|
43
|
-
opts.on('-L', '--ld_path PATH',
|
44
|
-
'Look dependencies in PATH') do |ld_path|
|
45
|
+
opts.on('-L', '--ld_path PATH', 'Look dependencies in PATH') do |ld_path|
|
45
46
|
options[:ld_paths] << ld_path
|
46
47
|
end
|
47
48
|
|
48
|
-
opts.on('-e', '--env VAR=VAL',
|
49
|
-
|
50
|
-
options[:envs]
|
49
|
+
opts.on('-e', '--env VAR=VAL', 'Add environment variable to run.sh') do |env|
|
50
|
+
var, val = env.split('=').map(&:strip)
|
51
|
+
options[:envs][var] = val
|
51
52
|
end
|
52
53
|
end.parse!
|
53
54
|
|
data/lib/bubing.rb
CHANGED
@@ -5,4 +5,65 @@ require 'bubing/shared_object_bundler'
|
|
5
5
|
require 'bubing/bundler_factory'
|
6
6
|
|
7
7
|
module Bubing
|
8
|
+
def self.configure
|
9
|
+
configuration = Configuration.new
|
10
|
+
yield configuration
|
11
|
+
configuration
|
12
|
+
end
|
13
|
+
|
14
|
+
class Configuration
|
15
|
+
def initialize
|
16
|
+
@options = {}
|
17
|
+
@options[:plugins] = []
|
18
|
+
@options[:plugin_dirs] = []
|
19
|
+
@options[:files] = {}
|
20
|
+
@options[:file_dirs] = {}
|
21
|
+
@options[:envs] = {}
|
22
|
+
@options[:ld_paths] = []
|
23
|
+
end
|
24
|
+
|
25
|
+
def binary(path)
|
26
|
+
@binary = File.absolute_path(path)
|
27
|
+
end
|
28
|
+
|
29
|
+
def directory(path)
|
30
|
+
@directory = File.absolute_path(path)
|
31
|
+
end
|
32
|
+
|
33
|
+
def add_plugin(path)
|
34
|
+
@options[:plugins] << path
|
35
|
+
end
|
36
|
+
|
37
|
+
def add_plugin_dir(path)
|
38
|
+
@options[:plugin_dirs] << path
|
39
|
+
end
|
40
|
+
|
41
|
+
def add_file(from, to)
|
42
|
+
@options[:files][File.expand_path(from)] = to
|
43
|
+
end
|
44
|
+
|
45
|
+
def add_file_dir(from, to)
|
46
|
+
@options[:file_dirs][File.expand_path(from)] = to
|
47
|
+
end
|
48
|
+
|
49
|
+
def add_env(var, val)
|
50
|
+
@options[:envs][var] = val
|
51
|
+
end
|
52
|
+
|
53
|
+
def add_ld_path(path)
|
54
|
+
@options[:ld_paths] << File.expand_path(path)
|
55
|
+
end
|
56
|
+
|
57
|
+
def run_script(name)
|
58
|
+
@options[:run_script] = name
|
59
|
+
end
|
60
|
+
|
61
|
+
def verbose!
|
62
|
+
@options[:verbose] = true
|
63
|
+
end
|
64
|
+
|
65
|
+
def bundle!
|
66
|
+
Bubing::BundlerFactory.new.build(@binary, @directory, **@options).bundle!
|
67
|
+
end
|
68
|
+
end
|
8
69
|
end
|
data/lib/bubing/binary_info.rb
CHANGED
data/lib/bubing/bundler.rb
CHANGED
@@ -14,11 +14,11 @@ module Bubing
|
|
14
14
|
@binary = binary
|
15
15
|
@directory = directory
|
16
16
|
@interpreter = options[:interpreter]
|
17
|
-
@plugins = options[:plugins]
|
18
|
-
@plugin_dirs = options[:plugin_dirs]
|
19
|
-
@files = options[:files]
|
20
|
-
@file_dirs = options[:file_dirs]
|
21
|
-
@ld_paths = options[:ld_paths]
|
17
|
+
@plugins = options[:plugins] || []
|
18
|
+
@plugin_dirs = options[:plugin_dirs] || []
|
19
|
+
@files = options[:files] || []
|
20
|
+
@file_dirs = options[:file_dirs] || []
|
21
|
+
@ld_paths = options[:ld_paths] || []
|
22
22
|
@verbose = options[:verbose]
|
23
23
|
|
24
24
|
@lib_dir = File.join(directory, 'lib')
|
@@ -60,7 +60,7 @@ module Bubing
|
|
60
60
|
if lib.include?('not found')
|
61
61
|
raise DependencyNotFoundError.new(lib.split('=>')[0].strip)
|
62
62
|
end
|
63
|
-
|
63
|
+
PATH_RE.match(lib)[1].strip
|
64
64
|
end
|
65
65
|
|
66
66
|
def get_deps(file)
|
@@ -70,7 +70,7 @@ module Bubing
|
|
70
70
|
''
|
71
71
|
end
|
72
72
|
trace = `#{ld_lib_path} LD_TRACE_LOADED_OBJECTS=1 #{@interpreter} #{file}`
|
73
|
-
trace.split("\n").map(&:strip).select{|row| row.include?('=>')}.map{|dep| extract_path(dep)}
|
73
|
+
trace.split("\n").map(&:strip).select{|row| row.include?('=>')}.map{|dep| extract_path(dep)}.reject(&:empty?)
|
74
74
|
end
|
75
75
|
|
76
76
|
def copy_deps(binary)
|
@@ -103,12 +103,11 @@ module Bubing
|
|
103
103
|
end
|
104
104
|
|
105
105
|
def copy_files(files)
|
106
|
-
files.each do |
|
107
|
-
|
108
|
-
dst = File.join(@directory, dst)
|
106
|
+
files.each do |from, to|
|
107
|
+
dst = File.join(@directory, to)
|
109
108
|
|
110
109
|
FileUtils.mkdir_p(dst)
|
111
|
-
copy(
|
110
|
+
copy(from, dst)
|
112
111
|
end
|
113
112
|
end
|
114
113
|
end
|
@@ -1,15 +1,13 @@
|
|
1
1
|
module Bubing
|
2
2
|
class ExecutableBundler < Bubing::Bundler
|
3
|
-
RUN_TEMPLATE = '%{envs} ./lib/%{interpreter} ./bin/%{binary}'
|
3
|
+
RUN_TEMPLATE = '%{envs} ./lib/%{interpreter} ./bin/%{binary} "$@"'
|
4
4
|
|
5
5
|
def initialize(binary, directory, **options)
|
6
6
|
super
|
7
7
|
@bin_dir = File.join(@directory, 'bin')
|
8
|
+
@run_script = options[:run_script] || 'run.sh'
|
8
9
|
|
9
|
-
@envs = options[:envs]
|
10
|
-
k, v = env.split('=')
|
11
|
-
h[k] = v
|
12
|
-
end
|
10
|
+
@envs = options[:envs] || {}
|
13
11
|
if @envs['LD_LIBRARY_PATH'].nil?
|
14
12
|
@envs['LD_LIBRARY_PATH'] = './lib'
|
15
13
|
end
|
@@ -19,23 +17,23 @@ module Bubing
|
|
19
17
|
super
|
20
18
|
copy(@interpreter, @lib_dir)
|
21
19
|
copy(@binary, @bin_dir)
|
22
|
-
log(
|
20
|
+
log("Preparing #{@run_script}...")
|
23
21
|
run_file = make_run
|
24
22
|
|
25
23
|
FileUtils.chmod('+x', run_file)
|
26
24
|
end
|
27
25
|
|
28
26
|
def make_run
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
27
|
+
File.join(@directory, @run_script).tap do |run_file|
|
28
|
+
envs = @envs.each_with_object([]) do |(k, v), ary|
|
29
|
+
ary << "#{k}=#{v}"
|
30
|
+
end.join(' ')
|
31
|
+
run = RUN_TEMPLATE % {envs: envs, interpreter: File.basename(@interpreter), binary: File.basename(@binary)}
|
32
|
+
File.open(run_file, 'w') do |file|
|
33
|
+
file.write("#!/bin/bash\n")
|
34
|
+
file.write("#{run}\n")
|
35
|
+
end
|
37
36
|
end
|
38
|
-
run_file
|
39
37
|
end
|
40
38
|
|
41
39
|
protected
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: bubing
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
4
|
+
version: 0.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Gleb Sinyavsky
|
@@ -9,7 +9,63 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
date: 2016-05-07 00:00:00.000000000 Z
|
12
|
-
dependencies:
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.12'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.12'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '11.1'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '11.1'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rspec
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '3.4'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '3.4'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: coveralls
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0.8'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0.8'
|
13
69
|
description: Script for bundling linux binaries
|
14
70
|
email: zhulik.gleb@gmail.com
|
15
71
|
executables:
|