cupper 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +1 -0
- data/lib/cupper/cookbook.rb +2 -28
- data/lib/cupper/recipe.rb +41 -35
- data/lib/cupper/templates/_cookbook_file.erb +1 -1
- data/lib/cupper/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: c5222cb608fedc123c84ca945f2885f4e5609f9f
|
4
|
+
data.tar.gz: 0ee85f347f7e47b8b149ae7db5ba0a8e0e3405c9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0631c79f3a2fd563f65f10b7f5eef51fd90a25b885e5044547e767a5e617c2915e84203f2eb53e48ec1c3be35074d5c29cb3de303c9c1d7f857f0fe05a4ac6b6
|
7
|
+
data.tar.gz: 7d54800377105f0d8112195e279192a8b5d5aa6d1ce585922136e1d2e0ec04fe40ab3ca0d0e189705c138e935bb72816db5c090b282f90d6ca6be7a2f0de9689
|
data/.gitignore
CHANGED
data/lib/cupper/cookbook.rb
CHANGED
@@ -10,12 +10,12 @@ module Cupper
|
|
10
10
|
@cookbook_files_path = "#{@cookbook_path}/files"
|
11
11
|
@cookbook_recipes_path = "#{@cookbook_path}/recipes"
|
12
12
|
@recipe_deps = [ # TODO this is hard code to reflect all_recipes. Refactor this later
|
13
|
-
"#{cookbookname}::
|
13
|
+
"#{cookbookname}::packages",
|
14
|
+
"#{cookbookname}::cookbook_files",
|
14
15
|
"#{cookbookname}::links",
|
15
16
|
"#{cookbookname}::groups",
|
16
17
|
"#{cookbookname}::services",
|
17
18
|
"#{cookbookname}::users",
|
18
|
-
"#{cookbookname}::packages",
|
19
19
|
]
|
20
20
|
setup_paths
|
21
21
|
end
|
@@ -30,7 +30,6 @@ module Cupper
|
|
30
30
|
collector = Collect.new
|
31
31
|
collector.setup
|
32
32
|
all_recipes(collector)
|
33
|
-
all_cookbook_files(collector)
|
34
33
|
end
|
35
34
|
|
36
35
|
def all_recipes(collector)
|
@@ -42,30 +41,5 @@ module Cupper
|
|
42
41
|
Recipe.new(@cookbook_recipes_path, collector, '_users', 'users').create
|
43
42
|
Recipe.new(@cookbook_recipes_path, collector, '_package', 'packages').create
|
44
43
|
end
|
45
|
-
|
46
|
-
def all_cookbook_files(collector)
|
47
|
-
expand_cookbook_files(collector.extract 'files')
|
48
|
-
end
|
49
|
-
|
50
|
-
def text_type?(file)
|
51
|
-
file[1]['type'].match('text') or file[1]['type'].match('ASCII')
|
52
|
-
end
|
53
|
-
|
54
|
-
def expand_cookbook_files(files)
|
55
|
-
files.each do |attr|
|
56
|
-
if text_type?(attr) and !(attr[1]['related'].nil?)
|
57
|
-
source = attr[0].split('/').last
|
58
|
-
content = attr[1]['content']
|
59
|
-
CookbookFile.new(@cookbook_files_path, source, content, 'cookbook_file').create
|
60
|
-
end
|
61
|
-
# TODO: This is a work around to source list file
|
62
|
-
# should be replaced for a better logic
|
63
|
-
if text_type?(attr) and attr[0].include? "/etc/apt/sources.list"
|
64
|
-
source = attr[0].split('/').last
|
65
|
-
content = attr[1]['content']
|
66
|
-
CookbookFile.new(@cookbook_files_path, source, content, 'cookbook_file').create
|
67
|
-
end
|
68
|
-
end
|
69
|
-
end
|
70
44
|
end
|
71
45
|
end
|
data/lib/cupper/recipe.rb
CHANGED
@@ -14,47 +14,22 @@ module Cupper
|
|
14
14
|
@links = Array.new
|
15
15
|
@directories = Array.new
|
16
16
|
@files = Array.new
|
17
|
+
@files_path = "#{dest_path.chomp("recipes")}/files"
|
17
18
|
@collector = collector
|
18
19
|
super(recipe_name, dest_path, erb_file, nil, '.rb')
|
19
20
|
end
|
20
21
|
|
21
22
|
def create
|
22
|
-
@sources_list
|
23
|
-
@packages
|
24
|
-
@services
|
25
|
-
@users
|
26
|
-
@groups
|
27
|
-
@links
|
28
|
-
@files
|
23
|
+
@sources_list = expand_sources_list(@collector.extract 'files')
|
24
|
+
@packages = expand_packages(@collector.extract 'packages')
|
25
|
+
@services = expand_services(@collector.extract 'services')
|
26
|
+
@users = expand_users(@collector.extract 'users')
|
27
|
+
@groups = expand_groups(@collector.extract 'groups')
|
28
|
+
@links = expand_links(@collector.extract 'files')
|
29
|
+
@files = expand_files(@collector.extract 'files')
|
29
30
|
super
|
30
31
|
end
|
31
32
|
|
32
|
-
def expand_sources_list(files)
|
33
|
-
att = Array.new
|
34
|
-
files.each do |attr|
|
35
|
-
# TODO: Doesn't works for arch, this should be a plugin responsability
|
36
|
-
if attr[0].include?("/etc/apt/sources.list") and (convert_mode(attr[1]['mode']) != 'Unknown') and text_type?(attr)
|
37
|
-
path = attr[0]
|
38
|
-
group = attr[1]['group']
|
39
|
-
mode = attr[1]['mode']
|
40
|
-
owner = attr[1]['owner']
|
41
|
-
att.push(new_file(group, mode, owner, path))
|
42
|
-
end
|
43
|
-
end
|
44
|
-
att
|
45
|
-
end
|
46
|
-
|
47
|
-
def expand_packages(packages)
|
48
|
-
att = Array.new
|
49
|
-
packages.each do |attr|
|
50
|
-
pkg = attr[0]
|
51
|
-
version = attr[1]['version']
|
52
|
-
|
53
|
-
att.push(new_package(pkg,version))
|
54
|
-
end
|
55
|
-
att
|
56
|
-
end
|
57
|
-
|
58
33
|
def link_type?(file)
|
59
34
|
(file[1]['type'].split.first(2).join(' ').match('symbolic link'))
|
60
35
|
end
|
@@ -82,6 +57,33 @@ module Cupper
|
|
82
57
|
result
|
83
58
|
end
|
84
59
|
|
60
|
+
|
61
|
+
def expand_sources_list(files)
|
62
|
+
att = Array.new
|
63
|
+
files.each do |attr|
|
64
|
+
# TODO: Doesn't works for arch, this should be a plugin responsability
|
65
|
+
if attr[0].include?("/etc/apt/sources.list") and (convert_mode(attr[1]['mode']) != 'Unknown') and text_type?(attr)
|
66
|
+
path = attr[0]
|
67
|
+
group = attr[1]['group']
|
68
|
+
mode = attr[1]['mode']
|
69
|
+
owner = attr[1]['owner']
|
70
|
+
att.push(new_file(group, mode, owner, path))
|
71
|
+
end
|
72
|
+
end
|
73
|
+
att
|
74
|
+
end
|
75
|
+
|
76
|
+
def expand_packages(packages)
|
77
|
+
att = Array.new
|
78
|
+
packages.each do |attr|
|
79
|
+
pkg = attr[0]
|
80
|
+
version = attr[1]['version']
|
81
|
+
|
82
|
+
att.push(new_package(pkg,version))
|
83
|
+
end
|
84
|
+
att
|
85
|
+
end
|
86
|
+
|
85
87
|
def expand_services(services)
|
86
88
|
att = Array.new
|
87
89
|
services.each do |attr|
|
@@ -138,13 +140,17 @@ module Cupper
|
|
138
140
|
def expand_files(files)
|
139
141
|
att = Array.new
|
140
142
|
files.each do |attr|
|
141
|
-
if text_type?(attr) and !(attr[1]['related'].nil?)
|
143
|
+
if text_type?(attr) and (!(attr[1]['related'].nil?) or attr[0].include? "/etc/apt/sources.list")
|
142
144
|
path = attr[0]
|
143
145
|
group = attr[1]['group']
|
144
146
|
mode = attr[1]['mode']
|
145
147
|
owner = attr[1]['owner']
|
146
|
-
|
147
148
|
att.push(new_file(group, mode, owner, path))
|
149
|
+
|
150
|
+
# Related file
|
151
|
+
source = attr[0].split('/').last
|
152
|
+
content = attr[1]['content']
|
153
|
+
CookbookFile.new(@files_path, source, content, 'cookbook_file').create
|
148
154
|
end
|
149
155
|
end
|
150
156
|
att
|
data/lib/cupper/version.rb
CHANGED