tara 0.4.0 → 0.5.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/tara/archive.rb +21 -1
- data/lib/tara/archiver.rb +2 -0
- data/lib/tara/fetcher.rb +3 -3
- data/lib/tara/shim.rb +17 -4
- data/lib/tara/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2617054a9d3083e73b54e1e80c40d8a657fcdfa9
|
4
|
+
data.tar.gz: 8323289eb628caaf484509aab0e9b8c7fdd319a7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e1b7e0c93f9052feeb74586d3b08189a13276ff4f12ac04285723885cd8945163f5256ef73b3f909c4a07b9e4f1d428546b113f32d17e9c425635f4e3f044b38
|
7
|
+
data.tar.gz: 8dcf6b5c2eec3707c7ab07bf9495622145b9037c2069b9d924ae8e8442da5faaa1a073d0b7cb244c9b37a25e24af07bc7788c43dc1d8e6a3ed0c63ad7b914019
|
data/lib/tara/archive.rb
CHANGED
@@ -46,6 +46,8 @@ module Tara
|
|
46
46
|
# expanded when including source files in archive. Should be relative from :app_dir.
|
47
47
|
# @option config [Array<String>] :executables (%w[bin/*]) list of globs that will be
|
48
48
|
# expanded when including executables in archive. Should be relative from :app_dir.
|
49
|
+
# @option config [Array<String, String>] :gem_executables ([]) list of gem and exec name
|
50
|
+
# pairs which will be included as executables in archive.
|
49
51
|
# @option config [String] :target (linux-x86_64) target platform that the archive will
|
50
52
|
# be created for. Should be one of "linux-x86", "linux-x86_64", or "osx".
|
51
53
|
# @option config [String] :traveling_ruby_version (20150210) release of Traveling Ruby
|
@@ -62,6 +64,7 @@ module Tara
|
|
62
64
|
@config[:archive_name] ||= @config[:app_name] + '.tgz'
|
63
65
|
@config[:files] ||= %w[lib/**/*.rb]
|
64
66
|
@config[:executables] ||= %w[bin/*]
|
67
|
+
@config[:gem_executables] ||= []
|
65
68
|
@config[:target] ||= 'linux-x86_64'
|
66
69
|
@config[:traveling_ruby_version] ||= '20150210'
|
67
70
|
@config[:without_groups] ||= %w[development test]
|
@@ -88,6 +91,7 @@ module Tara
|
|
88
91
|
install_dependencies(package_dir, fetcher)
|
89
92
|
copy_source(project_dir, package_dir)
|
90
93
|
copy_executables(project_dir, package_dir)
|
94
|
+
create_gem_shims(package_dir)
|
91
95
|
Dir.chdir(tmp_dir) do
|
92
96
|
create_archive(build_dir)
|
93
97
|
end
|
@@ -120,6 +124,12 @@ module Tara
|
|
120
124
|
end
|
121
125
|
end
|
122
126
|
|
127
|
+
def create_gem_shims(package_dir)
|
128
|
+
@config[:gem_executables].each do |gem_name, exec_name|
|
129
|
+
create_gem_shim(package_dir, gem_name, exec_name)
|
130
|
+
end
|
131
|
+
end
|
132
|
+
|
123
133
|
def create_archive(build_dir)
|
124
134
|
Shell.exec('tar -czf %s %s' % [@config[:archive_name], Dir['*'].join(' ')])
|
125
135
|
FileUtils.mkdir_p(build_dir)
|
@@ -137,6 +147,9 @@ module Tara
|
|
137
147
|
def copy_file(project_dir, package_dir, file)
|
138
148
|
relative_file = file.relative_path_from(project_dir)
|
139
149
|
if relative_file.directory?
|
150
|
+
unless (dirname = relative_file.dirname) == DOT_PATH
|
151
|
+
FileUtils.mkdir_p(package_dir.join(dirname))
|
152
|
+
end
|
140
153
|
FileUtils.cp_r(file, package_dir.join(relative_file))
|
141
154
|
else
|
142
155
|
unless (dirname = relative_file.dirname) == DOT_PATH
|
@@ -148,7 +161,14 @@ module Tara
|
|
148
161
|
|
149
162
|
def create_shim(package_dir, executable)
|
150
163
|
shim_path = package_dir.join(executable.basename)
|
151
|
-
shim =
|
164
|
+
shim = ExecShim.new(*executable.split)
|
165
|
+
File.open(shim_path, 'w') { |f| shim.write(f) }
|
166
|
+
FileUtils.chmod(0755, shim_path)
|
167
|
+
end
|
168
|
+
|
169
|
+
def create_gem_shim(package_dir, gem_name, exec_name)
|
170
|
+
shim_path = package_dir.join(exec_name)
|
171
|
+
shim = GemShim.new(gem_name, exec_name)
|
152
172
|
File.open(shim_path, 'w') { |f| shim.write(f) }
|
153
173
|
FileUtils.chmod(0755, shim_path)
|
154
174
|
end
|
data/lib/tara/archiver.rb
CHANGED
@@ -31,6 +31,8 @@ module Tara
|
|
31
31
|
# expanded when including source files in archive. Should be relative from `:app_dir`.
|
32
32
|
# @option config [Array<String>] :executables (%w[bin/*]) list of globs that will be
|
33
33
|
# expanded when including executables in archive. Should be relative from `:app_dir`.
|
34
|
+
# @option config [Array<String, String>] :gem_executables ([]) list of gem and exec name
|
35
|
+
# pairs which will be included as executables in archive.
|
34
36
|
# @option config [String] :target (linux-x86_64) target platform that the archive will
|
35
37
|
# be created for. Should be one of "linux-x86", "linux-x86_64", or "osx".
|
36
38
|
# @option config [String] :traveling_ruby_version (20150210) release of Traveling Ruby
|
data/lib/tara/fetcher.rb
CHANGED
@@ -11,7 +11,7 @@ module Tara
|
|
11
11
|
@target = target
|
12
12
|
@tr_version = tr_version
|
13
13
|
@ruby_version = options[:ruby_version] || RUBY_VERSION
|
14
|
-
@release_url = options[:tr_release_url] || '
|
14
|
+
@release_url = options[:tr_release_url] || 'https://d6r77u77i8pq3.cloudfront.net/releases'
|
15
15
|
@shell = options[:shell] || Shell
|
16
16
|
end
|
17
17
|
|
@@ -44,11 +44,11 @@ module Tara
|
|
44
44
|
def fetch(remote_uri, local_uri, limit=10)
|
45
45
|
unless File.exist?(local_uri)
|
46
46
|
uri = URI(remote_uri)
|
47
|
-
Net::HTTP.start(uri.host, uri.port) do |http|
|
47
|
+
Net::HTTP.start(uri.host, uri.port, use_ssl: uri.scheme == 'https') do |http|
|
48
48
|
http.request(Net::HTTP::Get.new(uri)) do |response|
|
49
49
|
case response
|
50
50
|
when Net::HTTPSuccess
|
51
|
-
File.open(local_uri, '
|
51
|
+
File.open(local_uri, 'wb') do |f|
|
52
52
|
response.read_body do |chunk|
|
53
53
|
f.write(chunk)
|
54
54
|
end
|
data/lib/tara/shim.rb
CHANGED
@@ -3,9 +3,8 @@
|
|
3
3
|
module Tara
|
4
4
|
# @private
|
5
5
|
class Shim
|
6
|
-
def initialize(
|
7
|
-
@
|
8
|
-
@name = name
|
6
|
+
def initialize(command)
|
7
|
+
@command = command
|
9
8
|
end
|
10
9
|
|
11
10
|
def write(io)
|
@@ -21,8 +20,22 @@ module Tara
|
|
21
20
|
SELF_DIR=$(dirname "$0")
|
22
21
|
export BUNDLE_GEMFILE="$SELF_DIR/lib/vendor/Gemfile"
|
23
22
|
unset BUNDLE_IGNORE_CONFIG
|
24
|
-
exec "$SELF_DIR/lib/ruby/bin/ruby" -rbundler/setup
|
23
|
+
exec "$SELF_DIR/lib/ruby/bin/ruby" -rbundler/setup #{@command}
|
25
24
|
EOH
|
26
25
|
end
|
27
26
|
end
|
27
|
+
|
28
|
+
# @private
|
29
|
+
class ExecShim < Shim
|
30
|
+
def initialize(dirpath, name)
|
31
|
+
super(%("$SELF_DIR/#{dirpath}/#{name}" "$@"))
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
# @private
|
36
|
+
class GemShim < Shim
|
37
|
+
def initialize(gem_name, exec_name)
|
38
|
+
super(%(-e "load Gem.bin_path('#{gem_name}', '#{exec_name}')" -- "$@"))
|
39
|
+
end
|
40
|
+
end
|
28
41
|
end
|
data/lib/tara/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: tara
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.5.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Mathias Söderberg
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-10-19 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: Tara packs your Ruby app into a standalone archive with gems and a Ruby
|
14
14
|
runtime
|