-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrbenv.rb
94 lines (80 loc) · 1.96 KB
/
rbenv.rb
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
dep 'rbenv', :username do
@home_dirs = []
Dir.glob('/home/*').sort.each do |dir|
homename = dir.split('/').last
next if homename == 'admin'
@home_dirs << homename
end
username.ask('Which user?').default(@home_dirs.first)
# ruby env
requires 'ruby_deps'
requires 'rbenv-stack'.with(username)
# postgres dev
requires 'libpq-dev.lib'
end
#
# Low level deps
#
dep 'rbenv-stack', :username do
def path
if username.nil?
'/usr/local/rbenv'
else
"/home/#{username}/.rbenv"
end
end
requires 'rbenv-core'.with(username, path)
requires 'rbenv-ruby-build'.with(username, path)
end
dep 'rbenv-core', :username, :path do
met? { path.p.exists? }
meet { git 'https://github.com/rbenv/rbenv.git', to: path }
after { shell "chown #{username}:#{username} -R #{path}", as: 'root' }
end
dep 'rbenv-ruby-build', :username, :path do
met? { "#{path}/plugins/ruby-build".p.exists? }
meet { git 'https://github.com/rbenv/ruby-build.git', to: "#{path}/plugins/ruby-build" }
after { shell "chown #{username}:#{username} -R #{path}", as: 'root' }
end
dep 'ruby', :version do
requires 'rbenv'
met? {
# check for right system ruby in rbenv
if login_shell "rbenv versions | grep '#{version}' 1>/dev/null 2>&1"
log_ok "ruby version=#{version}"
end
}
meet {
# install system ruby in rbenv
login_shell "rbenv install #{version}"
log "ruby version=#{version}"
}
after {
login_shell 'rbenv rehash'
login_shell "rbenv global #{version}"
}
end
dep 'ruby_deps' do
def list
%w(
autoconf
bison
build-essential
libssl-dev
libyaml-dev
libreadline-dev
zlib1g-dev
libncurses5-dev
libffi-dev
)
end
met? do
shell?("dpkg --status #{list.join(' ')}", as: 'root')
end
meet do
shell "apt-get --yes install #{list.join(' ')}", sudo: true
end
# after do
# shell "Autoremoving packages", "apt-get -y autoremove", sudo: true
# end
end