rake-compiler-dock 0.3.1 → 0.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- checksums.yaml.gz.sig +0 -0
- data.tar.gz.sig +2 -1
- data/History.md +10 -0
- data/README.md +15 -8
- data/bin/rake-compiler-dock +7 -1
- data/lib/rake_compiler_dock.rb +9 -102
- data/lib/rake_compiler_dock/colors.rb +43 -0
- data/lib/rake_compiler_dock/docker_check.rb +159 -0
- data/lib/rake_compiler_dock/starter.rb +121 -0
- data/lib/rake_compiler_dock/version.rb +1 -1
- data/rake-compiler-dock.gemspec +1 -0
- data/src/runas +4 -4
- metadata +6 -3
- metadata.gz.sig +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6c62efef1a82d18b2fd09f02ba508c683693b306
|
4
|
+
data.tar.gz: c6908768b4f5af935e1080fad7f2f08d5942cfe4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: cba0c38a91c5325e7bfc9137f7b197da46064db824cb6f425b84854993a7dfcd4b5bf7e066f427b6205e72732f69fb43ce3da0d613062df07b100cc1d251e43b
|
7
|
+
data.tar.gz: efed7ff1813b06cce9b396b208843146a19b4e0ed0f6a6def118655099ad378ce2bb3ceb2e64875ae21d3ee185ce99c4017420981edaaf185518c763ebe16fa5
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
data.tar.gz.sig
CHANGED
@@ -1 +1,2 @@
|
|
1
|
-
|
1
|
+
K�cݗ`�Уw�.=_���hc�v��t�d��W:E�`�4�.�?��'_�כ3E]0���҃I������5�6��v�&����ß�Gћ�����j��Y���K���ĻO�MC���ްR��D�˫����l��w���鄍�|�TP庅���?��{�W�bȑA��09�\V�t�
|
2
|
+
,�m1ә���rwN)ZT0�z���*O|�U�e9�H�h��Us����r�lgcR&v������۔��
|
data/History.md
CHANGED
@@ -1,3 +1,13 @@
|
|
1
|
+
0.4.0 / 2015-06-29
|
2
|
+
------------------
|
3
|
+
* Add support for OS-X.
|
4
|
+
* Try boot2docker init and start, when docker is not available.
|
5
|
+
* Add colorized terminal output.
|
6
|
+
* Fix usage of STDIN for sending data/commands into the container.
|
7
|
+
* Limit gemspec to ruby-1.9.3 or newer.
|
8
|
+
* Allow spaces in user name and path on the host side.
|
9
|
+
|
10
|
+
|
1
11
|
0.3.1 / 2015-06-24
|
2
12
|
------------------
|
3
13
|
* Add :sigfw and :runas options.
|
data/README.md
CHANGED
@@ -28,19 +28,26 @@ Install rake-compiler-dock as a gem. The docker image is downloaded later on dem
|
|
28
28
|
|
29
29
|
## Usage
|
30
30
|
|
31
|
-
Rake-compiler-dock offers the shell command `rake-compiler-dock` and a [ruby API
|
32
|
-
Both mount the current working directory into the docker environment.
|
33
|
-
All commands are executed with the current user and group of the host.
|
34
|
-
This is done by copying account data into the container and sudo to it.
|
31
|
+
Rake-compiler-dock offers the shell command `rake-compiler-dock` and a [ruby API](http://www.rubydoc.info/gems/rake-compiler-dock/RakeCompilerDock) for issuing commands within the docker image, described below.
|
35
32
|
|
36
33
|
`rake-compiler-dock` without arguments starts an interactive shell session.
|
34
|
+
This is best suited to try out and debug a build.
|
35
|
+
It mounts the current working directory into the docker environment.
|
37
36
|
All changes below the current working directory are shared with the host.
|
38
|
-
But note, that all other changes to the file system of the
|
37
|
+
But note, that all other changes to the file system of the container are dropped at the end of the session - the docker image is stateless. `rake-compiler-dock` can also take the build command(s) from STDIN or as command arguments.
|
39
38
|
|
40
|
-
|
39
|
+
All commands are executed with the same user and group of the host.
|
40
|
+
This is done by copying user account data into the container and sudo to it.
|
41
41
|
|
42
|
-
|
43
|
-
|
42
|
+
To build x86- and x64 Windows (RubyInstaller) binary gems interactively, it can be called like this:
|
43
|
+
|
44
|
+
user@host:$ cd your-gem-dir/
|
45
|
+
user@host:$ rake-compiler-dock # this enters a container with an interactive shell
|
46
|
+
user@5b53794ada92:$ bundle
|
47
|
+
user@5b53794ada92:$ rake cross native gem
|
48
|
+
user@5b53794ada92:$ exit
|
49
|
+
user@host:$ ls pkg/*.gem
|
50
|
+
your-gem-1.0.0.gem your-gem-1.0.0-x64-mingw32.gem your-gem-1.0.0-x86-mingw32.gem
|
44
51
|
|
45
52
|
The installed cross rubies can be listed like this:
|
46
53
|
|
data/bin/rake-compiler-dock
CHANGED
@@ -2,7 +2,13 @@
|
|
2
2
|
|
3
3
|
require 'rake_compiler_dock'
|
4
4
|
|
5
|
-
args = ARGV.empty? ? ['bash'
|
5
|
+
args = ARGV.empty? ? ['bash'] : ARGV.dup
|
6
|
+
|
7
|
+
if $stdin.tty?
|
8
|
+
# An interactive session should not leave the container on Ctrl-C
|
9
|
+
args << {sigfw: false}
|
10
|
+
end
|
11
|
+
|
6
12
|
begin
|
7
13
|
RakeCompilerDock.exec(*args) do |ok, res|
|
8
14
|
exit(res.exitstatus)
|
data/lib/rake_compiler_dock.rb
CHANGED
@@ -1,9 +1,9 @@
|
|
1
|
-
require "
|
1
|
+
require "rake_compiler_dock/colors"
|
2
|
+
require "rake_compiler_dock/docker_check"
|
3
|
+
require "rake_compiler_dock/starter"
|
2
4
|
require "rake_compiler_dock/version"
|
3
5
|
|
4
6
|
module RakeCompilerDock
|
5
|
-
class DockerIsNotAvailable < RuntimeError
|
6
|
-
end
|
7
7
|
|
8
8
|
# Run the command cmd within a fresh rake-compiler-dock container and within a shell.
|
9
9
|
#
|
@@ -25,14 +25,11 @@ module RakeCompilerDock
|
|
25
25
|
# end
|
26
26
|
# end
|
27
27
|
def sh(cmd, options={}, &block)
|
28
|
-
|
29
|
-
$stderr.puts "rake-compiler-dock bash -c #{ cmd.inspect }"
|
30
|
-
end
|
31
|
-
exec('bash', '-c', cmd, options, &block)
|
28
|
+
Starter.sh(cmd, options, &block)
|
32
29
|
end
|
33
30
|
|
34
31
|
def image_name
|
35
|
-
|
32
|
+
Starter.image_name
|
36
33
|
end
|
37
34
|
|
38
35
|
# Run the command cmd within a fresh rake-compiler-dock container.
|
@@ -46,104 +43,14 @@ module RakeCompilerDock
|
|
46
43
|
# * Option +:check_docker+ can be set to false to disable the docker check.
|
47
44
|
# * Option +:sigfw+ can be set to false to not stop the container on Ctrl-C.
|
48
45
|
# * Option +:runas+ can be set to false to execute the command as user root.
|
46
|
+
# * Option +:options+ can be an Array of additional options to the 'docker run' command.
|
49
47
|
#
|
50
48
|
# Examples:
|
51
49
|
#
|
52
50
|
# RakeCompilerDock.exec 'bash', '-c', 'echo $RUBY_CC_VERSION'
|
53
|
-
def exec(*args)
|
54
|
-
|
55
|
-
runargs = args.dup
|
56
|
-
|
57
|
-
check_docker if options.fetch(:check_docker){ true }
|
58
|
-
runargs.unshift("sigfw") if options.fetch(:sigfw){ true }
|
59
|
-
runargs.unshift("runas") if options.fetch(:runas){ true }
|
60
|
-
|
61
|
-
if RUBY_PLATFORM =~ /mingw|mswin/
|
62
|
-
# Change Path from "C:\Path" to "/c/Path" as used by boot2docker
|
63
|
-
pwd = Dir.pwd.gsub(/^([a-z]):/i){ "/#{$1.downcase}" }
|
64
|
-
uid = 1000
|
65
|
-
gid = 1000
|
66
|
-
else
|
67
|
-
pwd = Dir.pwd
|
68
|
-
uid = Process.uid
|
69
|
-
gid = Process.gid
|
70
|
-
end
|
71
|
-
user = `id -nu`.chomp
|
72
|
-
group = `id -ng`.chomp
|
73
|
-
|
74
|
-
cmd = ["docker", "run", "--rm", "-i", "-t",
|
75
|
-
"-v", "#{pwd}:#{pwd}",
|
76
|
-
"-e", "UID=#{uid}",
|
77
|
-
"-e", "GID=#{gid}",
|
78
|
-
"-e", "USER=#{user}",
|
79
|
-
"-e", "GROUP=#{group}",
|
80
|
-
"-e", "ftp_proxy=#{ENV['ftp_proxy']}",
|
81
|
-
"-e", "http_proxy=#{ENV['http_proxy']}",
|
82
|
-
"-e", "https_proxy=#{ENV['https_proxy']}",
|
83
|
-
"-w", pwd,
|
84
|
-
image_name,
|
85
|
-
*runargs]
|
86
|
-
|
87
|
-
cmdline = Shellwords.join(cmd)
|
88
|
-
if verbose_flag(options) == true
|
89
|
-
$stderr.puts cmdline
|
90
|
-
end
|
91
|
-
|
92
|
-
ok = system(*cmd)
|
93
|
-
if block_given?
|
94
|
-
yield(ok, $?)
|
95
|
-
elsif !ok
|
96
|
-
fail "Command failed with status (#{$?.exitstatus}): " +
|
97
|
-
"[#{cmdline}]"
|
98
|
-
end
|
99
|
-
end
|
100
|
-
|
101
|
-
def verbose_flag(options)
|
102
|
-
verbose = options.fetch(:verbose) do
|
103
|
-
Object.const_defined?(:Rake) && Rake.const_defined?(:FileUtilsExt) ? Rake::FileUtilsExt.verbose_flag : false
|
104
|
-
end
|
105
|
-
end
|
106
|
-
|
107
|
-
@@docker_checked = false
|
108
|
-
|
109
|
-
def check_docker
|
110
|
-
return if @@docker_checked
|
111
|
-
|
112
|
-
version_text = `docker version` rescue SystemCallError
|
113
|
-
if $?.exitstatus == 0 && version_text.to_s =~ /version/
|
114
|
-
@@docker_checked = true
|
115
|
-
else
|
116
|
-
at_exit do
|
117
|
-
$stderr.puts
|
118
|
-
case RUBY_PLATFORM
|
119
|
-
when /mingw|mswin/
|
120
|
-
$stderr.puts "Docker is not available. Please download and install boot2docker:"
|
121
|
-
$stderr.puts " https://github.com/boot2docker/windows-installer/releases"
|
122
|
-
$stderr.puts
|
123
|
-
$stderr.puts "Then execute 'boot2docker start' and follow the instuctions"
|
124
|
-
when /linux/
|
125
|
-
$stderr.puts "Docker is not available."
|
126
|
-
$stderr.puts
|
127
|
-
$stderr.puts "Install on Ubuntu/Debian:"
|
128
|
-
$stderr.puts " sudo apt-get install docker.io"
|
129
|
-
$stderr.puts
|
130
|
-
$stderr.puts "Install on Fedora/Centos/RHEL"
|
131
|
-
$stderr.puts " sudo yum install docker"
|
132
|
-
$stderr.puts " sudo systemctl start docker"
|
133
|
-
$stderr.puts
|
134
|
-
$stderr.puts "Install on SuSE"
|
135
|
-
$stderr.puts " sudo zypper install docker"
|
136
|
-
$stderr.puts " sudo systemctl start docker"
|
137
|
-
when /darwin/
|
138
|
-
$stderr.puts "Docker is not available. Please download and install boot2docker:"
|
139
|
-
$stderr.puts " https://github.com/boot2docker/osx-installer/releases"
|
140
|
-
else
|
141
|
-
$stderr.puts "Docker is not available."
|
142
|
-
end
|
143
|
-
end
|
144
|
-
raise DockerIsNotAvailable, "Docker is not available"
|
145
|
-
end
|
51
|
+
def exec(*args, &block)
|
52
|
+
Starter.exec(*args, &block)
|
146
53
|
end
|
147
54
|
|
148
|
-
module_function :exec, :sh, :image_name
|
55
|
+
module_function :exec, :sh, :image_name
|
149
56
|
end
|
@@ -0,0 +1,43 @@
|
|
1
|
+
module RakeCompilerDock
|
2
|
+
module Colors
|
3
|
+
# Start an escape sequence
|
4
|
+
ESC = "\e["
|
5
|
+
|
6
|
+
# End the escape sequence
|
7
|
+
NND = "#{ESC}0m"
|
8
|
+
|
9
|
+
ColorMap = {
|
10
|
+
black: 0,
|
11
|
+
red: 1,
|
12
|
+
green: 2,
|
13
|
+
yellow: 3,
|
14
|
+
blue: 4,
|
15
|
+
magenta: 5,
|
16
|
+
cyan: 6,
|
17
|
+
white: 7,
|
18
|
+
}
|
19
|
+
|
20
|
+
ColorMap.each do |color, code|
|
21
|
+
define_method(color) do |string|
|
22
|
+
colored(code, string)
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
def colored(color, string)
|
27
|
+
if @colors_on
|
28
|
+
c = ColorMap[color] || color
|
29
|
+
"#{ESC}#{30+c}m#{string}#{NND}"
|
30
|
+
else
|
31
|
+
string.dup
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
def enable_colors
|
36
|
+
@colors_on = true
|
37
|
+
end
|
38
|
+
|
39
|
+
def disable_colors
|
40
|
+
@colors_on = false
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
@@ -0,0 +1,159 @@
|
|
1
|
+
require "rake_compiler_dock/colors"
|
2
|
+
|
3
|
+
module RakeCompilerDock
|
4
|
+
class DockerCheck
|
5
|
+
include Colors
|
6
|
+
|
7
|
+
attr_reader :io
|
8
|
+
|
9
|
+
def initialize(io)
|
10
|
+
@io = io
|
11
|
+
if !io.tty? || (RUBY_PLATFORM=~/mingw|mswin/ && RUBY_VERSION[/^\d+/] < '2')
|
12
|
+
disable_colors
|
13
|
+
else
|
14
|
+
enable_colors
|
15
|
+
end
|
16
|
+
|
17
|
+
docker_version
|
18
|
+
|
19
|
+
unless ok?
|
20
|
+
b2d_version
|
21
|
+
|
22
|
+
if b2d_avail?
|
23
|
+
io.puts
|
24
|
+
io.puts yellow("boot2docker is available, but not ready to use. Trying to start.")
|
25
|
+
|
26
|
+
b2d_init
|
27
|
+
if b2d_init_ok?
|
28
|
+
b2d_start
|
29
|
+
|
30
|
+
docker_version
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
def docker_version
|
37
|
+
@docker_version_text = `docker version 2>&1` rescue SystemCallError
|
38
|
+
@docker_version_status = $?.exitstatus
|
39
|
+
end
|
40
|
+
|
41
|
+
def ok?
|
42
|
+
@docker_version_status == 0 && @docker_version_text =~ /version/
|
43
|
+
end
|
44
|
+
|
45
|
+
def docker_client_avail?
|
46
|
+
@docker_version_text =~ /version/
|
47
|
+
end
|
48
|
+
|
49
|
+
def b2d_version
|
50
|
+
@b2d_version_text = `boot2docker version 2>&1` rescue SystemCallError
|
51
|
+
@b2d_version_status = $?.exitstatus
|
52
|
+
end
|
53
|
+
|
54
|
+
def b2d_avail?
|
55
|
+
@b2d_version_status == 0 && @b2d_version_text =~ /version/
|
56
|
+
end
|
57
|
+
|
58
|
+
def b2d_init
|
59
|
+
system("boot2docker init") rescue SystemCallError
|
60
|
+
@b2d_init_status = $?.exitstatus
|
61
|
+
end
|
62
|
+
|
63
|
+
def b2d_init_ok?
|
64
|
+
@b2d_init_status == 0
|
65
|
+
end
|
66
|
+
|
67
|
+
def b2d_start
|
68
|
+
@b2d_start_text = `boot2docker start` rescue SystemCallError
|
69
|
+
@b2d_start_status = $?.exitstatus
|
70
|
+
|
71
|
+
if @b2d_start_status == 0
|
72
|
+
@b2d_start_text.scan(/(unset |Remove-Item Env:\\)(?<key>.+?)$/) do |r, |
|
73
|
+
io.puts " #{$&}"
|
74
|
+
ENV.delete(key)
|
75
|
+
end
|
76
|
+
@b2d_start_text.scan(/(export |\$Env:)(?<key>.+?)(=| = ")(?<val>.*?)(|\")$/) do |key, val|
|
77
|
+
io.puts " #{$&}"
|
78
|
+
ENV[key] = val
|
79
|
+
end
|
80
|
+
end
|
81
|
+
end
|
82
|
+
|
83
|
+
def b2d_start_ok?
|
84
|
+
@b2d_start_status == 0
|
85
|
+
end
|
86
|
+
|
87
|
+
def help_text
|
88
|
+
help = []
|
89
|
+
if !ok? && docker_client_avail? && !b2d_avail?
|
90
|
+
help << red("Docker client tools work, but connection to the local docker server failed.")
|
91
|
+
case RUBY_PLATFORM
|
92
|
+
when /linux/
|
93
|
+
help << yellow("Please make sure the docker daemon is running.")
|
94
|
+
help << ""
|
95
|
+
help << yellow("On Ubuntu/Debian:")
|
96
|
+
help << " sudo service docker start"
|
97
|
+
help << yellow("or")
|
98
|
+
help << " sudo service docker.io start"
|
99
|
+
help << ""
|
100
|
+
help << yellow("On Fedora/Centos/RHEL")
|
101
|
+
help << " sudo systemctl start docker"
|
102
|
+
help << ""
|
103
|
+
help << yellow("On SuSE")
|
104
|
+
help << " sudo systemctl start docker"
|
105
|
+
help << ""
|
106
|
+
help << yellow("And re-check with '") + white("docker version") + yellow("'")
|
107
|
+
else
|
108
|
+
help << yellow(" Please check why '") + white("docker version") + yellow("' fails.")
|
109
|
+
end
|
110
|
+
elsif !ok? && !b2d_avail?
|
111
|
+
case RUBY_PLATFORM
|
112
|
+
when /mingw|mswin/
|
113
|
+
help << red("Docker is not available.")
|
114
|
+
help << yellow("Please download and install boot2docker:")
|
115
|
+
help << yellow(" https://github.com/boot2docker/windows-installer/releases")
|
116
|
+
when /linux/
|
117
|
+
help << red("Docker is not available.")
|
118
|
+
help << ""
|
119
|
+
help << yellow("Install on Ubuntu/Debian:")
|
120
|
+
help << " sudo apt-get install docker.io"
|
121
|
+
help << ""
|
122
|
+
help << yellow("Install on Fedora/Centos/RHEL")
|
123
|
+
help << " sudo yum install docker"
|
124
|
+
help << " sudo systemctl start docker"
|
125
|
+
help << ""
|
126
|
+
help << yellow("Install on SuSE")
|
127
|
+
help << " sudo zypper install docker"
|
128
|
+
help << " sudo systemctl start docker"
|
129
|
+
when /darwin/
|
130
|
+
help << red("Docker is not available.")
|
131
|
+
help << yellow("Please download and install boot2docker:")
|
132
|
+
help << yellow(" https://github.com/boot2docker/osx-installer/releases")
|
133
|
+
else
|
134
|
+
help << red("Docker is not available.")
|
135
|
+
end
|
136
|
+
elsif !ok? && !b2d_init_ok?
|
137
|
+
help << red("boot2docker is installed but couldn't be initialized.")
|
138
|
+
help << ""
|
139
|
+
help << yellow(" Please check why '") + white("boot2docker init") + yellow("' fails.")
|
140
|
+
elsif !ok? && !b2d_start_ok?
|
141
|
+
help << red("boot2docker is installed but couldn't be started.")
|
142
|
+
help << ""
|
143
|
+
help << yellow(" Please check why '") + white("boot2docker start") + yellow("' fails.")
|
144
|
+
help << yellow(" You might need to re-init with '") + white("boot2docker delete") + yellow("'.")
|
145
|
+
elsif !ok? && b2d_start_ok?
|
146
|
+
help << red("boot2docker is installed and started, but 'docker version' failed.")
|
147
|
+
help << ""
|
148
|
+
help << yellow(" Please check why '") + white("docker version") + yellow("' fails.")
|
149
|
+
help << yellow(" You might need to re-init with '") + white("boot2docker delete") + yellow("'.")
|
150
|
+
end
|
151
|
+
|
152
|
+
help.join("\n")
|
153
|
+
end
|
154
|
+
|
155
|
+
def print_help_text
|
156
|
+
io.puts(help_text)
|
157
|
+
end
|
158
|
+
end
|
159
|
+
end
|
@@ -0,0 +1,121 @@
|
|
1
|
+
require "shellwords"
|
2
|
+
require "rake_compiler_dock/version"
|
3
|
+
|
4
|
+
module RakeCompilerDock
|
5
|
+
class DockerIsNotAvailable < RuntimeError
|
6
|
+
end
|
7
|
+
|
8
|
+
class Starter
|
9
|
+
class << self
|
10
|
+
def sh(cmd, options={}, &block)
|
11
|
+
if verbose_flag(options)
|
12
|
+
$stderr.puts "rake-compiler-dock bash -c #{ cmd.inspect }"
|
13
|
+
end
|
14
|
+
exec('bash', '-c', cmd, options, &block)
|
15
|
+
end
|
16
|
+
|
17
|
+
def image_name
|
18
|
+
ENV['RAKE_COMPILER_DOCK_IMAGE'] || "larskanis/rake-compiler-dock:#{VERSION}"
|
19
|
+
end
|
20
|
+
|
21
|
+
def exec(*args)
|
22
|
+
options = (Hash === args.last) ? args.pop : {}
|
23
|
+
runargs = args.dup
|
24
|
+
|
25
|
+
check_docker if options.fetch(:check_docker){ true }
|
26
|
+
runargs.unshift("sigfw") if options.fetch(:sigfw){ true }
|
27
|
+
runargs.unshift("runas") if options.fetch(:runas){ true }
|
28
|
+
docker_opts = options.fetch(:options) do
|
29
|
+
opts = ["--rm", "-i"]
|
30
|
+
opts << "-t" if $stdin.tty?
|
31
|
+
opts
|
32
|
+
end
|
33
|
+
|
34
|
+
case RUBY_PLATFORM
|
35
|
+
when /mingw|mswin/
|
36
|
+
# Change Path from "C:\Path" to "/c/Path" as used by boot2docker
|
37
|
+
pwd = Dir.pwd.gsub(/^([a-z]):/i){ "/#{$1.downcase}" }
|
38
|
+
# Virtualbox shared folders don't care about file permissions, so we use generic ids.
|
39
|
+
uid = 1000
|
40
|
+
gid = 1000
|
41
|
+
when /darwin/
|
42
|
+
pwd = Dir.pwd
|
43
|
+
uid = 1000
|
44
|
+
gid = 1000
|
45
|
+
else
|
46
|
+
pwd = Dir.pwd
|
47
|
+
# Docker mounted volumes also share file uid/gid and permissions with the host.
|
48
|
+
# Therefore we use the same attributes inside and outside the container.
|
49
|
+
uid = Process.uid
|
50
|
+
gid = Process.gid
|
51
|
+
end
|
52
|
+
user = make_valid_name(`id -nu`.chomp)
|
53
|
+
group = make_valid_name(`id -ng`.chomp)
|
54
|
+
|
55
|
+
cmd = ["docker", "run",
|
56
|
+
"-v", "#{pwd}:#{make_valid_path(pwd)}",
|
57
|
+
"-e", "UID=#{uid}",
|
58
|
+
"-e", "GID=#{gid}",
|
59
|
+
"-e", "USER=#{user}",
|
60
|
+
"-e", "GROUP=#{group}",
|
61
|
+
"-e", "ftp_proxy=#{ENV['ftp_proxy']}",
|
62
|
+
"-e", "http_proxy=#{ENV['http_proxy']}",
|
63
|
+
"-e", "https_proxy=#{ENV['https_proxy']}",
|
64
|
+
"-w", make_valid_path(pwd),
|
65
|
+
*docker_opts,
|
66
|
+
image_name,
|
67
|
+
*runargs]
|
68
|
+
|
69
|
+
cmdline = Shellwords.join(cmd)
|
70
|
+
if verbose_flag(options) == true
|
71
|
+
$stderr.puts cmdline
|
72
|
+
end
|
73
|
+
|
74
|
+
ok = system(*cmd)
|
75
|
+
if block_given?
|
76
|
+
yield(ok, $?)
|
77
|
+
elsif !ok
|
78
|
+
fail "Command failed with status (#{$?.exitstatus}): " +
|
79
|
+
"[#{cmdline}]"
|
80
|
+
end
|
81
|
+
end
|
82
|
+
|
83
|
+
def verbose_flag(options)
|
84
|
+
verbose = options.fetch(:verbose) do
|
85
|
+
Object.const_defined?(:Rake) && Rake.const_defined?(:FileUtilsExt) ? Rake::FileUtilsExt.verbose_flag : false
|
86
|
+
end
|
87
|
+
end
|
88
|
+
|
89
|
+
def make_valid_name(name)
|
90
|
+
name = name.downcase
|
91
|
+
# Convert disallowed characters
|
92
|
+
name = name[0..0].gsub(/[^a-z_]/, "_") + name[1..-2].gsub(/[^a-z0-9_-]/, "_") + name[-1..-1].gsub(/[^a-z0-9_$-]/, "_")
|
93
|
+
# Limit to 32 characters
|
94
|
+
name.sub( /^(.{16}).{2,}(.{15})$/ ){ $1+"-"+$2 }
|
95
|
+
end
|
96
|
+
|
97
|
+
def make_valid_path(name)
|
98
|
+
# Convert problematic characters
|
99
|
+
name = name.gsub(/[ ]/i, "_")
|
100
|
+
end
|
101
|
+
|
102
|
+
@@docker_checked = nil
|
103
|
+
|
104
|
+
def check_docker
|
105
|
+
return if @@docker_checked
|
106
|
+
|
107
|
+
check = DockerCheck.new($stderr)
|
108
|
+
unless check.ok?
|
109
|
+
at_exit do
|
110
|
+
$stderr.puts
|
111
|
+
check.print_help_text
|
112
|
+
end
|
113
|
+
raise DockerIsNotAvailable, "Docker is not available"
|
114
|
+
end
|
115
|
+
|
116
|
+
@@docker_checked = check
|
117
|
+
end
|
118
|
+
|
119
|
+
end
|
120
|
+
end
|
121
|
+
end
|
data/rake-compiler-dock.gemspec
CHANGED
@@ -13,6 +13,7 @@ Gem::Specification.new do |spec|
|
|
13
13
|
Use rake-compiler-dock to enter an interactive shell session or add a task to your Rakefile to automate your cross build.}
|
14
14
|
spec.homepage = "https://github.com/larskanis/rake-compiler-dock"
|
15
15
|
spec.license = "MIT"
|
16
|
+
spec.required_ruby_version = '>= 1.9.3'
|
16
17
|
|
17
18
|
spec.files = `git ls-files -z`.split("\x0")
|
18
19
|
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
data/src/runas
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
#!/bin/bash
|
2
2
|
|
3
|
-
groupadd -g $GID $GROUP
|
3
|
+
groupadd -g "$GID" "$GROUP"
|
4
4
|
mkdir -p /tmp/home
|
5
|
-
useradd -g $GID -u $UID -G rvm,sudo -p "" -b /tmp/home -m $USER
|
5
|
+
useradd -g "$GID" -u "$UID" -G rvm,sudo -p "" -b /tmp/home -m "$USER"
|
6
6
|
|
7
7
|
HOME=$(bash <<< "echo ~$USER")
|
8
|
-
ln -s /usr/local/rake-compiler $HOME/.rake-compiler
|
8
|
+
ln -s /usr/local/rake-compiler "$HOME"/.rake-compiler
|
9
9
|
|
10
|
-
sudo -u $USER --set-home \
|
10
|
+
sudo -u "$USER" --set-home \
|
11
11
|
BASH_ENV=/etc/rubybashrc \
|
12
12
|
RUBY_CC_VERSION=1.8.7:1.9.3:2.0.0:2.1.6:2.2.2 \
|
13
13
|
-- "$@"
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rake-compiler-dock
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Lars Kanis
|
@@ -29,7 +29,7 @@ cert_chain:
|
|
29
29
|
1i6jssufMLmyDB9b1ss72d7xQQpCHH7oizgt84wKAcsV8b83kGbAhtoszY3TgGiJ
|
30
30
|
rww=
|
31
31
|
-----END CERTIFICATE-----
|
32
|
-
date: 2015-06-
|
32
|
+
date: 2015-06-29 00:00:00.000000000 Z
|
33
33
|
dependencies:
|
34
34
|
- !ruby/object:Gem::Dependency
|
35
35
|
name: bundler
|
@@ -78,6 +78,9 @@ files:
|
|
78
78
|
- Rakefile
|
79
79
|
- bin/rake-compiler-dock
|
80
80
|
- lib/rake_compiler_dock.rb
|
81
|
+
- lib/rake_compiler_dock/colors.rb
|
82
|
+
- lib/rake_compiler_dock/docker_check.rb
|
83
|
+
- lib/rake_compiler_dock/starter.rb
|
81
84
|
- lib/rake_compiler_dock/version.rb
|
82
85
|
- patches/ruby-1.8.7-p374/nop.patch
|
83
86
|
- patches/ruby-1.9.3/no_sendfile.patch
|
@@ -101,7 +104,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
101
104
|
requirements:
|
102
105
|
- - ">="
|
103
106
|
- !ruby/object:Gem::Version
|
104
|
-
version:
|
107
|
+
version: 1.9.3
|
105
108
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
106
109
|
requirements:
|
107
110
|
- - ">="
|
metadata.gz.sig
CHANGED
@@ -1,2 +1,3 @@
|
|
1
|
-
|
2
|
-
|
1
|
+
\
|
2
|
+
P)m���%�����:�Y��U�����5���ɰ�o���I-Ȃ�is�� ��B���xx��}n�����'��으�'�q��� -i�u��AB�;ƆfLs�\���"��ތ$�;� M�U��17�pZ��Mx���b蹄�[��o�W�*�0 �;����� ak�L d�W<S;!.N(���
|
3
|
+
h׀"�I�-�6�z
|