docker_core 0.0.10 → 0.0.14

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/docker_core.rb +36 -18
  3. metadata +15 -14
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: ad11481b8c2d460b9685c4022b1805220b64bf1db62bbf7faca9a0733d568169
4
- data.tar.gz: aa21c991bfa072b42b378b7f569bbd55f54b7bd98b10b73a8b01a56a765bd8bd
3
+ metadata.gz: 0c701083c9a545230b1e4fac7502e31c418627da7dd0b0b90bd19bc14a9aec98
4
+ data.tar.gz: f3b7b98b2a654d247b21b4015f3388a2b6578708803ad0a88bc92020588ae565
5
5
  SHA512:
6
- metadata.gz: c6b657275d527d98b636106b41f524ecf380743d525089affc0369240c6c93f243e0f9b646efea7195462c030e7f1813153b8a23a9e7551364b77ec5004eaf5e
7
- data.tar.gz: 67897ef4a150344583d759fc9a89d333cf414c65496bd13cffaa2a6be3ccd644ed9fa3f0850cf0bc8b4646ed0643d6633df02bedc51c9e8ebafa4038bef27909
6
+ metadata.gz: fa4c150462533849c1760cfdbb27a780165ee079d652224e83ad84d4a9de081b0eedc148ea9c9799cfa224a4c3d99323ea15fa362b59405794427f41784e55da
7
+ data.tar.gz: 77f9c1ce5f6b1b6b803c6097ee50c866c400beffee23c472f9c3a01fa60f4449eb4388703b5a9c2d5a468744e2e911cac5dcc94822a3555f86300568302aa620
data/lib/docker_core.rb CHANGED
@@ -34,36 +34,37 @@ module DockerCore
34
34
  end
35
35
 
36
36
  # @param [String] command
37
- # @param [Boolean] verbose
38
- # @param [Boolean] throw
39
- def self.run(command, verbose: true, throw: true)
40
- if verbose
41
- self.echo("+ #{command}")
42
- end
43
-
37
+ # @param [Boolean] force
38
+ def self.run(command, force: false)
44
39
  begin
40
+ self.echo("+ #{command}")
45
41
  print(`#{command}`)
46
42
  rescue
47
- if throw
48
- raise $!
49
- end
43
+ raise unless force
50
44
  end
51
45
  end
52
46
 
47
+ # @param [String] command
48
+ # @param [Boolean] force
49
+ def self.suexec(command, force: false)
50
+ command = "su-exec core #{command}"
51
+ self.run(command, force: force)
52
+ end
53
+
53
54
  # @param [Integer] uid
54
55
  # @param [Integer] gid
55
56
  def self.update_user(uid: 500, gid: 500)
56
57
  uid = ENV.fetch('DOCKER_CORE_UID', uid)
57
58
  gid = ENV.fetch('DOCKER_CORE_GID', gid)
58
- self.run('deluser core', throw: false)
59
- self.run('delgroup core', throw: false)
59
+ self.run('deluser core', force: true)
60
+ self.run('delgroup core', force: true)
60
61
  self.run("addgroup --system --gid=#{gid} core")
61
62
  self.run("adduser --system --disabled-password --no-create-home --ingroup=core --gecos=core --shell=/bin/bash --uid=#{uid} core")
62
63
  end
63
64
 
64
65
  # @param [Array<String>] arguments
65
66
  def self.path(*arguments)
66
- return Dir[*arguments].map { |item| File.path(item) }.uniq
67
+ return Dir.glob(arguments.flatten, File::FNM_DOTMATCH).map { |item| File.path(item) }.uniq
67
68
  end
68
69
 
69
70
  # @param [Array<String>] arguments
@@ -74,14 +75,31 @@ module DockerCore
74
75
  end
75
76
 
76
77
  # @param [Array<String>] arguments
77
- def self.mkdir(*arguments, mode: nil)
78
+ def self.chmod(mode, *arguments)
78
79
  self.path(*arguments).each do |path|
80
+ FileUtils.chmod_R(mode, path, force: true)
81
+ end
82
+ end
83
+
84
+ # @param [Array<String>] arguments
85
+ def self.mkdir(*arguments, mode: nil)
86
+ stack = []
87
+ paths = arguments.map { |path| File.path(path) }.uniq
88
+
89
+ paths.each do |path|
90
+ until path == stack.last
91
+ stack << path
92
+ path = File.dirname(path)
93
+ end
94
+ end
95
+
96
+ stack.uniq.each do |path|
79
97
  if File.exist?(path) && false == File.directory?(path)
80
98
  File.delete(path)
81
99
  end
82
-
83
- FileUtils.mkdir_p(path, mode: mode)
84
100
  end
101
+
102
+ FileUtils.mkdir_p(paths, mode: mode)
85
103
  end
86
104
 
87
105
  # @param [Array<String>] arguments
@@ -175,7 +193,7 @@ module DockerCore
175
193
  if entry.file?
176
194
  self.mkdir(File.dirname(file))
177
195
  File.binwrite(file, entry.read)
178
- FileUtils.chmod(mode, file)
196
+ self.chmod(mode, file)
179
197
  next
180
198
  end
181
199
  end
@@ -201,7 +219,7 @@ module DockerCore
201
219
  # @type [Gem::Package::TarWriter] writer
202
220
  Gem::Package::TarWriter.new(io) do |writer|
203
221
  # @type [String] file
204
- Dir[File.join(path, '**/*')].each do |name|
222
+ self.path(File.join(path, '**/*')).each do |name|
205
223
  mode = File.stat(name).mode
206
224
  file = name.slice(offset ..)
207
225
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: docker_core
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.10
4
+ version: 0.0.14
5
5
  platform: ruby
6
6
  authors:
7
7
  - agrozyme
@@ -14,44 +14,44 @@ dependencies:
14
14
  name: fileutils
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - ">="
17
+ - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: '0'
19
+ version: '1'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - ">="
24
+ - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: '0'
26
+ version: '1'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: json
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - ">="
31
+ - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: '0'
33
+ version: '2'
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - ">="
38
+ - - "~>"
39
39
  - !ruby/object:Gem::Version
40
- version: '0'
40
+ version: '2'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: zlib
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - ">="
45
+ - - "~>"
46
46
  - !ruby/object:Gem::Version
47
- version: '0'
47
+ version: '1'
48
48
  type: :runtime
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
- - - ">="
52
+ - - "~>"
53
53
  - !ruby/object:Gem::Version
54
- version: '0'
54
+ version: '1'
55
55
  description:
56
56
  email:
57
57
  executables: []
@@ -60,7 +60,8 @@ extra_rdoc_files: []
60
60
  files:
61
61
  - lib/docker_core.rb
62
62
  homepage: https://gitlab.com/agrozyme-package/ruby/docker_core
63
- licenses: []
63
+ licenses:
64
+ - Ruby
64
65
  metadata: {}
65
66
  post_install_message:
66
67
  rdoc_options: []