dock0 0.2.3 → 0.2.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/dock0/image.rb +2 -2
- data/lib/dock0/install.rb +27 -15
- data/lib/dock0/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 65012095e39136647f62864f6bd21447cd15dd10
|
4
|
+
data.tar.gz: cd192de12e6ac2e612d3b372c6748e0b710b7e9e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fc78d710c6f27a6528016143d78ba8858a850ff213b0551210b371f82457a5d4b390fce015b719ad8b30ce41051514f38d811f6b38cb414258ebf04a6ff879c4
|
7
|
+
data.tar.gz: 0853929148b265d2f290759437b3184a3c4f8c8b44cba56e64ccd6d2eee7ee03aad97d9f13836068caa34e3a00b2b737d4c8842934c3c34d7527e081a636f61d
|
data/lib/dock0/image.rb
CHANGED
@@ -7,8 +7,8 @@ module Dock0
|
|
7
7
|
def default_config # rubocop:disable Metrics/MethodLength
|
8
8
|
{
|
9
9
|
'paths' => {
|
10
|
-
'build_file' => './
|
11
|
-
'build' => './
|
10
|
+
'build_file' => './root.fs',
|
11
|
+
'build' => './build',
|
12
12
|
'package_list' => './packages',
|
13
13
|
'overlay' => './overlay',
|
14
14
|
'scripts' => './scripts',
|
data/lib/dock0/install.rb
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
require 'fileutils'
|
2
2
|
require 'open-uri'
|
3
|
+
require 'pathname'
|
3
4
|
|
4
5
|
module Dock0
|
5
6
|
##
|
@@ -10,45 +11,63 @@ module Dock0
|
|
10
11
|
'paths' => {
|
11
12
|
'templates' => './templates',
|
12
13
|
'scripts' => './scripts',
|
13
|
-
'build' => './build'
|
14
|
+
'build' => './build',
|
15
|
+
'base' => '/'
|
14
16
|
},
|
17
|
+
'org' => 'dock0',
|
15
18
|
'artifacts' => []
|
16
19
|
}
|
17
20
|
end
|
18
21
|
|
19
22
|
def build_url(artifact)
|
20
|
-
org = @config[
|
21
|
-
name, version, file = artifact.
|
23
|
+
org = @config['org']
|
24
|
+
name, version, file = artifact.values_at('name', 'version', 'file')
|
22
25
|
"https://github.com/#{org}/#{name}/releases/download/#{version}/#{file}"
|
23
26
|
end
|
24
27
|
|
25
28
|
def build_path(artifact)
|
26
|
-
"#{artifact['name']}/#{artifact['file']}"
|
29
|
+
"#{artifact['name']}/#{artifact['version']}/#{artifact['file']}"
|
30
|
+
end
|
31
|
+
|
32
|
+
def qualify_path(path)
|
33
|
+
"#{@paths['build']}/#{@paths['base']}/#{path}"
|
34
|
+
end
|
35
|
+
|
36
|
+
def missing(path, artifact)
|
37
|
+
return true unless File.exist? path
|
38
|
+
puts "#{artifact['name']} (#{artifact['version']}) already loaded"
|
27
39
|
end
|
28
40
|
|
29
41
|
def download(artifact)
|
30
42
|
url, path = artifact.values_at('url', 'full_path')
|
43
|
+
return unless missing(path, artifact)
|
31
44
|
puts "Downloading #{url} to #{path}"
|
45
|
+
FileUtils.mkdir_p File.dirname(path)
|
32
46
|
File.open(path, 'wb') do |fh|
|
33
47
|
open(url, 'rb') { |request| fh.write request.read }
|
34
48
|
end
|
35
49
|
end
|
36
50
|
|
37
51
|
def chmod(artifact)
|
38
|
-
File.chmod(artifact['mode'], full_path)
|
52
|
+
File.chmod(artifact['mode'], full_path)
|
39
53
|
end
|
40
54
|
|
41
55
|
def link(artifact)
|
42
|
-
|
56
|
+
full_link_path = qualify_path artifact['link']
|
57
|
+
FileUtils.mkdir_p File.dirname(full_link_path)
|
58
|
+
relative_path = Pathname(artifact['path']).relative_path_from(
|
59
|
+
Pathname(File.dirname(full_link_path))
|
60
|
+
)
|
61
|
+
FileUtils.ln_sf relative_path, full_link_path
|
43
62
|
end
|
44
63
|
|
45
64
|
def load_artifacts
|
46
65
|
@config['artifacts'].each do |artifact|
|
47
66
|
artifact['url'] ||= build_url(artifact)
|
48
67
|
artifact['path'] ||= build_path(artifact)
|
49
|
-
artifact['full_path'] =
|
68
|
+
artifact['full_path'] = qualify_path artifact['path']
|
50
69
|
download artifact
|
51
|
-
chmod artifact
|
70
|
+
chmod artifact if artifact['mode']
|
52
71
|
link(artifact) if artifact['link']
|
53
72
|
end
|
54
73
|
end
|
@@ -71,17 +90,10 @@ module Dock0
|
|
71
90
|
end
|
72
91
|
end
|
73
92
|
|
74
|
-
def finalize
|
75
|
-
puts "Packing config into #{@paths['output']}"
|
76
|
-
tar = Dir.chdir(File.dirname(@paths['build'])) { run 'tar cz .' }
|
77
|
-
File.open(@paths['output'], 'w') { |fh| fh << tar }
|
78
|
-
end
|
79
|
-
|
80
93
|
def easy_mode
|
81
94
|
load_artifacts
|
82
95
|
render_templates
|
83
96
|
run_scripts
|
84
|
-
finalize
|
85
97
|
end
|
86
98
|
end
|
87
99
|
end
|
data/lib/dock0/version.rb
CHANGED