rake-compiler-dock 0.4.3 → 0.5.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 CHANGED
@@ -1,7 +1,7 @@
1
- ---
2
- SHA1:
3
- metadata.gz: 1e983c94653b1f0957be5369aea68c1f36b08d98
4
- data.tar.gz: 7c0cd46e926a975dfd6e6bf42b00ee6686e50d86
5
- SHA512:
6
- metadata.gz: 93f1cc24bf695392c2c3224f822631102a17208b48ccc394859860a152c77c855eff35e20158d84064d1b4a01e20cc7fe4e00c076386ef7eec8e7159d6abce79
7
- data.tar.gz: 598ba57c29cd9cf4ac07a9456813850fd6e7ec35c124deb9240d95dbdb6b910e8b1873c3a9e495ea1d6a67fabb14e4031022aa2064f86634b9be9adde0353dc9
1
+ ---
2
+ SHA1:
3
+ metadata.gz: e5326f050ab952a7641a48ab10de71a2f56933fe
4
+ data.tar.gz: de257ed5785395495ee8e11cc6aae3a5e35870c7
5
+ SHA512:
6
+ metadata.gz: 9d7089a62ac4b0b6f7224791d56d152e57364e47bf989079fe03f822095f11243e5bffb18906ffa1372f0b8f370a75cb36c9470c623b1075f29a923ba38f162e
7
+ data.tar.gz: c7ff5593f623e88a794b341df449d0859b8f555cf515ff098881be5387f4cb65601e7dd24a0549c224fec773c84e5e699aa122ecaa6d157be2c74061659201f7
Binary file
data.tar.gz.sig CHANGED
Binary file
data/Dockerfile CHANGED
@@ -25,13 +25,14 @@ RUN gpg --keyserver hkp://keys.gnupg.net --recv-keys D39DC0E3 && \
25
25
  source /etc/rubybashrc && \
26
26
  rvmsudo rvm cleanup all "
27
27
 
28
- ADD patches /home/rvm/patches
28
+ # Import patch files for ruby and gems
29
+ COPY build/patches /home/rvm/patches/
29
30
  ENV BASH_ENV /etc/rubybashrc
30
31
 
31
32
  # install rubies and fix permissions on
32
33
  RUN bash -c " \
33
34
  export CFLAGS='-s -O3 -fno-fast-math -fPIC' && \
34
- for v in 1.8.7-p374 1.9.3 2.2.2 ; do \
35
+ for v in 2.3.0 1.9.3 1.8.7-p374 ; do \
35
36
  rvm install \$v --patch \$(echo ~/patches/ruby-\$v/* | tr ' ' ','); \
36
37
  done && \
37
38
  rvm cleanup all && \
@@ -42,7 +43,8 @@ RUN bash -c " \
42
43
  RUN echo "gem: --no-ri --no-rdoc" >> ~/.gemrc && \
43
44
  bash -c " \
44
45
  rvm all do gem install bundler rake-compiler hoe mini_portile rubygems-tasks && \
45
- find /usr/local/rvm -type d | sudo xargs chmod g+sw "
46
+ rvm 1.9.3,2.3.0 do gem install mini_portile2 && \
47
+ find /usr/local/rvm -type d -print0 | sudo xargs -0 chmod g+sw "
46
48
 
47
49
  # Install rake-compiler's cross rubies in global dir instead of /root
48
50
  RUN sudo mkdir -p /usr/local/rake-compiler && \
@@ -50,38 +52,40 @@ RUN sudo mkdir -p /usr/local/rake-compiler && \
50
52
  ln -s /usr/local/rake-compiler ~/.rake-compiler
51
53
 
52
54
  # Patch rake-compiler to avoid build of ruby extensions
53
- ADD src/rake-compiler-without-exts.diff /home/rvm/
54
- RUN cd /usr/local/rvm/gems/ruby-1.8.7-p374/gems/rake-compiler-0.9.5 && patch -p1 < /home/rvm/rake-compiler-without-exts.diff && \
55
- cd /usr/local/rvm/gems/ruby-1.9.3-p551/gems/rake-compiler-0.9.5 && patch -p1 < /home/rvm/rake-compiler-without-exts.diff && \
56
- cd /usr/local/rvm/gems/ruby-2.2.2/gems/rake-compiler-0.9.5 && patch -p1 < /home/rvm/rake-compiler-without-exts.diff
55
+ RUN cd /usr/local/rvm/gems/ruby-1.8.7-p374/gems/rake-compiler-0.9.5 && patch -p1 < /home/rvm/patches/rake-compiler-0.9.5/without-exts.diff ; \
56
+ cd /usr/local/rvm/gems/ruby-1.9.3-p551/gems/rake-compiler-0.9.5 && patch -p1 < /home/rvm/patches/rake-compiler-0.9.5/without-exts.diff ; \
57
+ cd /usr/local/rvm/gems/ruby-2.3.0/gems/rake-compiler-0.9.5 && patch -p1 < /home/rvm/patches/rake-compiler-0.9.5/without-exts.diff ; \
58
+ true
57
59
 
58
- # Build 1.8.7 with mingw32 compiler (GCC 4.2)
59
- # Use just one CPU for building 1.8.7 and 1.9.3
60
- RUN bash -c "rvm use 1.8.7-p374 && \
61
- export CFLAGS='-s -O1 -fno-omit-frame-pointer -fno-fast-math' && \
62
- rake-compiler cross-ruby VERSION=1.8.7-p374 HOST=i586-mingw32msvc && \
63
- rm -rf ~/.rake-compiler/builds ~/.rake-compiler/sources"
60
+ RUN bash -c "rvm use 2.3.0 --default && \
61
+ export MAKE=\"make -j`nproc`\" CFLAGS='-s -O1 -fno-omit-frame-pointer -fno-fast-math' && \
62
+ rake-compiler cross-ruby VERSION=2.3.0 HOST=i686-w64-mingw32 && \
63
+ rake-compiler cross-ruby VERSION=2.3.0 HOST=x86_64-w64-mingw32 && \
64
+ rake-compiler cross-ruby VERSION=2.2.2 HOST=i686-w64-mingw32 && \
65
+ rake-compiler cross-ruby VERSION=2.2.2 HOST=x86_64-w64-mingw32 && \
66
+ rake-compiler cross-ruby VERSION=2.1.6 HOST=i686-w64-mingw32 && \
67
+ rake-compiler cross-ruby VERSION=2.1.6 HOST=x86_64-w64-mingw32 && \
68
+ rake-compiler cross-ruby VERSION=2.0.0-p645 HOST=i686-w64-mingw32 && \
69
+ rake-compiler cross-ruby VERSION=2.0.0-p645 HOST=x86_64-w64-mingw32 && \
70
+ rm -rf ~/.rake-compiler/builds ~/.rake-compiler/sources && \
71
+ find /usr/local/rvm -type d | sudo xargs chmod g+sw "
64
72
 
65
73
  RUN bash -c "rvm use 1.9.3 && \
66
74
  export CFLAGS='-s -O1 -fno-omit-frame-pointer -fno-fast-math' && \
67
75
  rake-compiler cross-ruby VERSION=1.9.3-p551 HOST=i586-mingw32msvc && \
68
76
  rm -rf ~/.rake-compiler/builds ~/.rake-compiler/sources"
69
77
 
70
- RUN bash -c "rvm use 2.2.2 --default && \
71
- export MAKE=\"make -j`nproc`\" CFLAGS='-s -O1 -fno-omit-frame-pointer -fno-fast-math' && \
72
- rake-compiler cross-ruby VERSION=2.0.0-p645 HOST=i686-w64-mingw32 && \
73
- rake-compiler cross-ruby VERSION=2.0.0-p645 HOST=x86_64-w64-mingw32 && \
74
- rake-compiler cross-ruby VERSION=2.1.6 HOST=i686-w64-mingw32 && \
75
- rake-compiler cross-ruby VERSION=2.1.6 HOST=x86_64-w64-mingw32 && \
76
- rake-compiler cross-ruby VERSION=2.2.2 HOST=i686-w64-mingw32 && \
77
- rake-compiler cross-ruby VERSION=2.2.2 HOST=x86_64-w64-mingw32 && \
78
- rm -rf ~/.rake-compiler/builds ~/.rake-compiler/sources && \
79
- find /usr/local/rvm -type d | sudo xargs chmod g+sw "
78
+ # Build 1.8.7 with mingw32 compiler (GCC 4.2)
79
+ # Use just one CPU for building 1.8.7 and 1.9.3
80
+ RUN bash -c "rvm use 1.8.7-p374 && \
81
+ export CFLAGS='-s -O1 -fno-omit-frame-pointer -fno-fast-math' && \
82
+ rake-compiler cross-ruby VERSION=1.8.7-p374 HOST=i586-mingw32msvc && \
83
+ rm -rf ~/.rake-compiler/builds ~/.rake-compiler/sources"
80
84
 
81
85
  RUN bash -c " \
82
- rvm alias create 1.8 1.8.7-p374 && \
86
+ rvm alias create 2.3 2.3.0 && \
83
87
  rvm alias create 1.9 1.9.3 && \
84
- rvm alias create 2.2 2.2.2 "
88
+ rvm alias create 1.8 1.8.7-p374 "
85
89
 
86
90
  USER root
87
91
 
@@ -92,7 +96,7 @@ RUN sed -i -- "s:/root/.rake-compiler:/usr/local/rake-compiler:g" /usr/local/rak
92
96
  echo "export PATH=\$PATH:/opt/mingw/mingw64/bin" >> /etc/bash.bashrc
93
97
 
94
98
  # Install wrappers for strip commands as a workaround for "Protocol error" in boot2docker.
95
- ADD src/strip_wrapper /root/
99
+ COPY build/strip_wrapper /root/
96
100
  RUN mv /opt/mingw/mingw32/bin/i686-w64-mingw32-strip /opt/mingw/mingw32/bin/i686-w64-mingw32-strip.bin && \
97
101
  mv /opt/mingw/mingw64/bin/x86_64-w64-mingw32-strip /opt/mingw/mingw64/bin/x86_64-w64-mingw32-strip.bin && \
98
102
  mv /usr/bin/i586-mingw32msvc-strip /usr/bin/i586-mingw32msvc-strip.bin && \
@@ -101,15 +105,15 @@ RUN mv /opt/mingw/mingw32/bin/i686-w64-mingw32-strip /opt/mingw/mingw32/bin/i686
101
105
  ln /root/strip_wrapper /usr/bin/i586-mingw32msvc-strip
102
106
 
103
107
  # Install SIGINT forwarder
104
- ADD src/sigfw.c /root/
108
+ COPY build/sigfw.c /root/
105
109
  RUN gcc $HOME/sigfw.c -o /usr/local/bin/sigfw
106
110
 
107
111
  # Install user mapper
108
- ADD src/runas /usr/local/bin/
112
+ COPY build/runas /usr/local/bin/
109
113
 
110
114
  # Install sudoers configuration
111
- ADD src/sudoers /etc/sudoers.d/rake-compiler-dock
115
+ COPY build/sudoers /etc/sudoers.d/rake-compiler-dock
112
116
 
113
- ENV RUBY_CC_VERSION 1.8.7:1.9.3:2.0.0:2.1.6:2.2.2
117
+ ENV RUBY_CC_VERSION 2.3.0:2.2.2:2.1.6:2.0.0:1.9.3:1.8.7
114
118
 
115
119
  CMD bash
data/History.md CHANGED
@@ -1,3 +1,11 @@
1
+ 0.5.0 / 2015-12-25
2
+ ------------------
3
+ * Add cross ruby version 2.3.0.
4
+ * Replace RVM ruby version 2.2.2 with 2.3.0 and set it as default.
5
+ * Add support for docker-machine in addition to deprecated boot2docker.
6
+ * Drop runtime support for ruby-1.8. Cross build for 1.8 is still supported.
7
+
8
+
1
9
  0.4.3 / 2015-07-09
2
10
  ------------------
3
11
  * Ensure the user and group names doesn't clash with names in the image.
data/README.md CHANGED
@@ -2,8 +2,9 @@
2
2
 
3
3
  **Easy to use and reliable cross compiler environment for building Windows binary gems.**
4
4
 
5
- It provides cross compilers and Ruby environments for all versions of the [RubyInstaller](http://rubyinstaller.org/) .
6
- They are prepared for use with [rake-compiler](https://github.com/rake-compiler/rake-compiler) .
5
+ It provides cross compilers and Ruby environments for all versions of the [RubyInstaller](http://rubyinstaller.org/).
6
+ They are prepared for use with [rake-compiler](https://github.com/rake-compiler/rake-compiler).
7
+ It is used by [many gems with C-extentions](https://github.com/rake-compiler/rake-compiler-dock/wiki/Projects-using-rake-compiler-dock).
7
8
 
8
9
  This is kind of successor of [rake-compiler-dev-box](https://github.com/tjschuck/rake-compiler-dev-box).
9
10
  It is wrapped as a gem for easier setup, usage and integration and is based on lightweight Docker containers.
@@ -15,7 +16,7 @@ Install docker natively on Linux:
15
16
 
16
17
  $ sudo apt-get install docker.io
17
18
 
18
- ... or install boot2docker on [Windows](https://github.com/boot2docker/windows-installer/releases) or [OS X](https://github.com/boot2docker/osx-installer/releases) .
19
+ ... or install [docker-toolbox for Windows and OSX](https://www.docker.com/docker-toolbox) or boot2docker on [Windows](https://github.com/boot2docker/windows-installer/releases) or [OS X](https://github.com/boot2docker/osx-installer/releases) .
19
20
 
20
21
  Install rake-compiler-dock as a gem. The docker image is downloaded later on demand:
21
22
 
@@ -23,7 +24,7 @@ Install rake-compiler-dock as a gem. The docker image is downloaded later on dem
23
24
 
24
25
  ... or build your own gem and docker image:
25
26
 
26
- $ git clone https://github.com/larskanis/rake-compiler-dock
27
+ $ git clone https://github.com/rake-compiler/rake-compiler-dock
27
28
  $ rake install
28
29
 
29
30
 
@@ -77,9 +78,9 @@ This can be done like this:
77
78
 
78
79
  Rake-compiler-dock uses [semantic versioning](http://semver.org/), so you should add it into your Gemfile, to make sure, that future changes will not break your build.
79
80
 
80
- gem 'rake-compiler-dock', '~> 0.4.0'
81
+ gem 'rake-compiler-dock', '~> 0.5.0'
81
82
 
82
- See [the wiki](https://github.com/larskanis/rake-compiler-dock/wiki/Projects-using-rake-compiler-dock) for projects which make use of rake-compiler-dock.
83
+ See [the wiki](https://github.com/rake-compiler/rake-compiler-dock/wiki/Projects-using-rake-compiler-dock) for projects which make use of rake-compiler-dock.
83
84
 
84
85
 
85
86
  ## Environment Variables
@@ -93,7 +94,7 @@ The following variables are recognized by rake-compiler-dock:
93
94
 
94
95
  The following variables are passed through to the docker container without modification:
95
96
 
96
- * `http_proxy`, `https_proxy`, `ftp_proxy` - See [Frequently asked questions](https://github.com/larskanis/rake-compiler-dock/wiki/FAQ) for more details.
97
+ * `http_proxy`, `https_proxy`, `ftp_proxy` - See [Frequently asked questions](https://github.com/rake-compiler/rake-compiler-dock/wiki/FAQ) for more details.
97
98
 
98
99
  The following variables are provided to the running docker container:
99
100
 
@@ -101,7 +102,7 @@ The following variables are provided to the running docker container:
101
102
  * `RCD_HOST_RUBY_PLATFORM` - The `RUBY_PLATFORM` of the host ruby.
102
103
  * `RCD_HOST_RUBY_VERSION` - The `RUBY_VERSION` of the host ruby.
103
104
  * `RUBY_CC_VERSION` - The target ruby versions for rake-compiler.
104
- The default is defined in the [Dockerfile](https://github.com/larskanis/rake-compiler-dock/blob/master/Dockerfile), but can be changed as a parameter to rake.
105
+ The default is defined in the [Dockerfile](https://github.com/rake-compiler/rake-compiler-dock/blob/master/Dockerfile), but can be changed as a parameter to rake.
105
106
 
106
107
  Other environment variables can be set or passed through to the container like this:
107
108
 
@@ -110,12 +111,12 @@ Other environment variables can be set or passed through to the container like t
110
111
 
111
112
  ## More information
112
113
 
113
- See [Frequently asked questions](https://github.com/larskanis/rake-compiler-dock/wiki/FAQ) and [![Join the chat at https://gitter.im/larskanis/rake-compiler-dock](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/larskanis/rake-compiler-dock?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
114
+ See [Frequently asked questions](https://github.com/rake-compiler/rake-compiler-dock/wiki/FAQ) and [![Join the chat at https://gitter.im/larskanis/rake-compiler-dock](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/larskanis/rake-compiler-dock?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
114
115
 
115
116
 
116
117
  ## Contributing
117
118
 
118
- 1. Fork it ( https://github.com/larskanis/rake-compiler-dock/fork )
119
+ 1. Fork it ( https://github.com/rake-compiler/rake-compiler-dock/fork )
119
120
  2. Create your feature branch (`git checkout -b my-new-feature`)
120
121
  3. Commit your changes (`git commit -am 'Add some feature'`)
121
122
  4. Push to the branch (`git push origin my-new-feature`)
@@ -1,8 +1,8 @@
1
1
  diff --git a/configure b/configure
2
- index 55157af..6630eba 100755
2
+ index ebe3d8c..a336b73 100755
3
3
  --- a/configure
4
4
  +++ b/configure
5
- @@ -18676,7 +18676,6 @@ do :
5
+ @@ -18943,7 +18943,6 @@ do :
6
6
  ac_fn_c_check_func "$LINENO" "sendfile" "ac_cv_func_sendfile"
7
7
  if test "x$ac_cv_func_sendfile" = xyes; then :
8
8
  cat >>confdefs.h <<_ACEOF
File without changes
File without changes
File without changes
File without changes
@@ -1,3 +1,10 @@
1
+
2
+ # We do ruby version check at runtime, so this file should be kept ruby-1.8 compatible.
3
+ if (m=RUBY_VERSION.match(/^(\d+)\.(\d+)\.(\d+)/)) &&
4
+ m.captures.map(&:to_i).pack("N*") < [1,9,2].pack("N*")
5
+ raise "rake-compiler-dock requires at least RUBY_VERSION >= 1.9.2"
6
+ end
7
+
1
8
  require "rake_compiler_dock/colors"
2
9
  require "rake_compiler_dock/docker_check"
3
10
  require "rake_compiler_dock/starter"
@@ -45,6 +52,8 @@ module RakeCompilerDock
45
52
  # * Option +:sigfw+ can be set to false to not stop the container on Ctrl-C.
46
53
  # * Option +:runas+ can be set to false to execute the command as user root.
47
54
  # * Option +:options+ can be an Array of additional options to the 'docker run' command.
55
+ # * Option +:username+ can be used to overwrite the user name in the container
56
+ # * Option +:groupname+ can be used to overwrite the group name in the container
48
57
  #
49
58
  # Examples:
50
59
  #
@@ -7,14 +7,14 @@ module RakeCompilerDock
7
7
  NND = "#{ESC}0m"
8
8
 
9
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,
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
18
  }
19
19
 
20
20
  ColorMap.each do |color, code|
@@ -1,3 +1,4 @@
1
+ require "uri"
1
2
  require "rake_compiler_dock/colors"
2
3
 
3
4
  module RakeCompilerDock
@@ -5,9 +6,12 @@ module RakeCompilerDock
5
6
  include Colors
6
7
 
7
8
  attr_reader :io
9
+ attr_accessor :machine_name
8
10
 
9
- def initialize(io)
11
+ def initialize(io, machine_name="rake-compiler-dock")
10
12
  @io = io
13
+ @machine_name = machine_name
14
+
11
15
  if !io.tty? || (RUBY_PLATFORM=~/mingw|mswin/ && RUBY_VERSION[/^\d+/] < '2')
12
16
  disable_colors
13
17
  else
@@ -17,25 +21,37 @@ module RakeCompilerDock
17
21
  docker_version
18
22
 
19
23
  unless ok?
20
- b2d_version
21
-
22
- if b2d_avail?
24
+ doma_version
25
+ if doma_avail?
23
26
  io.puts
24
- io.puts yellow("boot2docker is available, but not ready to use. Trying to start.")
27
+ io.puts yellow("docker-machine is available, but not ready to use. Trying to start.")
25
28
 
26
- b2d_init
27
- if b2d_init_ok?
28
- b2d_start
29
+ doma_create
30
+ if doma_create_ok?
31
+ doma_start
29
32
 
30
33
  docker_version
31
34
  end
35
+ else
36
+ b2d_version
37
+
38
+ if b2d_avail?
39
+ io.puts
40
+ io.puts yellow("boot2docker is available, but not ready to use. Trying to start.")
41
+
42
+ b2d_init
43
+ if b2d_init_ok?
44
+ b2d_start
45
+
46
+ docker_version
47
+ end
48
+ end
32
49
  end
33
50
  end
34
51
  end
35
52
 
36
53
  def docker_version
37
- @docker_version_text = `docker version 2>&1` rescue SystemCallError
38
- @docker_version_status = $?.exitstatus
54
+ @docker_version_text, @docker_version_status = run("docker version")
39
55
  end
40
56
 
41
57
  def ok?
@@ -46,6 +62,55 @@ module RakeCompilerDock
46
62
  @docker_version_text =~ /version/
47
63
  end
48
64
 
65
+ def doma_version
66
+ @doma_version_text, @doma_version_status = run("docker-machine --version")
67
+ end
68
+
69
+ def doma_avail?
70
+ @doma_version_status == 0 && @doma_version_text =~ /version/
71
+ end
72
+
73
+ def doma_create
74
+ options = [
75
+ "--engine-env", "ftp_proxy=#{ENV['ftp_proxy']}",
76
+ "--engine-env", "http_proxy=#{ENV['http_proxy']}",
77
+ "--engine-env", "https_proxy=#{ENV['https_proxy']}",
78
+ ]
79
+ @doma_create_text, @doma_create_status = run("docker-machine create --driver virtualbox #{options.join(" ")} #{machine_name}", cmd: :visible, output: :visible)
80
+ end
81
+
82
+ def doma_create_ok?
83
+ @doma_create_status == 0 || @doma_create_text =~ /already exists/
84
+ end
85
+
86
+ def doma_start
87
+ @doma_start_text, @doma_start_status = run("docker-machine start #{machine_name}", cmd: :visible, output: :visible)
88
+ @doma_env_set = false
89
+
90
+ if doma_start_ok?
91
+ @doma_env_text, @doma_env_status = run("docker-machine env #{machine_name}")
92
+ if @doma_env_status == 0 && set_env(@doma_env_text)
93
+ # We use docker-machine for a local provider only, so we shouldn't use any proxy to connect to it.
94
+ if host=ENV['DOCKER_HOST']
95
+ ENV['NO_PROXY'] = [ENV['NO_PROXY'], URI.parse(host).host].compact.join(",")
96
+ end
97
+ @doma_env_set = true
98
+ end
99
+ end
100
+ end
101
+
102
+ def doma_start_ok?
103
+ @doma_start_status == 0 || @doma_start_text =~ /already running/
104
+ end
105
+
106
+ def doma_env_ok?
107
+ @doma_env_status == 0
108
+ end
109
+
110
+ def doma_has_env?
111
+ @doma_env_set
112
+ end
113
+
49
114
  def b2d_version
50
115
  @b2d_version_text = `boot2docker version 2>&1` rescue SystemCallError
51
116
  @b2d_version_status = $?.exitstatus
@@ -71,19 +136,11 @@ module RakeCompilerDock
71
136
 
72
137
  if @b2d_start_status == 0
73
138
  io.puts @b2d_start_text
74
- @b2d_start_text.scan(/(unset |Remove-Item Env:\\)(.+?)$/) do |_, key|
75
- ENV.delete(key)
76
- @b2d_start_envset = true
77
- end
78
- @b2d_start_text.scan(/(export |\$Env:)(.+?)(=| = ")(.*?)(|\")$/) do |_, key, _, val, _|
79
- ENV[key] = val
139
+ if set_env(@b2d_start_text)
80
140
  @b2d_start_envset = true
141
+ io.puts yellow("Using above environment variables for starting #{machine_name}.")
81
142
  end
82
143
  end
83
-
84
- if @b2d_start_envset
85
- io.puts yellow("Using above environment variables for starting rake-compiler-dock.")
86
- end
87
144
  end
88
145
 
89
146
  def b2d_start_ok?
@@ -94,9 +151,22 @@ module RakeCompilerDock
94
151
  @b2d_start_envset
95
152
  end
96
153
 
154
+ def set_env(text)
155
+ set = false
156
+ text.scan(/(unset |Remove-Item Env:\\)(.+?)$/) do |_, key|
157
+ ENV.delete(key)
158
+ set = true
159
+ end
160
+ text.scan(/(export |\$Env:)(.+?)(="|=| = ")(.*?)(|\")$/) do |_, key, _, val, _|
161
+ ENV[key] = val
162
+ set = true
163
+ end
164
+ set
165
+ end
166
+
97
167
  def help_text
98
168
  help = []
99
- if !ok? && docker_client_avail? && !b2d_avail?
169
+ if !ok? && docker_client_avail? && !doma_avail? && !b2d_avail?
100
170
  help << red("Docker client tools work, but connection to the local docker server failed.")
101
171
  case RUBY_PLATFORM
102
172
  when /linux/
@@ -114,17 +184,17 @@ module RakeCompilerDock
114
184
  help << " sudo systemctl start docker"
115
185
  help << ""
116
186
  help << yellow("Then re-check with '") + white("docker version") + yellow("'")
117
- help << yellow("or have a look at the FAQs: http://git.io/vtD2Z")
187
+ help << yellow("or have a look at our FAQs: http://git.io/vm8AL")
118
188
  else
119
189
  help << yellow(" Please check why '") + white("docker version") + yellow("' fails")
120
- help << yellow(" or have a look at the FAQs: http://git.io/vtD2Z")
190
+ help << yellow(" or have a look at our FAQs: http://git.io/vm8AL")
121
191
  end
122
- elsif !ok? && !b2d_avail?
192
+ elsif !ok? && !doma_avail? && !b2d_avail?
123
193
  case RUBY_PLATFORM
124
194
  when /mingw|mswin/
125
195
  help << red("Docker is not available.")
126
- help << yellow("Please download and install boot2docker:")
127
- help << yellow(" https://github.com/boot2docker/windows-installer/releases")
196
+ help << yellow("Please download and install the docker-toolbox:")
197
+ help << yellow(" https://www.docker.com/docker-toolbox")
128
198
  when /linux/
129
199
  help << red("Docker is not available.")
130
200
  help << ""
@@ -140,33 +210,70 @@ module RakeCompilerDock
140
210
  help << " sudo systemctl start docker"
141
211
  when /darwin/
142
212
  help << red("Docker is not available.")
143
- help << yellow("Please download and install boot2docker:")
144
- help << yellow(" https://github.com/boot2docker/osx-installer/releases")
213
+ help << yellow("Please install docker-machine per homebrew:")
214
+ help << " brew cask install virtualbox"
215
+ help << " brew install docker"
216
+ help << " brew install docker-machine"
217
+ help << ""
218
+ help << yellow("or download and install the official docker-toolbox:")
219
+ help << yellow(" https://www.docker.com/docker-toolbox")
145
220
  else
146
221
  help << red("Docker is not available.")
147
222
  end
148
- elsif !ok? && !b2d_init_ok?
149
- help << red("boot2docker is installed but couldn't be initialized.")
150
- help << ""
151
- help << yellow(" Please check why '") + white("boot2docker init") + yellow("' fails")
152
- help << yellow(" or have a look at the FAQs: http://git.io/vtDBH")
153
- elsif !ok? && !b2d_start_ok?
154
- help << red("boot2docker is installed but couldn't be started.")
155
- help << ""
156
- help << yellow(" Please check why '") + white("boot2docker start") + yellow("' fails.")
157
- help << yellow(" You might need to re-init with '") + white("boot2docker delete") + yellow("'")
158
- help << yellow(" or have a look at the FAQs: http://git.io/vtDBH")
159
- elsif !ok? && b2d_start_ok?
160
- help << red("boot2docker is installed and started, but 'docker version' failed.")
161
- help << ""
162
- if b2d_start_has_env?
163
- help << yellow(" Please copy and paste above environment variables to your terminal")
164
- help << yellow(" and check why '") + white("docker version") + yellow("' fails.")
165
- else
166
- help << yellow(" Please check why '") + white("docker version") + yellow("' fails.")
223
+ elsif doma_avail?
224
+ if !ok? && !doma_create_ok?
225
+ help << red("docker-machine is installed but machine couldn't be created.")
226
+ help << ""
227
+ help << yellow(" Please check why '") + white("docker-machine create") + yellow("' fails")
228
+ help << yellow(" or have a look at our FAQs: http://git.io/vRzIg")
229
+ elsif !ok? && !doma_start_ok?
230
+ help << red("docker-machine is installed but couldn't be started.")
231
+ help << ""
232
+ help << yellow(" Please check why '") + white("docker-machine start") + yellow("' fails.")
233
+ help << yellow(" You might need to re-init with '") + white("docker-machine rm") + yellow("'")
234
+ help << yellow(" or have a look at our FAQs: http://git.io/vRzIg")
235
+ elsif !ok? && !doma_env_ok?
236
+ help << red("docker-machine is installed and started, but 'docker-machine env' failed.")
237
+ help << ""
238
+ help << yellow("You might try to regenerate TLS certificates with:")
239
+ help << " docker-machine regenerate-certs #{machine_name}"
240
+ elsif !ok?
241
+ help << red("docker-machine is installed and started, but 'docker version' failed.")
242
+ help << ""
243
+
244
+ if doma_has_env?
245
+ help << yellow(" Please copy and paste following environment variables to your terminal")
246
+ help += @doma_env_text.each_line.reject{|l| l=~/\s*#/ }.map{|l| " #{l.chomp}" }
247
+ help << yellow(" and check why '") + white("docker version") + yellow("' fails.")
248
+ else
249
+ help << yellow(" Please check why '") + white("docker version") + yellow("' fails.")
250
+ end
251
+ help << yellow(" You might also have a look at our FAQs: http://git.io/vRzIg")
252
+ end
253
+ elsif b2d_avail?
254
+ if !ok? && !b2d_init_ok?
255
+ help << red("boot2docker is installed but couldn't be initialized.")
256
+ help << ""
257
+ help << yellow(" Please check why '") + white("boot2docker init") + yellow("' fails")
258
+ help << yellow(" or have a look at our FAQs: http://git.io/vm8Nr")
259
+ elsif !ok? && !b2d_start_ok?
260
+ help << red("boot2docker is installed but couldn't be started.")
261
+ help << ""
262
+ help << yellow(" Please check why '") + white("boot2docker start") + yellow("' fails.")
263
+ help << yellow(" You might need to re-init with '") + white("boot2docker delete") + yellow("'")
264
+ help << yellow(" or have a look at our FAQs: http://git.io/vm8Nr")
265
+ elsif !ok? && b2d_start_ok?
266
+ help << red("boot2docker is installed and started, but 'docker version' failed.")
267
+ help << ""
268
+ if b2d_start_has_env?
269
+ help << yellow(" Please copy and paste above environment variables to your terminal")
270
+ help << yellow(" and check why '") + white("docker version") + yellow("' fails.")
271
+ else
272
+ help << yellow(" Please check why '") + white("docker version") + yellow("' fails.")
273
+ end
274
+ help << yellow(" You might need to re-init with '") + white("boot2docker delete") + yellow("'")
275
+ help << yellow(" or have a look at our FAQs: http://git.io/vm8Nr")
167
276
  end
168
- help << yellow(" You might need to re-init with '") + white("boot2docker delete") + yellow("'")
169
- help << yellow(" or have a look at the FAQs: http://git.io/vtDBH")
170
277
  end
171
278
 
172
279
  help.join("\n")
@@ -175,5 +282,31 @@ module RakeCompilerDock
175
282
  def print_help_text
176
283
  io.puts(help_text)
177
284
  end
285
+
286
+ private
287
+
288
+ def run(cmd, options={})
289
+ if options[:cmd] == :visible
290
+ io.puts "$ #{green(cmd)}"
291
+ end
292
+
293
+ if options[:output] == :visible
294
+ text = String.new
295
+ begin
296
+ IO.popen("#{cmd} 2>&1") do |fd|
297
+ while !fd.eof?
298
+ t = fd.read_nonblock(1024)
299
+ io.write t
300
+ text << t
301
+ end
302
+ end
303
+ rescue SystemCallError
304
+ text = nil
305
+ end
306
+ else
307
+ text = `#{cmd} 2>&1` rescue SystemCallError
308
+ end
309
+ [text, $?.exitstatus]
310
+ end
178
311
  end
179
312
  end
@@ -1,4 +1,5 @@
1
1
  require "shellwords"
2
+ require "etc"
2
3
  require "rake_compiler_dock/version"
3
4
 
4
5
  module RakeCompilerDock
@@ -49,10 +50,8 @@ module RakeCompilerDock
49
50
  uid = Process.uid
50
51
  gid = Process.gid
51
52
  end
52
- user = make_valid_user_name(`id -nu`.chomp)
53
- group = make_valid_group_name(`id -ng`.chomp)
54
-
55
- drun_args = docker_opts + [image_name] + runargs
53
+ user = options.fetch(:username){ current_user }
54
+ group = options.fetch(:groupname){ current_group }
56
55
 
57
56
  cmd = ["docker", "run",
58
57
  "-v", "#{pwd}:#{make_valid_path(pwd)}",
@@ -67,7 +66,9 @@ module RakeCompilerDock
67
66
  "-e", "RCD_HOST_RUBY_VERSION=#{RUBY_VERSION}",
68
67
  "-e", "RCD_IMAGE=#{image_name}",
69
68
  "-w", make_valid_path(pwd),
70
- *drun_args]
69
+ *docker_opts,
70
+ image_name,
71
+ *runargs]
71
72
 
72
73
  cmdline = Shellwords.join(cmd)
73
74
  if verbose_flag(options) == true
@@ -89,10 +90,25 @@ module RakeCompilerDock
89
90
  end
90
91
  end
91
92
 
93
+ def current_user
94
+ make_valid_user_name(Etc.getlogin)
95
+ end
96
+
97
+ def current_group
98
+ group_obj = Etc.getgrgid
99
+ make_valid_group_name(group_obj ? group_obj.name : "dummygroup")
100
+ end
101
+
92
102
  def make_valid_name(name)
93
- name = name.downcase
103
+ name = name.to_s.downcase
104
+ name = "_" if name.empty?
94
105
  # Convert disallowed characters
95
- name = name[0..0].gsub(/[^a-z_]/, "_") + name[1..-2].gsub(/[^a-z0-9_-]/, "_") + name[-1..-1].gsub(/[^a-z0-9_$-]/, "_")
106
+ if name.length > 1
107
+ name = name[0..0].gsub(/[^a-z_]/, "_") + name[1..-2].to_s.gsub(/[^a-z0-9_-]/, "_") + name[-1..-1].to_s.gsub(/[^a-z0-9_$-]/, "_")
108
+ else
109
+ name = name.gsub(/[^a-z_]/, "_")
110
+ end
111
+
96
112
  # Limit to 32 characters
97
113
  name.sub( /^(.{16}).{2,}(.{15})$/ ){ $1+"-"+$2 }
98
114
  end
@@ -1,4 +1,4 @@
1
1
  module RakeCompilerDock
2
- VERSION = "0.4.3"
3
- IMAGE_VERSION = "0.4.2"
2
+ VERSION = "0.5.0"
3
+ IMAGE_VERSION = "0.5.0"
4
4
  end
@@ -11,8 +11,11 @@ Gem::Specification.new do |spec|
11
11
  spec.summary = %q{Easy to use and reliable cross compiler environment for building Windows binary gems.}
12
12
  spec.description = %q{Easy to use and reliable cross compiler environment for building Windows binary gems.
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
- spec.homepage = "https://github.com/larskanis/rake-compiler-dock"
14
+ spec.homepage = "https://github.com/rake-compiler/rake-compiler-dock"
15
15
  spec.license = "MIT"
16
+ # We do not set a ruby version in the gemspec, to allow addition to the Gemfile of gems that still support ruby-1.8.
17
+ # However we do the version check at runtime.
18
+ # spec.required_ruby_version = '>= 1.9.2'
16
19
 
17
20
  spec.files = `git ls-files -z`.split("\x0")
18
21
  spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
@@ -0,0 +1,33 @@
1
+ require 'rake_compiler_dock'
2
+ require 'test/unit'
3
+ begin
4
+ require 'test/unit/notify'
5
+ rescue LoadError
6
+ end
7
+
8
+ class TestStarter < Test::Unit::TestCase
9
+ include RakeCompilerDock
10
+
11
+ def test_make_valid_user_name
12
+ assert_equal "mouse-click", Starter.make_valid_user_name("Mouse-Click")
13
+ assert_equal "very_very_very_l-ame_with_spaces", Starter.make_valid_user_name("Very very very long name with spaces")
14
+ assert_equal "_nobody", Starter.make_valid_user_name("nobody")
15
+ assert_equal "_rvm", Starter.make_valid_user_name("rvm")
16
+ assert_equal "staff", Starter.make_valid_user_name("staff")
17
+ assert_equal "a", Starter.make_valid_user_name("a")
18
+ assert_equal "_", Starter.make_valid_user_name("")
19
+ assert_equal "_", Starter.make_valid_user_name(nil)
20
+ end
21
+
22
+ def test_make_valid_group_name
23
+ assert_equal "mouse-click", Starter.make_valid_group_name("Mouse-Click")
24
+ assert_equal "very_very_very_l-ame_with_spaces", Starter.make_valid_group_name("Very very very long name with spaces")
25
+ assert_equal "nobody", Starter.make_valid_group_name("nobody")
26
+ assert_equal "_rvm", Starter.make_valid_group_name("rvm")
27
+ assert_equal "_staff", Starter.make_valid_group_name("staff")
28
+ assert_equal "a", Starter.make_valid_group_name("a")
29
+ assert_equal "_", Starter.make_valid_group_name("")
30
+ assert_equal "_", Starter.make_valid_group_name(nil)
31
+ end
32
+
33
+ end
metadata CHANGED
@@ -1,13 +1,13 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: rake-compiler-dock
3
- version: !ruby/object:Gem::Version
4
- version: 0.4.3
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.5.0
5
5
  platform: ruby
6
- authors:
6
+ authors:
7
7
  - Lars Kanis
8
8
  autorequire:
9
9
  bindir: bin
10
- cert_chain:
10
+ cert_chain:
11
11
  - |
12
12
  -----BEGIN CERTIFICATE-----
13
13
  MIIDPDCCAiSgAwIBAgIBAjANBgkqhkiG9w0BAQUFADBEMQ0wCwYDVQQDDARsYXJz
@@ -29,52 +29,61 @@ cert_chain:
29
29
  6jkDey5mE3jQb893U6ihl55uLkVQwxZZTq/flNWjTIcbbvKKafEGdGv5uOlB+KRL
30
30
  PRtgPFlA2jDgUr1EPAIH1Q==
31
31
  -----END CERTIFICATE-----
32
-
33
- date: 2015-07-09 00:00:00 Z
34
- dependencies:
35
- - !ruby/object:Gem::Dependency
32
+ date: 2015-12-25 00:00:00.000000000 Z
33
+ dependencies:
34
+ - !ruby/object:Gem::Dependency
36
35
  name: bundler
37
- prerelease: false
38
- requirement: &id001 !ruby/object:Gem::Requirement
39
- requirements:
40
- - - ~>
41
- - !ruby/object:Gem::Version
42
- version: "1.7"
36
+ requirement: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '1.7'
43
41
  type: :development
44
- version_requirements: *id001
45
- - !ruby/object:Gem::Dependency
46
- name: rake
47
42
  prerelease: false
48
- requirement: &id002 !ruby/object:Gem::Requirement
49
- requirements:
50
- - - ~>
51
- - !ruby/object:Gem::Version
52
- version: "10.0"
43
+ version_requirements: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '1.7'
48
+ - !ruby/object:Gem::Dependency
49
+ name: rake
50
+ requirement: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '10.0'
53
55
  type: :development
54
- version_requirements: *id002
55
- - !ruby/object:Gem::Dependency
56
- name: test-unit
57
56
  prerelease: false
58
- requirement: &id003 !ruby/object:Gem::Requirement
59
- requirements:
60
- - - ~>
61
- - !ruby/object:Gem::Version
62
- version: "3.0"
57
+ version_requirements: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '10.0'
62
+ - !ruby/object:Gem::Dependency
63
+ name: test-unit
64
+ requirement: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '3.0'
63
69
  type: :development
64
- version_requirements: *id003
70
+ prerelease: false
71
+ version_requirements: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: '3.0'
65
76
  description: |-
66
77
  Easy to use and reliable cross compiler environment for building Windows binary gems.
67
78
  Use rake-compiler-dock to enter an interactive shell session or add a task to your Rakefile to automate your cross build.
68
- email:
79
+ email:
69
80
  - lars@greiz-reinsdorf.de
70
- executables:
81
+ executables:
71
82
  - rake-compiler-dock
72
83
  extensions: []
73
-
74
84
  extra_rdoc_files: []
75
-
76
- files:
77
- - .gitignore
85
+ files:
86
+ - ".gitignore"
78
87
  - Dockerfile
79
88
  - Gemfile
80
89
  - History.md
@@ -82,48 +91,49 @@ files:
82
91
  - README.md
83
92
  - Rakefile
84
93
  - bin/rake-compiler-dock
94
+ - build/patches/rake-compiler-0.9.5/without-exts.diff
95
+ - build/patches/ruby-1.8.7-p374/nop.patch
96
+ - build/patches/ruby-1.9.3/no_sendfile.patch
97
+ - build/patches/ruby-1.9.3/nop.patch
98
+ - build/patches/ruby-2.3.0/no_sendfile.patch
99
+ - build/runas
100
+ - build/sigfw.c
101
+ - build/strip_wrapper
102
+ - build/sudoers
85
103
  - lib/rake_compiler_dock.rb
86
104
  - lib/rake_compiler_dock/colors.rb
87
105
  - lib/rake_compiler_dock/docker_check.rb
88
106
  - lib/rake_compiler_dock/predefined_user_group.rb
89
107
  - lib/rake_compiler_dock/starter.rb
90
108
  - lib/rake_compiler_dock/version.rb
91
- - patches/ruby-1.8.7-p374/nop.patch
92
- - patches/ruby-1.9.3/no_sendfile.patch
93
- - patches/ruby-1.9.3/nop.patch
94
- - patches/ruby-2.2.2/no_sendfile.patch
95
109
  - rake-compiler-dock.gemspec
96
- - src/rake-compiler-without-exts.diff
97
- - src/runas
98
- - src/sigfw.c
99
- - src/strip_wrapper
100
- - src/sudoers
101
110
  - test/test_environment_variables.rb
102
- homepage: https://github.com/larskanis/rake-compiler-dock
103
- licenses:
111
+ - test/test_starter.rb
112
+ homepage: https://github.com/rake-compiler/rake-compiler-dock
113
+ licenses:
104
114
  - MIT
105
115
  metadata: {}
106
-
107
116
  post_install_message:
108
117
  rdoc_options: []
109
-
110
- require_paths:
118
+ require_paths:
111
119
  - lib
112
- required_ruby_version: !ruby/object:Gem::Requirement
113
- requirements:
114
- - &id004
115
- - ">="
116
- - !ruby/object:Gem::Version
117
- version: "0"
118
- required_rubygems_version: !ruby/object:Gem::Requirement
119
- requirements:
120
- - *id004
120
+ required_ruby_version: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - ">="
123
+ - !ruby/object:Gem::Version
124
+ version: '0'
125
+ required_rubygems_version: !ruby/object:Gem::Requirement
126
+ requirements:
127
+ - - ">="
128
+ - !ruby/object:Gem::Version
129
+ version: '0'
121
130
  requirements: []
122
-
123
131
  rubyforge_project:
124
- rubygems_version: 2.0.3
132
+ rubygems_version: 2.4.8
125
133
  signing_key:
126
134
  specification_version: 4
127
- summary: Easy to use and reliable cross compiler environment for building Windows binary gems.
128
- test_files:
135
+ summary: Easy to use and reliable cross compiler environment for building Windows
136
+ binary gems.
137
+ test_files:
129
138
  - test/test_environment_variables.rb
139
+ - test/test_starter.rb
metadata.gz.sig CHANGED
Binary file