avm 0.66.1 → 0.67.1

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: 1dd452a1cb233171f982fb3da213367417fd59f801dd1313f069f3bfc7ad6037
4
- data.tar.gz: b6e05b77f939fa23af9cdf2c999b1e82f3f0dc18323393e62a38410cd012c363
3
+ metadata.gz: 8e7bc57218b65d92924d3ebeae7143c6f1af0019c58878cbbbbb2a1ba14be21e
4
+ data.tar.gz: 9aa5752d38960f1cc3bd334c1b83274ab870c057d6c2b7eec13a887f1150039f
5
5
  SHA512:
6
- metadata.gz: 6eebe945bf1be89d66779f9db42474cdefc734ca13d994301ba7f11df97b0087941c1c7c967e0973d32d99df8b70c4ecfcdb95296dac76a865398430ca4da409
7
- data.tar.gz: 5d347b0d68044bec6cee52df488fbe0ed4d3f760a1eaee225d1de4be7529e8b51dde5141e46bc530cfef31cdff372ee25b7ae064fc958113ecf94634e2c47412
6
+ metadata.gz: 8eb8c082f19ea0b5d4efb00a827d75ef72a7b94b016f86eaf9eee4682609a439b8dfa91fba0ef104969658efe856caff263bc93a1120983de6678b45a28462d4
7
+ data.tar.gz: 06bc74d885fb1e32e752566750ff621e67fa51f17124fb8719c28d34ca70710a57424e7b2a3060c23d22a4d13c3262b2b1550616f383c970fdab5436df95d7e2
@@ -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]
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.1'
4
+ VERSION = '0.67.1'
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.1
4
+ version: 0.67.1
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-05 00:00:00.000000000 Z
11
+ date: 2023-04-30 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
@@ -126,20 +132,14 @@ dependencies:
126
132
  requirements:
127
133
  - - "~>"
128
134
  - !ruby/object:Gem::Version
129
- version: '0.3'
130
- - - ">="
131
- - !ruby/object:Gem::Version
132
- version: 0.3.2
135
+ version: '0.4'
133
136
  type: :runtime
134
137
  prerelease: false
135
138
  version_requirements: !ruby/object:Gem::Requirement
136
139
  requirements:
137
140
  - - "~>"
138
141
  - !ruby/object:Gem::Version
139
- version: '0.3'
140
- - - ">="
141
- - !ruby/object:Gem::Version
142
- version: 0.3.2
142
+ version: '0.4'
143
143
  - !ruby/object:Gem::Dependency
144
144
  name: filesize
145
145
  requirement: !ruby/object:Gem::Requirement
@@ -245,6 +245,7 @@ files:
245
245
  - lib/avm/applications/base/stereotype.rb
246
246
  - lib/avm/data/callbacks.rb
247
247
  - lib/avm/data/package.rb
248
+ - lib/avm/data/package/build_directory.rb
248
249
  - lib/avm/data/package/dump.rb
249
250
  - lib/avm/data/package/load.rb
250
251
  - lib/avm/data/rotate.rb