avm 0.66.0 → 0.67.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b052d242bf8dccbe7db34f395acd096c3700c7553ee5c16f590970653ad6274f
4
- data.tar.gz: 35f3f1cbb0840d82b8450921f2725b1adf10df833f82f9ec82138bb777b52e74
3
+ metadata.gz: 03e18c1b8d8e141cb67d37f8eee123d44aa444003a48c4489176199861dcd326
4
+ data.tar.gz: 04b402c83045cb9749d82f67e5ca4be1cbbca3ff18eaa0560c1dc70fba24df72
5
5
  SHA512:
6
- metadata.gz: 1d3e9166ff3862d74e3d5087509c2fb0efbf5d96072eb6acde907ceb88eb14c4be73b7b4b6e0a36081feeefd893050c5bb18abc99b06e3bf983485c20a9af7ea
7
- data.tar.gz: 0c1245bdf1e60ccee7bd6f270d7962f2e7eac458c802a728d395f0fb72e8e62e79535a9a0a3e5921bd8f7254bfa907ab7fafbc9a54e765d842aefa6973c3baa6
6
+ metadata.gz: 86ba3db9f576a68044b0cdba24b58fca43c6251cbfea221cd6528af798e7e069e3eb8d0b5eac9c1af8d5e58a0cd274cea6e486d0a9326122a8f993417b46accc
7
+ data.tar.gz: f5358b5238bd19bf35d14d2c0252fe0e7b005041ec2fed97cb0ba5a99c56538f2c31e93eed851ee86392fbba70eec62de6c536956901f7056f19fa5c9e225643
@@ -0,0 +1,28 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'eac_ruby_utils/fs/temp'
4
+ require 'eac_ruby_utils/core_ext'
5
+
6
+ module Avm
7
+ module Data
8
+ class Package
9
+ module BuildDirectory
10
+ private
11
+
12
+ attr_writer :build_directory
13
+
14
+ # @return [EacRubyUtils::Fs::Temp::Directory]
15
+ def build_directory
16
+ @build_directory || raise('@build_directory is blank')
17
+ end
18
+
19
+ def on_build_directory
20
+ ::EacRubyUtils::Fs::Temp.on_directory do |directory|
21
+ self.build_directory = directory
22
+ yield
23
+ end
24
+ end
25
+ end
26
+ end
27
+ end
28
+ end
@@ -1,5 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require 'avm/data/package/build_directory'
3
4
  require 'avm/data/rotate'
4
5
  require 'eac_ruby_utils/core_ext'
5
6
  require 'minitar'
@@ -10,6 +11,7 @@ module Avm
10
11
  class Dump
11
12
  enable_speaker
12
13
  enable_listable
14
+ include ::Avm::Data::Package::BuildDirectory
13
15
 
14
16
  DEFAULT_EXPIRE_TIME = 1.day
15
17
  DEFAULT_FILE_EXTENSION = '.tar'
@@ -45,8 +47,10 @@ module Avm
45
47
  def run
46
48
  raise "Cannot run: #{cannot_run_reason}" unless runnable?
47
49
 
48
- build_dir = dump_units_to_build_directory
49
- package_file = create_package_file(build_dir)
50
+ package_file = on_build_directory do
51
+ dump_units_to_build_directory
52
+ create_package_file
53
+ end
50
54
  rotate
51
55
  move_download_to_final_dest(package_file)
52
56
  end
@@ -100,15 +104,13 @@ module Avm
100
104
  end
101
105
 
102
106
  def dump_units_to_build_directory
103
- dir = ::Dir.mktmpdir
104
- package.dump_units_to_directory(dir)
105
- dir
107
+ package.dump_units_to_directory(build_directory)
106
108
  end
107
109
 
108
- def create_package_file(build_dir)
110
+ def create_package_file
109
111
  package_path = new_build_path
110
- infom "Creating package \"#{package_path}\" from \"#{build_dir}\"..."
111
- Dir.chdir(build_dir) do
112
+ infom "Creating package \"#{package_path}\" from \"#{build_directory}\"..."
113
+ ::Dir.chdir(build_directory.to_path) do
112
114
  ::Minitar.pack('.', File.open(::File.expand_path(package_path), 'wb'))
113
115
  end
114
116
  package_path
@@ -1,5 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require 'avm/data/package/build_directory'
3
4
  require 'eac_ruby_utils/core_ext'
4
5
  require 'minitar'
5
6
 
@@ -8,13 +9,9 @@ module Avm
8
9
  class Package
9
10
  class Load
10
11
  enable_speaker
12
+ include ::Avm::Data::Package::BuildDirectory
11
13
 
12
- attr_reader :package, :data_file_path
13
-
14
- def initialize(package, data_file_path)
15
- @package = package
16
- @data_file_path = data_file_path
17
- end
14
+ common_constructor :package, :data_file_path
18
15
 
19
16
  def runnable?
20
17
  cannot_run_reason.blank?
@@ -29,8 +26,10 @@ module Avm
29
26
  def run
30
27
  raise "Cannot run: #{cannot_run_reason}" unless runnable?
31
28
 
32
- build_dir = extract_packages_to_build_directory
33
- package.load_units_from_directory(build_dir)
29
+ on_build_directory do
30
+ extract_packages_to_build_directory
31
+ package.load_units_from_directory(build_directory)
32
+ end
34
33
  end
35
34
 
36
35
  def data_file_exist?
@@ -38,9 +37,7 @@ module Avm
38
37
  end
39
38
 
40
39
  def extract_packages_to_build_directory
41
- dir = ::Dir.mktmpdir
42
- ::Minitar.unpack(data_file_path, dir)
43
- dir
40
+ ::Minitar.unpack(data_file_path, build_directory.to_path)
44
41
  end
45
42
  end
46
43
  end
@@ -18,8 +18,11 @@ module Avm
18
18
  end
19
19
  end
20
20
 
21
+ # @return [Avm::Data::Package] Return +self+.
21
22
  def add_unit(identifier, unit)
22
23
  units[identifier.to_sym] = unit
24
+
25
+ self
23
26
  end
24
27
 
25
28
  def dump(data_path, options = {})
data/lib/avm/data/unit.rb CHANGED
@@ -46,6 +46,11 @@ module Avm
46
46
  end
47
47
  end
48
48
 
49
+ # @return [Struct(:key, :subpath), nil]
50
+ def installation_files_data
51
+ nil
52
+ end
53
+
49
54
  def load(data_path)
50
55
  run_callbacks :load do
51
56
  infom "Loading unit \"#{name}\" from \"#{data_path}\"..."
@@ -39,10 +39,17 @@ module Avm
39
39
  instance_command('find', files_path, '-mindepth', 1, '-delete').execute!
40
40
  end
41
41
 
42
+ # @return [Struct(:key, :subpath), nil]
43
+ def installation_files_data
44
+ return nil unless fs_path_subpath.relative?
45
+
46
+ ::Struct.new(:key, :subpath).new(fs_path_subpath.basename.to_path, fs_path_subpath)
47
+ end
48
+
42
49
  # @return [EacRubyUtils::Envs::Command]
43
50
  def instance_command(*args)
44
51
  args = ['sudo', '-Hu', sudo_user] + args if sudo_user.present?
45
- instance.host_env.command(*args)
52
+ instance.host_env.command(*args).chdir('/')
46
53
  end
47
54
 
48
55
  # @return [String, nil]
@@ -34,7 +34,12 @@ module Avm
34
34
  def check_with_rescue
35
35
  internal_check
36
36
  rescue ::Avm::Launcher::Errors::Base => e
37
- ::Avm::Launcher::Publish::CheckResult.blocked("Error: #{e}")
37
+ ::Avm::Launcher::Publish::CheckResult.blocked("Error: #{error_message(e)}")
38
+ end
39
+
40
+ # @return [String]
41
+ def error_message(error)
42
+ error.to_s + error.cause.if_present('') { |v| " / Caused by: #{error_message(v)}" }
38
43
  end
39
44
  end
40
45
  end
data/lib/avm/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Avm
4
- VERSION = '0.66.0'
4
+ VERSION = '0.67.0'
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: avm
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.66.0
4
+ version: 0.67.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Eduardo H. Bogoni
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-04-01 00:00:00.000000000 Z
11
+ date: 2023-04-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: aranha-parsers
@@ -17,6 +17,9 @@ dependencies:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
19
  version: '0.17'
20
+ - - ">="
21
+ - !ruby/object:Gem::Version
22
+ version: 0.17.1
20
23
  type: :runtime
21
24
  prerelease: false
22
25
  version_requirements: !ruby/object:Gem::Requirement
@@ -24,6 +27,9 @@ dependencies:
24
27
  - - "~>"
25
28
  - !ruby/object:Gem::Version
26
29
  version: '0.17'
30
+ - - ">="
31
+ - !ruby/object:Gem::Version
32
+ version: 0.17.1
27
33
  - !ruby/object:Gem::Dependency
28
34
  name: eac_cli
29
35
  requirement: !ruby/object:Gem::Requirement
@@ -245,6 +251,7 @@ files:
245
251
  - lib/avm/applications/base/stereotype.rb
246
252
  - lib/avm/data/callbacks.rb
247
253
  - lib/avm/data/package.rb
254
+ - lib/avm/data/package/build_directory.rb
248
255
  - lib/avm/data/package/dump.rb
249
256
  - lib/avm/data/package/load.rb
250
257
  - lib/avm/data/rotate.rb