dock0 0.2.2 → 0.2.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +19 -13
- data/bin/dock0 +10 -0
- data/lib/dock0.rb +1 -0
- data/lib/dock0/install.rb +87 -0
- data/lib/dock0/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 93d7456a2290387ed74a1b3d5dacfd934faf86b2
|
4
|
+
data.tar.gz: f0752fe961880c4cc65eef15125f89627d0356b8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0aae22f19127ceaa4eefad8b4eb50f5e58e9e0a793c1260702e5cda3a14728ad2080db9da300a911123fec1bdb79556973eecd63f8751d8b62683fd505630c64
|
7
|
+
data.tar.gz: 2e5d2ea2a39355e3516c28f85d9ea45c860ff46937f9f3bed59db305498055db92ec8c0f7ee854e3cbfe8bd51d4bad1c288b667e68139788ed6b543963ff2df5
|
data/README.md
CHANGED
@@ -8,27 +8,33 @@ dock0
|
|
8
8
|
[](https://travis-ci.org/dock0/dock0)
|
9
9
|
[](https://tldrlegal.com/license/mit-license)
|
10
10
|
|
11
|
-
|
11
|
+
Component generator for building Arch systems
|
12
12
|
|
13
13
|
## Usage
|
14
14
|
|
15
|
-
|
15
|
+
### Build a rootfs
|
16
16
|
|
17
|
-
|
17
|
+
```
|
18
|
+
dock0 image config.yaml
|
19
|
+
```
|
18
20
|
|
19
|
-
|
21
|
+
This will build a compressed rootfs from your configuration. Here is [an example configuration](https://github.com/dock0/vm_root)
|
20
22
|
|
21
|
-
|
23
|
+
### Build a config bundle
|
22
24
|
|
23
|
-
|
25
|
+
```
|
26
|
+
dock0 config config.yaml
|
27
|
+
```
|
24
28
|
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
29
|
+
This builds a config tarball designed to be used to customize a rootfs. Here is [an example configuration](https://github.com/dock0/vm_config)
|
30
|
+
|
31
|
+
### Build a system deployment
|
32
|
+
|
33
|
+
```
|
34
|
+
dock0 install config.yaml
|
35
|
+
```
|
36
|
+
|
37
|
+
This downloads created artifacts and runs build scripts to combine precreated and dynamic components into a full system. Here is [an example configuration](https://github.com/dock0/vm_install)
|
32
38
|
|
33
39
|
## Installation
|
34
40
|
|
data/bin/dock0
CHANGED
@@ -28,6 +28,16 @@ Mercenary.program(:dock0) do |p|
|
|
28
28
|
end
|
29
29
|
end
|
30
30
|
|
31
|
+
p.command(:install) do |c|
|
32
|
+
c.syntax 'install CONFIG1 [... CONFIGN]'
|
33
|
+
c.description 'Build/update a install'
|
34
|
+
|
35
|
+
c.action do |args, _|
|
36
|
+
Dock0.easy_mode :Install, args
|
37
|
+
puts 'All done!'
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
31
41
|
p.action do
|
32
42
|
puts p
|
33
43
|
exit 1
|
data/lib/dock0.rb
CHANGED
@@ -0,0 +1,87 @@
|
|
1
|
+
require 'fileutils'
|
2
|
+
require 'open-uri'
|
3
|
+
|
4
|
+
module Dock0
|
5
|
+
##
|
6
|
+
# An Install is a deployment of components onto a system
|
7
|
+
class Install < Base
|
8
|
+
def default_config
|
9
|
+
{
|
10
|
+
'paths' => {
|
11
|
+
'templates' => './templates',
|
12
|
+
'scripts' => './scripts',
|
13
|
+
'build' => './build'
|
14
|
+
},
|
15
|
+
'artifacts' => []
|
16
|
+
}
|
17
|
+
end
|
18
|
+
|
19
|
+
def build_url(artifact)
|
20
|
+
org = @config[:org]
|
21
|
+
name, version, file = artifact.fetch('name', 'version', 'file')
|
22
|
+
"https://github.com/#{org}/#{name}/releases/download/#{version}/#{file}"
|
23
|
+
end
|
24
|
+
|
25
|
+
def build_path(artifact)
|
26
|
+
"#{artifact['name']}/#{artifact['file']}"
|
27
|
+
end
|
28
|
+
|
29
|
+
def download(artifact)
|
30
|
+
url, path = artifact.values_at('url', 'full_path')
|
31
|
+
puts "Downloading #{url} to #{path}"
|
32
|
+
File.open(path, 'wb') do |fh|
|
33
|
+
open(url, 'rb') { |request| fh.write request.read }
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
def chmod(artifact)
|
38
|
+
File.chmod(artifact['mode'], full_path) if artifact['mode']
|
39
|
+
end
|
40
|
+
|
41
|
+
def link(artifact)
|
42
|
+
FileUtils.ln_sf artifact['link'], artifact['path']
|
43
|
+
end
|
44
|
+
|
45
|
+
def load_artifacts
|
46
|
+
@config['artifacts'].each do |artifact|
|
47
|
+
artifact['url'] ||= build_url(artifact)
|
48
|
+
artifact['path'] ||= build_path(artifact)
|
49
|
+
artifact['full_path'] = "#{@config['build']}/#{artifact['path']}"
|
50
|
+
download artifact
|
51
|
+
chmod artifact
|
52
|
+
link(artifact) if artifact['link']
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
def templates
|
57
|
+
Dir.chdir(@paths['templates']) do
|
58
|
+
Dir.glob('**/*').select { |x| File.file? x }
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
def render_templates
|
63
|
+
templates.each do |path|
|
64
|
+
puts "Templating #{path}"
|
65
|
+
template = File.read "#{@paths['templates']}/#{path}"
|
66
|
+
parsed = ERB.new(template, nil, '<>').result(binding)
|
67
|
+
|
68
|
+
target_path = "#{@paths['build']}/#{path}"
|
69
|
+
FileUtils.mkdir_p File.dirname(target_path)
|
70
|
+
File.open(target_path, 'w') { |fh| fh.write parsed }
|
71
|
+
end
|
72
|
+
end
|
73
|
+
|
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
|
+
def easy_mode
|
81
|
+
load_artifacts
|
82
|
+
render_templates
|
83
|
+
run_scripts
|
84
|
+
finalize
|
85
|
+
end
|
86
|
+
end
|
87
|
+
end
|
data/lib/dock0/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: dock0
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Les Aker
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-12-
|
11
|
+
date: 2014-12-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: mercenary
|
@@ -114,6 +114,7 @@ files:
|
|
114
114
|
- lib/dock0.rb
|
115
115
|
- lib/dock0/config.rb
|
116
116
|
- lib/dock0/image.rb
|
117
|
+
- lib/dock0/install.rb
|
117
118
|
- lib/dock0/version.rb
|
118
119
|
- spec/dock0_spec.rb
|
119
120
|
- spec/examples/alpha.yml
|