gem2exe 0.1.0 → 0.3.0
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.
- checksums.yaml +4 -4
- data/.travis.yml +49 -23
- data/Dockerfile +8 -10
- data/Gemfile.lock +2 -2
- data/README.md +13 -31
- data/docker-compose.yml +1 -1
- data/exe/gem2exe +2 -2
- data/lib/gem2exe/builder.rb +42 -0
- data/lib/gem2exe/cli/local_command.rb +27 -0
- data/lib/gem2exe/cli/remote_command.rb +25 -0
- data/lib/gem2exe/cli/root_command.rb +3 -3
- data/lib/gem2exe/cli/setup_command.rb +31 -2
- data/lib/gem2exe/cli.rb +4 -1
- data/lib/gem2exe/runner.rb +102 -0
- data/lib/gem2exe/unpacker.rb +27 -0
- data/lib/gem2exe/version.rb +1 -1
- data/lib/gem2exe.rb +17 -10
- metadata +7 -3
- data/lib/gem2exe/cli/build_command.rb +0 -27
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: e3bc1d21a1b618248edd3575d5041b358e5dacf97dc7d25c9cf6ec5e1c93f541
|
|
4
|
+
data.tar.gz: f0cd12d5a6ac070fafc7cb3a93b97d8cd5d07c888aab759ed3efc6be42e7f84f
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 6555d1e969916dfe643d869cc99ede65539bc80433f24923e5ebf9655c94df85b6365baf391eac5c7b41fc779ed37e7b143e6e7c5db11a0d52572d1eb860b7a4
|
|
7
|
+
data.tar.gz: 8214ca656546373782e50e0d6c061a3d7fa1063e6d7ee1ea408727bd01791974c76339807ed2cc6770f87b2b7599b5058b6f48162b873e2dad24bca750aa77f6
|
data/.travis.yml
CHANGED
|
@@ -1,28 +1,54 @@
|
|
|
1
|
-
|
|
1
|
+
stages:
|
|
2
|
+
- name: binary
|
|
3
|
+
if: tag IS present
|
|
2
4
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
+
jobs:
|
|
6
|
+
include:
|
|
7
|
+
- stage: binary
|
|
8
|
+
os: linux
|
|
5
9
|
|
|
6
|
-
|
|
7
|
-
|
|
10
|
+
sudo: required
|
|
11
|
+
services:
|
|
12
|
+
- docker
|
|
8
13
|
|
|
9
|
-
before_install:
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
script:
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
14
|
+
before_install:
|
|
15
|
+
- sudo rm /usr/local/bin/docker-compose
|
|
16
|
+
- curl -L https://github.com/docker/compose/releases/download/1.23.2/docker-compose-`uname -s`-`uname -m` > docker-compose
|
|
17
|
+
- chmod +x docker-compose
|
|
18
|
+
- sudo mv docker-compose /usr/local/bin
|
|
19
|
+
script:
|
|
20
|
+
- docker-compose build
|
|
21
|
+
- docker create --name gem2exe gem2exe
|
|
22
|
+
- mkdir releases
|
|
23
|
+
- docker cp gem2exe:/usr/local/bin/gem2exe releases/gem2exe-linux-amd64-${TRAVIS_TAG}
|
|
24
|
+
- chmod a+x releases/gem2exe-linux-amd64-${TRAVIS_TAG}
|
|
25
|
+
- gzip releases/*
|
|
26
|
+
|
|
27
|
+
- stage: binary
|
|
28
|
+
os: osx
|
|
29
|
+
rvm:
|
|
30
|
+
- "2.6"
|
|
31
|
+
script:
|
|
32
|
+
- gem update --system
|
|
33
|
+
- bundle install
|
|
34
|
+
- bundle exec rake
|
|
35
|
+
- bundle exec rake install
|
|
36
|
+
- bundle exec gem2exe setup
|
|
37
|
+
- bundle exec gem2exe local --out releases/gem2exe-darwin-amd64-${TRAVIS_TAG} gem2exe
|
|
38
|
+
- chmod a+x releases/gem2exe-darwin-amd64-${TRAVIS_TAG}
|
|
39
|
+
- gzip releases/*
|
|
20
40
|
|
|
21
41
|
deploy:
|
|
22
|
-
provider: releases
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
42
|
+
- provider: releases
|
|
43
|
+
api_key:
|
|
44
|
+
secure: "d0uXeYO/b1yb/9NgUAlUqAqDgfCgGLxPork1qIaJ5fuK0UMtqKvJp40jLhpoiGjGrc+YvVJ55otlxH5PBnofW/QaEGYJVtWMi54VZlddsszYk6wfsVQFFgVdtGVly//ImfjEIobdEBVzJp+IjX7OA6EXriCH9VxpdwC+gEL8Fi2jyxmTtM/x16ONGxYYzImrXL5iQj8ETUgPkElVaoAm9JceApnu3iwEMR1R+U9zeWUYvBYCjehg1aKkPy42Grm5m9rsYMeQ+DossCPu873lZBl3L9Pj2BpRoBVZsAaXCwARRlfh9B5lMMWVxaf7SDrk0o7r+nSGaV3BywxuM5P0JNOBeh4z3bf/CWelMF7oSC04dgNwZbvv9YR6j+gQqFpXTU74AYVLf3Zt8b5iY30z/JQtyoWcX+QVyTrfgVsoZjjzzqdEFlbjClhYUHsV2gtqixy/78EsqDkLuLL3FXcxBNd//hwBvgUJSIBqlb4Ecnfu1bxLVW/xHUQReklFAv5XhNJSAlrzLVdRdaBnFS3zjxJ11VHVZH1b+gTbBXWG3iUtS5wWZV5MmcOrc5QdZQOgtVfnmW0pRoGUzrA4S/QLUkzuhcYFodvv19UTyO9mDQgf3K9+sJ3XtcUKiTcHmg1WzFp35BGi6PVhXTtgg2LcsmHhkGxMuCu0S/ksX2mXoZw="
|
|
45
|
+
file_glob: true
|
|
46
|
+
file: releases/*
|
|
47
|
+
skip_cleanup: true
|
|
48
|
+
on:
|
|
49
|
+
tags: true
|
|
50
|
+
- provider: rubygems
|
|
51
|
+
api_key:
|
|
52
|
+
secure: "oNnsB58gFTwkBu+XpxhnFGfaMBonKghmh08NnH4naPmOH4aOkCwI2CB7UIBKq3dmZlfO9h67nVyQ9NvDVhmOrsSxkudzluIZ0RXiaz57YuWYP21j7TeyssuQIUaXEBbRuE/wb85rdYtRY+je6/vJjVZoRk524/VnWBf+guIRTY6yZWBzxwn/zECZsQgL7i9rXbaFO2Sm5XRDW//hwiIijqdBjQ3zvWeMSKh2in0GgCgbVmarYxFAV8bTXUgCOQIDM9Je4Q647430p8VpQ9kbhhSF2bdJVeeuUIMdnTel+OGjdejMoSEHIyRB1+QjPGKKXzx8JSOcON7C78af0lyZf6NEtJK4DnHfA6OJORhNSL4xvHvxlR20iiCuplOnLujzBppxnkA25ck4R5OodXkYUVT8dL+z6S2kDsnkiQ25frdHBks9MDD4AumdezhM06NbLWdwhJbN8D0B47z14ZSXOQ1zNYg2mqVidZS/qhbtlQEib70jIgGquj17ETEgTTSiyI0C5myc/rkLc1UYs8rKT7fY5VGeaaFmyHC/oQWSaM709rAJe35UvyYo6mTMBI6g/Vy8jmh1ZodXlzJE/CXfAkTI6s/zP2rABlnz3hxggE95ZEDrlO8q7v/njXGGpPjTH8HtAkqNzBDJEDRXPpB2jBuhhx75ho1YlCVYJj2lpOY="
|
|
53
|
+
on:
|
|
54
|
+
branch: master
|
data/Dockerfile
CHANGED
|
@@ -1,19 +1,17 @@
|
|
|
1
1
|
FROM ruby:2.6.0 as builder
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
RUN curl -sL https://github.com/kontena/ruby-packer/releases/download/0.5.0%2Bextra7/rubyc-0.5.0+extra7-linux-amd64.gz | gunzip > /usr/local/bin/rubyc
|
|
6
|
-
RUN chmod +x /usr/local/bin/rubyc
|
|
7
|
-
|
|
8
|
-
RUN update-ca-certificates
|
|
9
|
-
|
|
10
|
-
WORKDIR /app
|
|
3
|
+
WORKDIR /build
|
|
11
4
|
COPY . .
|
|
12
5
|
|
|
13
|
-
RUN
|
|
6
|
+
RUN bundle install
|
|
7
|
+
RUN rake
|
|
8
|
+
RUN rake install
|
|
9
|
+
RUN gem2exe setup
|
|
10
|
+
RUN gem2exe local gem2exe
|
|
14
11
|
|
|
15
12
|
# -----------
|
|
16
13
|
FROM ubuntu:18.04
|
|
17
|
-
|
|
14
|
+
RUN apt-get update && apt-get install -y git-core
|
|
15
|
+
COPY --from=builder /build/gem2exe /usr/local/bin
|
|
18
16
|
RUN /usr/local/bin/gem2exe setup
|
|
19
17
|
ENTRYPOINT [ "/usr/local/bin/gem2exe" ]
|
data/Gemfile.lock
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
PATH
|
|
2
2
|
remote: .
|
|
3
3
|
specs:
|
|
4
|
-
gem2exe (0.
|
|
4
|
+
gem2exe (0.3.0)
|
|
5
5
|
clamp (= 1.3.0)
|
|
6
6
|
|
|
7
7
|
GEM
|
|
@@ -29,9 +29,9 @@ PLATFORMS
|
|
|
29
29
|
|
|
30
30
|
DEPENDENCIES
|
|
31
31
|
bundler (~> 1.16)
|
|
32
|
+
gem2exe!
|
|
32
33
|
rake (~> 10.0)
|
|
33
34
|
rspec (~> 3.0)
|
|
34
|
-
gem2exe!
|
|
35
35
|
|
|
36
36
|
BUNDLED WITH
|
|
37
37
|
1.16.6
|
data/README.md
CHANGED
|
@@ -1,39 +1,21 @@
|
|
|
1
|
-
#
|
|
1
|
+
# gem2exe
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Uses https://github.com/kontena/ruby-packer/releases
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
## local gems
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
Building a local gem:
|
|
8
8
|
|
|
9
|
-
|
|
9
|
+
cd yourgem
|
|
10
|
+
gem2exe local command-to-start-gem
|
|
10
11
|
|
|
11
|
-
|
|
12
|
-
gem 'gem2exe'
|
|
13
|
-
```
|
|
12
|
+
Full options:
|
|
14
13
|
|
|
15
|
-
|
|
14
|
+
gem2exe local --path /path/to/your/gem \
|
|
15
|
+
--out /build/name \
|
|
16
|
+
--cache-dir /tmp/cache \
|
|
17
|
+
command-to-start-gem
|
|
16
18
|
|
|
17
|
-
|
|
19
|
+
## remote gems
|
|
18
20
|
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
$ gem install gem2exe
|
|
22
|
-
|
|
23
|
-
## Usage
|
|
24
|
-
|
|
25
|
-
TODO: Write usage instructions here
|
|
26
|
-
|
|
27
|
-
## Development
|
|
28
|
-
|
|
29
|
-
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
|
30
|
-
|
|
31
|
-
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
|
32
|
-
|
|
33
|
-
## Contributing
|
|
34
|
-
|
|
35
|
-
Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/gem2exe.
|
|
36
|
-
|
|
37
|
-
## License
|
|
38
|
-
|
|
39
|
-
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
|
21
|
+
TODO
|
data/docker-compose.yml
CHANGED
data/exe/gem2exe
CHANGED
|
@@ -8,6 +8,6 @@ require 'pathname'
|
|
|
8
8
|
lib_path = File.expand_path('../../lib', Pathname.new(__FILE__).realpath)
|
|
9
9
|
$LOAD_PATH.unshift lib_path unless $LOAD_PATH.include?(lib_path)
|
|
10
10
|
|
|
11
|
-
require '
|
|
12
|
-
require '
|
|
11
|
+
require 'gem2exe'
|
|
12
|
+
require 'gem2exe/cli'
|
|
13
13
|
Gem2exe::Cli::RootCommand.run
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
require "tmpdir"
|
|
2
|
+
require "fileutils"
|
|
3
|
+
module Gem2exe
|
|
4
|
+
class Builder
|
|
5
|
+
def initialize(path:,entrypoint:,out:,cores:nil,cache_dir:nil)
|
|
6
|
+
@path = path
|
|
7
|
+
@entrypoint = entrypoint
|
|
8
|
+
@out = out
|
|
9
|
+
@cores = (cores || self.cores+1)
|
|
10
|
+
@tmpdir = (cache_dir || Dir.mktmpdir)
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
def build
|
|
14
|
+
FileUtils.mkdir_p File.dirname(@out)
|
|
15
|
+
|
|
16
|
+
cmd = [Gem2exe.rubyc_path]
|
|
17
|
+
if Gem2exe.platform == "darwin"
|
|
18
|
+
cmd += ["--openssl-dir", "/usr/local/etc/openssl"]
|
|
19
|
+
else
|
|
20
|
+
cmd += ["--openssl-dir", "/etc/ssl"]
|
|
21
|
+
end
|
|
22
|
+
cmd += ["--root", @path]
|
|
23
|
+
cmd += ["-o", @out]
|
|
24
|
+
cmd += ["-d", @tmpdir]
|
|
25
|
+
cmd += ["--make-args", "-j#{@cores}"]
|
|
26
|
+
cmd += [@entrypoint]
|
|
27
|
+
|
|
28
|
+
Runner.run! cmd, output: true
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
protected
|
|
33
|
+
|
|
34
|
+
def cores
|
|
35
|
+
if Gem2exe.platform == "darwin"
|
|
36
|
+
Integer(`sysctl -n hw.ncpu`)
|
|
37
|
+
else
|
|
38
|
+
Integer(`nproc`)
|
|
39
|
+
end
|
|
40
|
+
end
|
|
41
|
+
end
|
|
42
|
+
end
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Gem2exe
|
|
4
|
+
module Cli
|
|
5
|
+
class LocalCommand < Clamp::Command
|
|
6
|
+
parameter "ENTRYPOINT", "entrypoint"
|
|
7
|
+
option "--cache-dir", "CACHE_DIR", "build cache dir"
|
|
8
|
+
option "--path", "PATH", "path to gem, defaults to working directory"
|
|
9
|
+
option "--out", "OUT", "executable, defaults to entrypoint"
|
|
10
|
+
|
|
11
|
+
def execute
|
|
12
|
+
Gem2exe.ensure_setup
|
|
13
|
+
|
|
14
|
+
out_with_path = out || entrypoint
|
|
15
|
+
|
|
16
|
+
path_expanded = if path
|
|
17
|
+
File.expand_path(path)
|
|
18
|
+
else
|
|
19
|
+
Dir.pwd
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
builder = Builder.new path: path_expanded, entrypoint: entrypoint, out: out_with_path, cache_dir: cache_dir
|
|
23
|
+
builder.build
|
|
24
|
+
end
|
|
25
|
+
end
|
|
26
|
+
end
|
|
27
|
+
end
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Gem2exe
|
|
4
|
+
module Cli
|
|
5
|
+
class RemoteCommand < Clamp::Command
|
|
6
|
+
parameter "GEM", "gem"
|
|
7
|
+
parameter "VERSION", "version"
|
|
8
|
+
parameter "ENTRYPOINT", "entrypoint"
|
|
9
|
+
|
|
10
|
+
option "--cache-dir", "CACHE_DIR", "build cache dir"
|
|
11
|
+
option "--out", "OUT", "executable, defaults to entrypoint"
|
|
12
|
+
|
|
13
|
+
def execute
|
|
14
|
+
Gem2exe.ensure_setup
|
|
15
|
+
out_with_path = out || entrypoint
|
|
16
|
+
|
|
17
|
+
unpacker = Unpacker.new gem: gem, version: version
|
|
18
|
+
unpacker.unpack
|
|
19
|
+
|
|
20
|
+
builder = Builder.new path: unpacker.path, entrypoint: entrypoint, out: out_with_path, cache_dir: cache_dir
|
|
21
|
+
builder.build
|
|
22
|
+
end
|
|
23
|
+
end
|
|
24
|
+
end
|
|
25
|
+
end
|
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
-
require_relative "build_command"
|
|
4
|
-
|
|
5
3
|
module Gem2exe
|
|
6
4
|
module Cli
|
|
7
5
|
class RootCommand < Clamp::Command
|
|
@@ -15,7 +13,9 @@ module Gem2exe
|
|
|
15
13
|
subcommand ["setup"], "setup", SetupCommand
|
|
16
14
|
subcommand ["uninstall"], "uninstall", UninstallCommand
|
|
17
15
|
|
|
18
|
-
subcommand ["
|
|
16
|
+
subcommand ["local"], "local", LocalCommand
|
|
17
|
+
subcommand ["remote"], "remote", RemoteCommand
|
|
18
|
+
|
|
19
19
|
subcommand ["version"], "Show version information", VersionCommand
|
|
20
20
|
|
|
21
21
|
def self.run
|
|
@@ -3,10 +3,39 @@
|
|
|
3
3
|
module Gem2exe
|
|
4
4
|
module Cli
|
|
5
5
|
class SetupCommand < Clamp::Command
|
|
6
|
+
option "--sudo", :flag, "use sudo"
|
|
7
|
+
|
|
6
8
|
def execute
|
|
7
|
-
|
|
9
|
+
$stderr.puts "installing dependencies ..."
|
|
10
|
+
|
|
11
|
+
if Gem2exe.platform == "darwin"
|
|
12
|
+
runner_opts = {
|
|
13
|
+
shell: true, output: true, prepend: {
|
|
14
|
+
stdboth: " brew: "
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
Runner.run! "brew install squashfs || brew upgrade squashfs || true", runner_opts
|
|
19
|
+
Runner.run! "brew install openssl || brew upgrade openssl || true", runner_opts
|
|
20
|
+
Runner.run! "curl -sL https://curl.haxx.se/ca/cacert.pem > /usr/local/etc/openssl/cacert.pem", runner_opts
|
|
21
|
+
else
|
|
22
|
+
runner_opts = {
|
|
23
|
+
sudo: sudo?, shell: true, output: true, prepend: {
|
|
24
|
+
stdboth: " apt-get: "
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
$stderr.puts "installing dependencies with apt-get ..."
|
|
28
|
+
Runner.run! "apt-get update", runner_opts
|
|
29
|
+
Runner.run! "apt-get install -y ruby squashfs-tools build-essential bison curl", runner_opts
|
|
30
|
+
end
|
|
31
|
+
$stderr.puts "... dependencies installed"
|
|
32
|
+
|
|
33
|
+
$stderr.puts "installing rubyc ..."
|
|
34
|
+
Gem2exe.download_rubyc
|
|
35
|
+
$stderr.puts "... rubyc installed"
|
|
8
36
|
|
|
9
|
-
puts "
|
|
37
|
+
puts ""
|
|
38
|
+
puts "setup ok"
|
|
10
39
|
end
|
|
11
40
|
end
|
|
12
41
|
end
|
data/lib/gem2exe/cli.rb
CHANGED
|
@@ -1,8 +1,11 @@
|
|
|
1
1
|
require 'clamp'
|
|
2
|
+
Clamp.allow_options_after_parameters = true
|
|
2
3
|
|
|
3
4
|
require_relative "cli/version_command"
|
|
4
5
|
require_relative "cli/setup_command"
|
|
5
6
|
require_relative "cli/uninstall_command"
|
|
6
7
|
|
|
7
|
-
require_relative "cli/
|
|
8
|
+
require_relative "cli/local_command"
|
|
9
|
+
require_relative "cli/remote_command"
|
|
10
|
+
|
|
8
11
|
require_relative "cli/root_command"
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
require "open3"
|
|
2
|
+
|
|
3
|
+
module Gem2exe
|
|
4
|
+
class RunnerError < StandardError
|
|
5
|
+
end
|
|
6
|
+
class RunnerBuffer
|
|
7
|
+
def initialize
|
|
8
|
+
@buffer = []
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
def <<(c)
|
|
12
|
+
@buffer << c
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
def to_s
|
|
16
|
+
@buffer.join ""
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
def method_missing(m, *args, &block)
|
|
20
|
+
to_s.send m, *args, block
|
|
21
|
+
end
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
class Runner
|
|
25
|
+
def initialize(cmd, env:nil, shell:false, sudo:false, chdir:nil, output:false,prepend:{})
|
|
26
|
+
cmd.insert(0, "sudo") if sudo
|
|
27
|
+
@cmd = if shell
|
|
28
|
+
["sh","-c"] + [cmd.join(" ")]
|
|
29
|
+
else
|
|
30
|
+
cmd
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
@env = (env || {})
|
|
34
|
+
@opts = {}
|
|
35
|
+
@opts[:chdir] = chdir if chdir
|
|
36
|
+
@output = output
|
|
37
|
+
@prepend = {}
|
|
38
|
+
if prepend[:stdboth]
|
|
39
|
+
@prepend[:stderr] = prepend[:stdboth]
|
|
40
|
+
@prepend[:stdout] = prepend[:stdboth]
|
|
41
|
+
else
|
|
42
|
+
@prepend = prepend
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
@status, @stdout, @stderr, @stdboth = nil, RunnerBuffer.new, RunnerBuffer.new, RunnerBuffer.new
|
|
46
|
+
end
|
|
47
|
+
attr_reader :status, :stdout, :stderr, :stdboth
|
|
48
|
+
|
|
49
|
+
def self.run!(cmd_string_or_array, opts={})
|
|
50
|
+
cmd = if cmd_string_or_array.is_a? Array
|
|
51
|
+
cmd_string_or_array
|
|
52
|
+
else
|
|
53
|
+
cmd_string_or_array.split(" ")
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
runner = self.new cmd, opts
|
|
57
|
+
runner.run
|
|
58
|
+
|
|
59
|
+
if runner.status.exitstatus != 0
|
|
60
|
+
exit 1
|
|
61
|
+
end
|
|
62
|
+
|
|
63
|
+
runner
|
|
64
|
+
end
|
|
65
|
+
|
|
66
|
+
def run
|
|
67
|
+
executable, *args = @cmd
|
|
68
|
+
stdin, stdout, stderr, wait_thr = Open3.popen3(@env, executable, *args, @opts)
|
|
69
|
+
|
|
70
|
+
stderr_thr = Thread.new do
|
|
71
|
+
stderr.each do |line|
|
|
72
|
+
@stdboth << line
|
|
73
|
+
@stderr << line
|
|
74
|
+
if @prepend[:stderr]
|
|
75
|
+
$stdout.print @prepend[:stderr]+line
|
|
76
|
+
else
|
|
77
|
+
$stdout.print line
|
|
78
|
+
end
|
|
79
|
+
end
|
|
80
|
+
end
|
|
81
|
+
|
|
82
|
+
stdout_thr = Thread.new do
|
|
83
|
+
stdout.each do |line|
|
|
84
|
+
@stdboth << line
|
|
85
|
+
@stderr << line
|
|
86
|
+
|
|
87
|
+
if @prepend[:stdout]
|
|
88
|
+
$stdout.print @prepend[:stdout]+line
|
|
89
|
+
else
|
|
90
|
+
$stdout.print line
|
|
91
|
+
end
|
|
92
|
+
end
|
|
93
|
+
end
|
|
94
|
+
|
|
95
|
+
wait_thr.join
|
|
96
|
+
stdout_thr.join
|
|
97
|
+
stderr_thr.join
|
|
98
|
+
|
|
99
|
+
@status = wait_thr.value
|
|
100
|
+
end
|
|
101
|
+
end
|
|
102
|
+
end
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
require "tmpdir"
|
|
2
|
+
|
|
3
|
+
module Gem2exe
|
|
4
|
+
class Unpacker
|
|
5
|
+
def initialize(gem:,version:)
|
|
6
|
+
@gem = gem
|
|
7
|
+
@version = version
|
|
8
|
+
@tmpdir = Dir.mktmpdir
|
|
9
|
+
@path = File.join(
|
|
10
|
+
@tmpdir,
|
|
11
|
+
"#{@gem}-#{@version}"
|
|
12
|
+
)
|
|
13
|
+
end
|
|
14
|
+
attr_reader :path
|
|
15
|
+
|
|
16
|
+
def unpack
|
|
17
|
+
cmd = ["gem", "unpack", @gem, "-v", @version]
|
|
18
|
+
|
|
19
|
+
r = Runner.run! cmd, chdir: @tmpdir, output: true
|
|
20
|
+
unless r.stderr.start_with? "Unpacked gem:"
|
|
21
|
+
exit 1
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
self
|
|
25
|
+
end
|
|
26
|
+
end
|
|
27
|
+
end
|
data/lib/gem2exe/version.rb
CHANGED
data/lib/gem2exe.rb
CHANGED
|
@@ -1,31 +1,35 @@
|
|
|
1
1
|
require "fileutils"
|
|
2
2
|
|
|
3
3
|
module Gem2exe
|
|
4
|
-
def self.cores
|
|
5
|
-
Integer(`sysctl -n hw.ncpu`)
|
|
6
|
-
end
|
|
7
|
-
|
|
8
4
|
def self.uninstall
|
|
9
5
|
FileUtils.rm_rf install_path
|
|
10
6
|
end
|
|
11
7
|
|
|
12
|
-
def self.
|
|
13
|
-
return if File.
|
|
8
|
+
def self.download_rubyc
|
|
9
|
+
return if File.exist? rubyc_path
|
|
14
10
|
FileUtils.mkdir_p File.dirname(self.rubyc_path)
|
|
15
11
|
|
|
16
12
|
rubyc_url = if self.platform == "darwin"
|
|
17
|
-
|
|
18
|
-
"https://dl.bintray.com/kontena/ruby-packer/0.5.0-dev/rubyc-0.5.0-extra2-darwin-amd64.gz"
|
|
13
|
+
"https://github.com/kontena/ruby-packer/releases/download/2.6.0-0.6.0/rubyc-2.6.0-0.6.0-osx-amd64.gz"
|
|
19
14
|
else
|
|
20
15
|
"https://github.com/kontena/ruby-packer/releases/download/2.6.0-0.6.0/rubyc-2.6.0-0.6.0-linux-amd64.gz"
|
|
21
16
|
end
|
|
22
17
|
|
|
23
18
|
$stderr.puts "downloading rubyc from #{rubyc_url}"
|
|
24
|
-
|
|
25
|
-
|
|
19
|
+
|
|
20
|
+
Runner.run! "curl -sL #{rubyc_url} | gunzip > #{self.rubyc_path}", shell: true
|
|
21
|
+
Runner.run! "chmod +x #{self.rubyc_path}"
|
|
22
|
+
|
|
26
23
|
$stderr.puts "installed in #{self.rubyc_path}"
|
|
27
24
|
end
|
|
28
25
|
|
|
26
|
+
def self.ensure_setup
|
|
27
|
+
unless File.exists? self.rubyc_path
|
|
28
|
+
$stderr.puts "rubyc not found - run: gem2exe setup"
|
|
29
|
+
exit 1
|
|
30
|
+
end
|
|
31
|
+
end
|
|
32
|
+
|
|
29
33
|
def self.rubyc_path
|
|
30
34
|
install_path_parts = [self.install_path]
|
|
31
35
|
install_path_parts << self.platform
|
|
@@ -48,3 +52,6 @@ module Gem2exe
|
|
|
48
52
|
end
|
|
49
53
|
|
|
50
54
|
require_relative "gem2exe/version"
|
|
55
|
+
require_relative "gem2exe/builder"
|
|
56
|
+
require_relative "gem2exe/unpacker"
|
|
57
|
+
require_relative "gem2exe/runner"
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: gem2exe
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.3.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Matti Paksula
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: exe
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2019-01-
|
|
11
|
+
date: 2019-01-21 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: clamp
|
|
@@ -89,12 +89,16 @@ files:
|
|
|
89
89
|
- exe/gem2exe
|
|
90
90
|
- gem2exe.gemspec
|
|
91
91
|
- lib/gem2exe.rb
|
|
92
|
+
- lib/gem2exe/builder.rb
|
|
92
93
|
- lib/gem2exe/cli.rb
|
|
93
|
-
- lib/gem2exe/cli/
|
|
94
|
+
- lib/gem2exe/cli/local_command.rb
|
|
95
|
+
- lib/gem2exe/cli/remote_command.rb
|
|
94
96
|
- lib/gem2exe/cli/root_command.rb
|
|
95
97
|
- lib/gem2exe/cli/setup_command.rb
|
|
96
98
|
- lib/gem2exe/cli/uninstall_command.rb
|
|
97
99
|
- lib/gem2exe/cli/version_command.rb
|
|
100
|
+
- lib/gem2exe/runner.rb
|
|
101
|
+
- lib/gem2exe/unpacker.rb
|
|
98
102
|
- lib/gem2exe/version.rb
|
|
99
103
|
homepage: https://github.com/matti/gem2exe
|
|
100
104
|
licenses:
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
require "tmpdir"
|
|
4
|
-
|
|
5
|
-
module Gem2exe
|
|
6
|
-
module Cli
|
|
7
|
-
class BuildCommand < Clamp::Command
|
|
8
|
-
parameter "NAME", "name"
|
|
9
|
-
option "--cache-dir", "CACHE_DIR", "build cache dir"
|
|
10
|
-
|
|
11
|
-
def execute
|
|
12
|
-
cores = Gem2exe.cores + 1
|
|
13
|
-
tmpdir = if cache_dir
|
|
14
|
-
cache_dir
|
|
15
|
-
else
|
|
16
|
-
Dir.mktmpdir
|
|
17
|
-
end
|
|
18
|
-
|
|
19
|
-
if Gem2exe.platform == "darwin"
|
|
20
|
-
`"#{Gem2exe.rubyc_path}" --openssl-dir=/usr/local/etc/openssl -o "#{name}" -d "#{tmpdir}" --make-args="-j#{cores} --silent" #{name}`
|
|
21
|
-
else
|
|
22
|
-
`"#{Gem2exe.rubyc_path}" --openssl-dir=/etc/ssl rubyc -o "#{name}" -d "#{tmpdir}" --make-args="-j#{cores}" #{name}`
|
|
23
|
-
end
|
|
24
|
-
end
|
|
25
|
-
end
|
|
26
|
-
end
|
|
27
|
-
end
|