-
Notifications
You must be signed in to change notification settings - Fork 2
/
Rakefile
84 lines (72 loc) · 2.94 KB
/
Rakefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
# For Bundler.with_clean_env
require 'bundler/setup'
PACKAGE_NAME = "file-extractor"
VERSION = "1.0.0"
TRAVELING_RUBY_VERSION = "20150715-2.2.2"
desc "Package your app"
task :package => ['package:linux:x86', 'package:linux:x86_64', 'package:osx']
namespace :package do
namespace :linux do
desc "Package your app for Linux x86"
task :x86 => [:bundle_install, "packaging/traveling-ruby-#{TRAVELING_RUBY_VERSION}-linux-x86.tar.gz"] do
create_package("linux-x86")
end
desc "Package your app for Linux x86_64"
task :x86_64 => [:bundle_install, "packaging/traveling-ruby-#{TRAVELING_RUBY_VERSION}-linux-x86_64.tar.gz"] do
create_package("linux-x86_64")
end
end
desc "Package your app for OS X"
task :osx => [:bundle_install, "packaging/traveling-ruby-#{TRAVELING_RUBY_VERSION}-osx.tar.gz"] do
create_package("osx")
end
desc "Install gems to local directory"
task :bundle_install do
if RUBY_VERSION !~ /^2\.2\./
abort "You can only 'bundle install' using Ruby 2.2, because that's what Traveling Ruby uses."
end
sh "rm -rf packaging/tmp"
sh "mkdir packaging/tmp"
sh "cp Gemfile Gemfile.lock packaging/tmp/"
Bundler.with_clean_env do
sh "cd packaging/tmp && env BUNDLE_IGNORE_CONFIG=1 bundle install --path ../vendor --without development"
end
sh "rm -rf packaging/tmp"
sh "rm -f packaging/vendor/*/*/cache/*"
end
end
file "packaging/traveling-ruby-#{TRAVELING_RUBY_VERSION}-linux-x86.tar.gz" do
download_runtime("linux-x86")
end
file "packaging/traveling-ruby-#{TRAVELING_RUBY_VERSION}-linux-x86_64.tar.gz" do
download_runtime("linux-x86_64")
end
file "packaging/traveling-ruby-#{TRAVELING_RUBY_VERSION}-osx.tar.gz" do
download_runtime("osx")
end
def create_package(target)
package_dir = "#{PACKAGE_NAME}-#{VERSION}-#{target}"
sh "rm -rf #{package_dir}"
sh "mkdir #{package_dir}"
sh "mkdir #{package_dir}/lib"
sh "mkdir #{package_dir}/lib/file-extractor"
sh "cp -r bin #{package_dir}/lib/file-extractor/bin"
sh "cp -r lib #{package_dir}/lib/file-extractor/lib"
sh "mkdir #{package_dir}/lib/ruby"
sh "tar -xzf packaging/traveling-ruby-#{TRAVELING_RUBY_VERSION}-#{target}.tar.gz -C #{package_dir}/lib/ruby"
sh "cd packaging && swift build -c release -Xswiftc -static-stdlib && cp $(swift build -c release --show-bin-path)/file-extractor ."
sh "cp packaging/file-extractor #{package_dir}/#{PACKAGE_NAME}"
sh "rm packaging/file-extractor"
sh "cp -pR packaging/vendor #{package_dir}/lib/"
sh "cp Gemfile Gemfile.lock #{package_dir}/lib/vendor/"
sh "mkdir #{package_dir}/lib/vendor/.bundle"
sh "cp packaging/bundler-config #{package_dir}/lib/vendor/.bundle/config"
if !ENV['DIR_ONLY']
sh "tar -czf #{package_dir}.tar.gz #{package_dir}"
sh "rm -rf #{package_dir}"
end
end
def download_runtime(target)
sh "cd packaging && curl -L -O --fail " +
"https://d6r77u77i8pq3.cloudfront.net/releases/traveling-ruby-#{TRAVELING_RUBY_VERSION}-#{target}.tar.gz"
end