rake-compiler-dock 0.2.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: a9d812c3d58c67858e89228862019e7414399f0a
4
- data.tar.gz: a49c40cc58b5687fac2b5b7d9f9fbeb50ab4cd5b
3
+ metadata.gz: baf177d3bb521223da3b6c4813223e8d061e4692
4
+ data.tar.gz: 28cd1acc6452ed7eab4b897c7b2dacbf88460f37
5
5
  SHA512:
6
- metadata.gz: 63a62025d40a77e6ea621119b2103e4e6a3290e8f5556fc73daa2a2f4bce1c4c3eae57f3f1b9719a105b6c276098887c9a0fb8aab5d5e50d25d3ea9343da4445
7
- data.tar.gz: cd2f86c14498ae4cfcd54f739a1f007c1bcf4a5e3a9bf6a1bfced80bc9420468e29f25269aab8a1e03952cb11b073a633758c028b27acfa2570aa781de8e73d6
6
+ metadata.gz: 4cf5327994d25b154d26021fc291fa719a33b4c4304b1376128d692b3557d9e6061b2a556ecd94796a82001a81b37c1debcd7b8e9c052824fc85e581de86ce31
7
+ data.tar.gz: 247e9649bf95c6ebaaca46bed11eb0b6896f957524a3abf2f99e2325598f554be03560ed993cc6e16733a2c26d40d7d9de6942b77b33f8a2fd51917b3eafc184
checksums.yaml.gz.sig CHANGED
Binary file
data.tar.gz.sig CHANGED
Binary file
data/Dockerfile CHANGED
@@ -6,14 +6,12 @@ RUN apt-get -y update && \
6
6
  RUN mkdir -p /opt/mingw && \
7
7
  curl -SL http://sunet.dl.sourceforge.net/project/mingw-w64/Toolchains%20targetting%20Win32/Personal%20Builds/rubenvb/gcc-4.7-release/i686-w64-mingw32-gcc-4.7.2-release-linux64_rubenvb.tar.xz | \
8
8
  tar -xJC /opt/mingw && \
9
- echo "export PATH=\$PATH:/opt/mingw/mingw32/bin" >> /etc/rubybashrc && \
10
- ln -s /opt/mingw/mingw32/bin/* /usr/local/bin/
9
+ echo "export PATH=\$PATH:/opt/mingw/mingw32/bin" >> /etc/rubybashrc
11
10
 
12
11
  RUN mkdir -p /opt/mingw && \
13
12
  curl -SL http://softlayer-ams.dl.sourceforge.net/project/mingw-w64/Toolchains%20targetting%20Win64/Personal%20Builds/rubenvb/gcc-4.7-release/x86_64-w64-mingw32-gcc-4.7.2-release-linux64_rubenvb.tar.xz | \
14
13
  tar -xJC /opt/mingw && \
15
- echo "export PATH=\$PATH:/opt/mingw/mingw64/bin" >> /etc/rubybashrc && \
16
- ln -s /opt/mingw/mingw64/bin/* /usr/local/bin/
14
+ echo "export PATH=\$PATH:/opt/mingw/mingw64/bin" >> /etc/rubybashrc
17
15
 
18
16
  # Add "rvm" as system group, to avoid conflicts with host GIDs typically starting with 1000
19
17
  RUN groupadd -r rvm && useradd -r -g rvm -G sudo -p "" --create-home rvm && \
@@ -86,9 +84,11 @@ RUN bash -c " \
86
84
 
87
85
  USER root
88
86
 
89
- # Fix paths in rake-compiler/config.yml and add rvm to the global bashrc
87
+ # Fix paths in rake-compiler/config.yml and add rvm and mingw-tools to the global bashrc
90
88
  RUN sed -i -- "s:/root/.rake-compiler:/usr/local/rake-compiler:g" /usr/local/rake-compiler/config.yml && \
91
- echo "source /etc/profile.d/rvm.sh" >> /etc/bash.bashrc
89
+ echo "source /etc/profile.d/rvm.sh" >> /etc/bash.bashrc && \
90
+ echo "export PATH=\$PATH:/opt/mingw/mingw32/bin" >> /etc/bash.bashrc && \
91
+ echo "export PATH=\$PATH:/opt/mingw/mingw64/bin" >> /etc/bash.bashrc
92
92
 
93
93
  # Install wrappers for strip commands as a workaround for "Protocol error" in boot2docker.
94
94
  ADD src/strip_wrapper /root/
data/History.md CHANGED
@@ -1,3 +1,10 @@
1
+ 0.3.0 / 2015-06-17
2
+ ------------------
3
+ * Workaround an issue with broken DLLs when building on Windows.
4
+ * Print docker command line based on verbose flag of rake.
5
+ * Add check for docker and instructions for install.
6
+
7
+
1
8
  0.2.0 / 2015-06-08
2
9
  ------------------
3
10
  * Add a simple API for running commands within the rake-compiler-dock environment.
data/README.md CHANGED
@@ -1,9 +1,12 @@
1
1
  # rake-compiler-dock
2
2
 
3
- Easy to use Docker based cross compiler environment for building binary windows gems.
3
+ Easy to use Docker based cross compiler environment for building binary Windows gems.
4
4
 
5
- This is similar to [rake-compiler-dev-box](https://github.com/tjschuck/rake-compiler-dev-box) but is based on lightweight Docker containers and is wrapped as a gem for easier usage and integration.
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) .
6
7
 
8
+ This is similar to [rake-compiler-dev-box](https://github.com/tjschuck/rake-compiler-dev-box) but is based on lightweight Docker containers and is wrapped as a gem for easier setup, usage and integration.
9
+ It is also a bit more reliable, since the underlying docker images are versioned and kept unchanged while building.
7
10
 
8
11
  ## Installation
9
12
 
@@ -32,7 +35,7 @@ All commands are executed with the current user and group of the host.
32
35
  `rake-compiler-dock` without arguments starts an interactive shell session.
33
36
  You can choose between different ruby versions by `rvm use <version>` .
34
37
  All changes within the current working directory are shared with the host.
35
- But note, that all other changes to the file system are dropped at the end of the session.
38
+ But note, that all other changes to the file system are dropped at the end of the session - the docker image is stateless.
36
39
 
37
40
  `rake-compiler-dock` can also take the build command(s) from STDIN or as command arguments.
38
41
 
@@ -3,6 +3,10 @@
3
3
  require 'rake_compiler_dock'
4
4
 
5
5
  args = ARGV.empty? ? ['bash'] : ARGV
6
- RakeCompilerDock.exec(*args) do |ok, res|
7
- exit(res.exitstatus)
6
+ begin
7
+ RakeCompilerDock.exec(*args) do |ok, res|
8
+ exit(res.exitstatus)
9
+ end
10
+ rescue RakeCompilerDock::DockerIsNotAvailable
11
+ exit(-1)
8
12
  end
@@ -1,23 +1,33 @@
1
+ require "shellwords"
1
2
  require "rake_compiler_dock/version"
2
3
 
3
4
  module RakeCompilerDock
5
+ class DockerIsNotAvailable < RuntimeError
6
+ end
7
+
4
8
  # Run the command cmd within a fresh rake-compiler-dock container and within a shell.
5
9
  #
6
10
  # If a block is given, upon command completion the block is called with an OK flag (true on a zero exit status) and a Process::Status object.
7
11
  # Without a block a RuntimeError is raised when the command exits non-zero.
8
12
  #
13
+ # Option +:verbose+ can be set to enable printing of the command line.
14
+ # If not set, the rake verbose_flag is used.
15
+ #
9
16
  # Examples:
10
17
  #
11
18
  # RakeCompilerDock.sh 'bundle && rake cross native gem'
12
19
  #
13
20
  # # check exit status after command runs
14
- # sh %{bundle && rake cross native gem} do |ok, res|
21
+ # sh %{bundle && rake cross native gem}, verbose: true do |ok, res|
15
22
  # if ! ok
16
23
  # puts "windows cross build failed (status = #{res.exitstatus})"
17
24
  # end
18
25
  # end
19
- def sh(cmd, &block)
20
- exec('bash', '-c', cmd, &block)
26
+ def sh(cmd, options={}, &block)
27
+ if verbose_flag(options)
28
+ $stderr.puts "rake-compiler-dock bash -c #{ cmd.inspect }"
29
+ end
30
+ exec('bash', '-c', cmd, options, &block)
21
31
  end
22
32
 
23
33
  def image_name
@@ -30,10 +40,18 @@ module RakeCompilerDock
30
40
  # If a block is given, upon command completion the block is called with an OK flag (true on a zero exit status) and a Process::Status object.
31
41
  # Without a block a RuntimeError is raised when the command exits non-zero.
32
42
  #
43
+ # Option +:verbose+ can be set to enable printing of the command line.
44
+ # If not set, the rake verbose_flag is used.
45
+ # Option +:check_docker+ can be set to false to disable the docker check.
46
+ #
33
47
  # Examples:
34
48
  #
35
49
  # RakeCompilerDock.exec 'bash', '-c', 'echo $RUBY_CC_VERSION'
36
50
  def exec(*args)
51
+ options = (Hash === args.last) ? args.pop : {}
52
+
53
+ check_docker if options.fetch(:check_docker){ true }
54
+
37
55
  if RUBY_PLATFORM =~ /mingw|mswin/
38
56
  # Change Path from "C:\Path" to "/c/Path" as used by boot2docker
39
57
  pwd = Dir.pwd.gsub(/^([a-z]):/i){ "/#{$1.downcase}" }
@@ -60,15 +78,63 @@ module RakeCompilerDock
60
78
  image_name,
61
79
  "sigfw", "runas", *args]
62
80
 
81
+ cmdline = Shellwords.join(cmd)
82
+ if verbose_flag(options) == true
83
+ $stderr.puts cmdline
84
+ end
85
+
63
86
  ok = system(*cmd)
64
87
  if block_given?
65
88
  yield(ok, $?)
66
89
  elsif !ok
67
- show_command = cmd.join(" ")
68
90
  fail "Command failed with status (#{$?.exitstatus}): " +
69
- "[#{show_command}]"
91
+ "[#{cmdline}]"
92
+ end
93
+ end
94
+
95
+ def verbose_flag(options)
96
+ verbose = options.fetch(:verbose) do
97
+ Object.const_defined?(:Rake) && Rake.const_defined?(:FileUtilsExt) ? Rake::FileUtilsExt.verbose_flag : false
98
+ end
99
+ end
100
+
101
+ @@docker_checked = false
102
+
103
+ def check_docker
104
+ return if @@docker_checked
105
+
106
+ version_text = `docker version` rescue SystemCallError
107
+ if $?.exitstatus == 0 && version_text.to_s =~ /version/
108
+ @@docker_checked = true
109
+ else
110
+ case RUBY_PLATFORM
111
+ when /mingw|mswin/
112
+ $stderr.puts "Docker is not available. Please download and install boot2docker:"
113
+ $stderr.puts " https://github.com/boot2docker/windows-installer/releases"
114
+ $stderr.puts
115
+ $stderr.puts "Then execute 'boot2docker start' and follow the instuctions"
116
+ when /linux/
117
+ $stderr.puts "Docker is not available."
118
+ $stderr.puts
119
+ $stderr.puts "Install on Ubuntu/Debian:"
120
+ $stderr.puts " sudo apt-get install docker.io"
121
+ $stderr.puts
122
+ $stderr.puts "Install on Fedora/Centos/RHEL"
123
+ $stderr.puts " sudo yum install docker"
124
+ $stderr.puts " sudo systemctl start docker"
125
+ $stderr.puts
126
+ $stderr.puts "Install on SuSE"
127
+ $stderr.puts " sudo zypper install docker"
128
+ $stderr.puts " sudo systemctl start docker"
129
+ when /darwin/
130
+ $stderr.puts "Docker is not available. Please download and install boot2docker:"
131
+ $stderr.puts " https://github.com/boot2docker/osx-installer/releases"
132
+ else
133
+ $stderr.puts "Docker is not available."
134
+ end
135
+ raise DockerIsNotAvailable, "Docker is not available"
70
136
  end
71
137
  end
72
138
 
73
- module_function :exec, :sh, :image_name
139
+ module_function :exec, :sh, :image_name, :verbose_flag, :check_docker
74
140
  end
@@ -1,3 +1,3 @@
1
1
  module RakeCompilerDock
2
- VERSION = "0.2.0"
2
+ VERSION = "0.3.0"
3
3
  end
data/src/strip_wrapper CHANGED
@@ -10,6 +10,7 @@ strip = "#{File.basename($0)}.bin"
10
10
 
11
11
  files = ARGV.reject{|f| f=~/^-/ }.map do |arg|
12
12
  tmp = Tempfile.new 'strip'
13
+ tmp.close
13
14
  FileUtils.cp arg, tmp.path
14
15
  [tmp, arg]
15
16
  end
@@ -17,12 +18,12 @@ end
17
18
  options = ARGV.select{|f| f=~/^-/ } + files.map{|t,o| t.path }
18
19
 
19
20
  unless system( strip, *options )
20
- puts "unable to execute #{strip}"
21
21
  exit 127
22
22
  end
23
23
  code = $?.exitstatus
24
24
 
25
25
  files.each do |tmp, orig|
26
+ FileUtils.rm orig
26
27
  FileUtils.cp tmp.path, orig
27
28
  end
28
29
 
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.2.0
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Lars Kanis
@@ -10,26 +10,26 @@ bindir: bin
10
10
  cert_chain:
11
11
  - |
12
12
  -----BEGIN CERTIFICATE-----
13
- MIIDPDCCAiSgAwIBAgIBAjANBgkqhkiG9w0BAQUFADBEMQ0wCwYDVQQDDARsYXJz
14
- MR8wHQYKCZImiZPyLGQBGRYPZ3JlaXotcmVpbnNkb3JmMRIwEAYKCZImiZPyLGQB
15
- GRYCZGUwHhcNMTUwMzEzMjAzMjExWhcNMTYwMzEyMjAzMjExWjBEMQ0wCwYDVQQD
16
- DARsYXJzMR8wHQYKCZImiZPyLGQBGRYPZ3JlaXotcmVpbnNkb3JmMRIwEAYKCZIm
17
- iZPyLGQBGRYCZGUwggEiMA0G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jYxNDIyNDRaMD0xDjAMBgNVBAMMBWthbmlz
16
+ MRcwFQYKCZImiZPyLGQBGRYHY29tY2FyZDESMBAGCgmSJomT8ixkARkWAmRlMIIB
17
+ IjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEApop+rNmg35bzRugZ21VMGqI6
18
+ HGzPLO4VHYncWn/xmgPU/ZMcZdfj6MzIaZJ/czXyt4eHpBk1r8QOV3gBXnRXEjVW
19
+ 9xi+EdVOkTV2/AVFKThcbTAQGiF/bT1n2M+B1GTybRzMg6hyhOJeGPqIhLfJEpxn
20
+ lJi4+ENAVT4MpqHEAGB8yFoPC0GqiOHQsdHxQV3P3c2OZqG+yJey74QtwA2tLcLn
21
+ Q53c63+VLGsOjODl1yPn/2ejyq8qWu6ahfTxiIlSar2UbwtaQGBDFdb2CXgEufXT
22
+ L7oaPxlmj+Q2oLOfOnInd2Oxop59HoJCQPsg8f921J43NCQGA8VHK6paxIRDLQID
23
+ AQABozkwNzAJBgNVHRMEAjAAMAsGA1UdDwQEAwIEsDAdBgNVHQ4EFgQUvgTdT7fe
24
+ x17ugO3IOsjEJwW7KP4wDQYJKoZIhvcNAQEFBQADggEBAE4pDPwv7zV/guo2ZETn
25
+ V+oVXMvEtUv7lPLpUYTM/g1qHP+mue4vZrhHTZbqEgxZEv03noz/4yIHizMQljED
26
+ 6aUw0DSCQiOtK39LeHE2SfVPnpJdl6R9WX6ObdhNvN3Q9bJL2Ng3TTPidj9on2jO
27
+ 6SevWmI9NMDsupzXOjeuNKbUivcCKgIsp3+qjw1gGURF6eITEM+kxV+u4eC5ah/f
28
+ iV4wuwAX30bHxaaOA2owy1BJBOHwTl5XBJFKWBf+HlTIGL6yrOjTb+rB+/rSTttv
29
+ 1i6jssufMLmyDB9b1ss72d7xQQpCHH7oizgt84wKAcsV8b83kGbAhtoszY3TgGiJ
30
+ rww=
31
31
  -----END CERTIFICATE-----
32
- date: 2015-06-08 00:00:00.000000000 Z
32
+ date: 2015-06-17 00:00:00.000000000 Z
33
33
  dependencies:
34
34
  - !ruby/object:Gem::Dependency
35
35
  name: bundler
@@ -110,4 +110,3 @@ signing_key:
110
110
  specification_version: 4
111
111
  summary: Docker based cross compiler environment for building binary windows gems.
112
112
  test_files: []
113
- has_rdoc:
metadata.gz.sig CHANGED
Binary file