iron_worker_ng 0.11.3 → 0.12.0

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -165,14 +165,6 @@ Runs code package on your local box. Can be useful for testing.
165
165
  code.run
166
166
  ```
167
167
 
168
- ### hash_string()
169
-
170
- Return the hash string for the code package. If you want to prevent uploading unchanged code packages, you can use it to check if any changes were made. It's very efficient, so it shouldn't cause any performance impact.
171
-
172
- ```
173
- puts code.hash_string
174
- ```
175
-
176
168
  ### merge_file(path, dest = '')
177
169
  ### file(path, dest = '')
178
170
 
@@ -7,6 +7,7 @@ require_relative '../feature/base'
7
7
  require_relative '../feature/common/merge_exec'
8
8
  require_relative '../feature/common/merge_file'
9
9
  require_relative '../feature/common/merge_dir'
10
+ require_relative '../feature/common/merge_deb'
10
11
 
11
12
  module IronWorkerNG
12
13
  module Code
@@ -22,6 +23,7 @@ module IronWorkerNG
22
23
 
23
24
  include IronWorkerNG::Feature::Common::MergeFile::InstanceMethods
24
25
  include IronWorkerNG::Feature::Common::MergeDir::InstanceMethods
26
+ include IronWorkerNG::Feature::Common::MergeDeb::InstanceMethods
25
27
 
26
28
  def initialize(*args, &block)
27
29
  @features = []
@@ -176,12 +178,6 @@ module IronWorkerNG
176
178
  end
177
179
  end
178
180
 
179
- def hash_string
180
- fixate
181
-
182
- Digest::MD5.hexdigest(@features.map { |f| f.hash_string }.join)
183
- end
184
-
185
181
  def runtime_bundle(container, local = false)
186
182
  end
187
183
 
@@ -213,10 +209,10 @@ root() {
213
209
 
214
210
  cd "$(root "$@")"
215
211
 
216
- LD_LIBRARY_PATH=.
212
+ LD_LIBRARY_PATH=.:./__debs__/usr/lib:./__debs__/usr/lib/x86_64-linux-gnu:./__debs__/lib:./__debs__/lib/x86_64-linux-gnu
217
213
  export LD_LIBRARY_PATH
218
214
 
219
- PATH=.:$PATH
215
+ PATH=.:./__debs__/usr/bin:./__debs__/bin:$PATH
220
216
  export PATH
221
217
 
222
218
  #{runtime_run_code(local)}
@@ -17,12 +17,15 @@ module IronWorkerNG
17
17
  dest
18
18
  end
19
19
 
20
- def add(dest, src, commit = false)
20
+ def add(dest, src)
21
21
  end
22
22
 
23
23
  def get_output_stream(dest, &block)
24
24
  end
25
25
 
26
+ def commit
27
+ end
28
+
26
29
  def close
27
30
  end
28
31
  end
@@ -8,7 +8,7 @@ module IronWorkerNG
8
8
  @name + '/' + clear_dest(dest)
9
9
  end
10
10
 
11
- def add(dest, src, commit = false)
11
+ def add(dest, src)
12
12
  FileUtils.mkdir_p(File.dirname(full_dest(dest)))
13
13
 
14
14
  if File.directory?(src)
@@ -1,5 +1,7 @@
1
1
  require 'zip/zip'
2
2
 
3
+ Zip.options[:continue_on_exists_proc] = true
4
+
3
5
  module IronWorkerNG
4
6
  module Code
5
7
  module Container
@@ -11,12 +13,14 @@ module IronWorkerNG
11
13
  @zip = ::Zip::ZipFile.open(@name, ::Zip::ZipFile::CREATE)
12
14
  end
13
15
 
14
- def add(dest, src, commit = false)
16
+ def add(dest, src)
15
17
  @zip.add(clear_dest(dest), src)
16
-
17
- @zip.commit if commit
18
18
  end
19
19
 
20
+ def commit
21
+ @zip.commit
22
+ end
23
+
20
24
  def get_output_stream(dest, &block)
21
25
  @zip.get_output_stream(clear_dest(dest), &block)
22
26
  end
@@ -39,6 +39,7 @@ task_id = nil
39
39
  end
40
40
 
41
41
  ENV['GEM_PATH'] = ([root + '__gems__'] + (ENV['GEM_PATH'] || '').split(':')).join(':')
42
+ ENV['GEM_HOME'] = root + '__gems__'
42
43
 
43
44
  $:.unshift("\#{root}")
44
45
 
@@ -13,7 +13,7 @@ module IronWorkerNG
13
13
  @code.base_dir + path
14
14
  end
15
15
 
16
- def container_add(container, dest, src)
16
+ def container_add(container, dest, src, commit = false)
17
17
  IronWorkerNG::Fetcher.fetch_to_file(src) do |local_src|
18
18
  if local_src.nil? || (not File.exists?(local_src))
19
19
  IronCore::Logger.error 'IronWorkerNG', "Can't find src with path='#{src}'", IronCore::Error
@@ -24,13 +24,13 @@ module IronWorkerNG
24
24
  container.add(@code.dest_dir + dest + path[local_src.length .. -1], path)
25
25
  end
26
26
  else
27
- container.add(@code.dest_dir + dest, local_src, IronWorkerNG::Fetcher.remote?(src))
27
+ container.add(@code.dest_dir + dest, local_src)
28
28
  end
29
- end
30
- end
31
29
 
32
- def hash_string
33
- ''
30
+ if IronWorkerNG::Fetcher.remote?(src) || commit
31
+ container.commit
32
+ end
33
+ end
34
34
  end
35
35
 
36
36
  def bundle(container)
@@ -0,0 +1,70 @@
1
+ require 'tmpdir'
2
+ require 'fileutils'
3
+
4
+ module IronWorkerNG
5
+ module Feature
6
+ module Common
7
+ module MergeDeb
8
+ class Feature < IronWorkerNG::Feature::Base
9
+ attr_reader :path
10
+
11
+ def initialize(code, path)
12
+ super(code)
13
+
14
+ @path = path
15
+ end
16
+
17
+ def bundle(container)
18
+ IronCore::Logger.debug 'IronWorkerNG', "Bundling deb with path='#{@path}'"
19
+
20
+ if (not @code.remote_build_command) && (not @code.full_remote_build)
21
+ IronWorkerNG::Fetcher.fetch_to_file(rebase(@path)) do |deb|
22
+ if deb.nil? || (not File.exists?(deb))
23
+ IronCore::Logger.error 'IronWorkerNG', "Can't find deb with path='#{@path}'"
24
+ end
25
+
26
+ tmp_dir_name = ::Dir.tmpdir + '/' + ::Dir::Tmpname.make_tmpname('iron-worker-ng-', 'deb')
27
+
28
+ ::Dir.mkdir(tmp_dir_name)
29
+
30
+ `dpkg -x #{deb} #{tmp_dir_name}`
31
+
32
+ ::Dir.glob(tmp_dir_name) do |path|
33
+ container_add(container, '__debs__', path, true)
34
+ end
35
+
36
+ FileUtils.rm_rf(tmp_dir_name)
37
+ end
38
+ else
39
+ if (not @code.full_remote_build) || (not IronWorkerNG::Fetcher.remote?(rebase(@path)))
40
+ container_add(container, File.basename(@path), rebase(@path))
41
+ end
42
+ end
43
+ end
44
+
45
+ def build_command
46
+ if @code.remote_build_command || @code.full_remote_build
47
+ if @code.full_remote_build && IronWorkerNG::Fetcher.remote?(rebase(@path))
48
+ "deb '#{rebase(@path)}'"
49
+ else
50
+ "deb '#{@code.dest_dir}#{File.basename(@path)}'"
51
+ end
52
+ else
53
+ nil
54
+ end
55
+ end
56
+ end
57
+
58
+ module InstanceMethods
59
+ def merge_deb(path)
60
+ IronCore::Logger.info 'IronWorkerNG', "Merging deb with path='#{path}'"
61
+
62
+ @features << IronWorkerNG::Feature::Common::MergeDeb::Feature.new(self, path)
63
+ end
64
+
65
+ alias :deb :merge_deb
66
+ end
67
+ end
68
+ end
69
+ end
70
+ end
@@ -13,16 +13,6 @@ module IronWorkerNG
13
13
  @dest = dest + (dest.empty? || dest.end_with?('/') ? '' : '/')
14
14
  end
15
15
 
16
- def hash_string
17
- s = @path + @dest + File.mtime(rebase(@path)).to_i.to_s
18
-
19
- ::Dir.glob(rebase(@path) + '/**/**') do |path|
20
- s += path + File.mtime(path).to_i.to_s
21
- end
22
-
23
- Digest::MD5.hexdigest(s)
24
- end
25
-
26
16
  def bundle(container)
27
17
  IronCore::Logger.debug 'IronWorkerNG', "Bundling dir with path='#{@path}' and dest='#{@dest}'"
28
18
 
@@ -23,10 +23,6 @@ module IronWorkerNG
23
23
  nil
24
24
  end
25
25
 
26
- def hash_string
27
- Digest::MD5.hexdigest(@path + File.mtime(rebase(@path)).to_i.to_s + args.to_s)
28
- end
29
-
30
26
  def bundle(container)
31
27
  IronCore::Logger.debug 'IronWorkerNG', "Bundling exec with path='#{@path}' and args='#{@args.inspect}'"
32
28
 
@@ -13,10 +13,6 @@ module IronWorkerNG
13
13
  @dest = dest + (dest.empty? || dest.end_with?('/') ? '' : '/')
14
14
  end
15
15
 
16
- def hash_string
17
- Digest::MD5.hexdigest(@path + @dest + File.mtime(rebase(@path)).to_i.to_s)
18
- end
19
-
20
16
  def bundle(container)
21
17
  IronCore::Logger.debug 'IronWorkerNG', "Bundling file with path='#{@path}' and dest='#{@dest}'"
22
18
 
@@ -11,10 +11,6 @@ module IronWorkerNG
11
11
  @path = path
12
12
  end
13
13
 
14
- def hash_string
15
- Digest::MD5.hexdigest(@path + File.mtime(rebase(@path)).to_i.to_s)
16
- end
17
-
18
14
  def bundle(container)
19
15
  IronCore::Logger.debug 'IronWorkerNG', "Bundling java jar with path='#{@path}'"
20
16
 
@@ -31,10 +31,6 @@ module IronWorkerNG
31
31
  path
32
32
  end
33
33
 
34
- def hash_string
35
- Digest::MD5.hexdigest(@spec.full_name)
36
- end
37
-
38
34
  def bundle(container)
39
35
  if not @code.full_remote_build
40
36
  if @spec.extensions.length == 0 || IronWorkerNG::Feature::Ruby::MergeGem.merge_binary?
@@ -15,10 +15,6 @@ module IronWorkerNG
15
15
  @version = version
16
16
  end
17
17
 
18
- def hash_string
19
- Digest::MD5.hexdigest(@name + @version)
20
- end
21
-
22
18
  def build_command
23
19
  if @code.full_remote_build
24
20
  "gem '#{@name}', '#{@version}'"
@@ -14,10 +14,6 @@ module IronWorkerNG
14
14
  @path = path
15
15
  @groups = groups
16
16
  end
17
-
18
- def hash_string
19
- Digest::MD5.hexdigest(@path + File.mtime(rebase(@path)).to_i.to_s + (File.exists?(rebase(@path) + '.lock') ? File.mtime(rebase(@path) + '.lock').to_i.to_s : '') + @groups.join)
20
- end
21
17
  end
22
18
 
23
19
  module InstanceMethods
@@ -1,5 +1,5 @@
1
1
  module IronWorkerNG
2
- VERSION = '0.11.3'
2
+ VERSION = '0.12.0'
3
3
 
4
4
  def self.version
5
5
  VERSION
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: iron_worker_ng
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.11.3
4
+ version: 0.12.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -45,7 +45,7 @@ dependencies:
45
45
  - !ruby/object:Gem::Version
46
46
  version: 1.0.0
47
47
  - !ruby/object:Gem::Dependency
48
- name: zip
48
+ name: rubyzip
49
49
  requirement: !ruby/object:Gem::Requirement
50
50
  none: false
51
51
  requirements:
@@ -166,6 +166,7 @@ files:
166
166
  - lib/iron_worker_ng/feature/ruby/merge_gem.rb
167
167
  - lib/iron_worker_ng/feature/ruby/merge_gemfile.rb
168
168
  - lib/iron_worker_ng/feature/common/merge_file.rb
169
+ - lib/iron_worker_ng/feature/common/merge_deb.rb
169
170
  - lib/iron_worker_ng/feature/common/merge_dir.rb
170
171
  - lib/iron_worker_ng/feature/common/merge_exec.rb
171
172
  - lib/iron_worker_ng/cli.rb