-
Notifications
You must be signed in to change notification settings - Fork 109
Expand file tree
/
Copy pathdependencies.erb
More file actions
124 lines (110 loc) · 3.42 KB
/
Copy pathdependencies.erb
File metadata and controls
124 lines (110 loc) · 3.42 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
<%=
def install_dependencies
script = ''
script += <<-INSTALL
test ! -e "$(dirname $0)/formula-fetch.sh" || . "$(dirname $0)/formula-fetch.sh"
test ! -e "$(dirname $0)/repository-setup.sh" || . "$(dirname $0)/repository-setup.sh"
export SALT_ROOT="#{config[:root_path]}/#{config[:salt_file_root]}";
export SALT_SHARE_DIR='/usr/share/salt-formulas'
export DEBIAN_FRONTEND=noninteractive
mkdir -p "${SALT_ROOT}";
mkdir -p "${SALT_SHARE_DIR}";
INSTALL
# setup apt
config[:vendor_repo].select{|x| x[:type]=='apt'}.each do |repo|
id =repo[:url].gsub(/[htp:\/.]/,'')
arch=repo[:arch] || '[arch=amd64]'
rurl=repo[:url]
comp=repo[:components] || 'main'
dist=repo[:distribution] || '$DISTRIB_CODENAME'
rkey=repo[:key_url]
script += <<-INSTALL
apt_repo_add "#{id}" "#{arch}" "#{rurl}" "#{comp}" "#{dist}" "#{rkey}";
INSTALL
end
# setup ppa
config[:vendor_repo].select{|x| x[:type]=='ppa'}.each do |repo|
script += <<-INSTALL
add-apt-repository "ppa:#{repo[:name]}" -y;
INSTALL
end
# TODO, setup yum repo
# update resources
config[:vendor_repo].map{|x| x[:type]}.uniq.each do |type|
case type
when 'apt'
script += <<-INSTALL
apt-get update -q;
sleep 10;
INSTALL
when 'yum'
script += <<-INSTALL
yum update;
sleep 10;
INSTALL
when 'spm'
script += <<-INSTALL
spm update_repo;
INSTALL
end
end
# install formulas
config[:dependencies].each do |formula|
if formula.key?(:repo)
case formula[:repo]
when 'git'
if formula[:source].start_with?("http")
script += <<-INSTALL
fetchGitFormula #{formula[:source]} "#{formula[:name]}" "#{formula[:branch] || 'master'}"
INSTALL
else
if formula[:ssh_key].nil? and config[:ssh_key].nil?
raise "No ssh_key specified for #{formula[:source]}"
end
if formula[:ssh_key].nil?
ssh_key = config[:root_path] + config[:ssh_home] + "/" + File.basename(config[:ssh_key])
else
ssh_key = config[:root_path] + config[:ssh_home] + "/" + File.basename(formula[:ssh_key])
end
script += <<-INSTALL
fetchGitFormula #{formula[:source]} "#{formula[:name]}" "#{formula[:branch] || 'master'}" "#{ssh_key}"
INSTALL
end
when 'spm'
if formula[:package].nil?
script += <<-INSTALL
spm -c #{config[:root_path]}/etc/salt install -y #{formula[:name]};
INSTALL
else
script += <<-INSTALL
curl -O #{formula[:package]};
spm -c #{config[:root_path]}/etc/salt local install -y "$(basename #{formula[:package]})";
INSTALL
end
when 'yum'
script += <<-INSTALL
yum install -y #{formula[:package]||formula[:name]};
INSTALL
when 'apt'
script += <<-INSTALL
apt-get install -y #{formula[:package]||formula[:name]};
INSTALL
end
elsif formula.key?(:path)
prepare_formula formula[:path], formula[:name]
end
end
script += <<-INSTALL
linkFormulas "$SALT_ROOT"
chown -R "${SUDO_USER:-$USER}" "${SALT_SHARE_DIR}" "${SALT_ROOT}";
echo "Content of $SALT_ROOT :";
ls -la "$SALT_ROOT";
INSTALL
return script
end
<<-INSTALL
#!/usr/bin/env bash
echo "Install External Dependencies";
#{install_dependencies}
INSTALL
%>