rubycut-babushka 0.10.6

Sign up to get free protection for your applications and to get access to all the features.
Files changed (171) hide show
  1. data/Gemfile +8 -0
  2. data/Gemfile.lock +31 -0
  3. data/README.markdown +246 -0
  4. data/Rakefile +26 -0
  5. data/bin/babushka +11 -0
  6. data/deps/babushka.rb +101 -0
  7. data/deps/dev.rb +12 -0
  8. data/deps/fhs.rb +31 -0
  9. data/deps/git.rb +29 -0
  10. data/deps/homebrew.rb +30 -0
  11. data/deps/os_x.rb +33 -0
  12. data/deps/packages.rb +22 -0
  13. data/deps/pkg_managers.rb +110 -0
  14. data/deps/ruby.rb +23 -0
  15. data/deps/rubygems.rb +24 -0
  16. data/deps/system.rb +10 -0
  17. data/deps/templates/app.rb +68 -0
  18. data/deps/templates/external.rb +12 -0
  19. data/deps/templates/installer.rb +31 -0
  20. data/deps/templates/managed.rb +105 -0
  21. data/deps/templates/ppa.rb +24 -0
  22. data/deps/templates/src.rb +42 -0
  23. data/deps/templates/tmbundle.rb +15 -0
  24. data/lib/babushka.rb +28 -0
  25. data/lib/babushka/accepts_block_for.rb +72 -0
  26. data/lib/babushka/accepts_list_for.rb +49 -0
  27. data/lib/babushka/accepts_value_for.rb +24 -0
  28. data/lib/babushka/base.rb +78 -0
  29. data/lib/babushka/bug_reporter.rb +55 -0
  30. data/lib/babushka/cmdline.rb +133 -0
  31. data/lib/babushka/cmdline/handler.rb +41 -0
  32. data/lib/babushka/cmdline/helpers.rb +127 -0
  33. data/lib/babushka/cmdline/parser.rb +69 -0
  34. data/lib/babushka/colorizer.rb +59 -0
  35. data/lib/babushka/core_patches/array.rb +171 -0
  36. data/lib/babushka/core_patches/blank.rb +22 -0
  37. data/lib/babushka/core_patches/bytes.rb +52 -0
  38. data/lib/babushka/core_patches/hash.rb +107 -0
  39. data/lib/babushka/core_patches/hashish.rb +14 -0
  40. data/lib/babushka/core_patches/integer.rb +25 -0
  41. data/lib/babushka/core_patches/io.rb +8 -0
  42. data/lib/babushka/core_patches/numeric.rb +16 -0
  43. data/lib/babushka/core_patches/object.rb +27 -0
  44. data/lib/babushka/core_patches/string.rb +116 -0
  45. data/lib/babushka/core_patches/symbol.rb +12 -0
  46. data/lib/babushka/core_patches/try.rb +15 -0
  47. data/lib/babushka/core_patches/uri.rb +24 -0
  48. data/lib/babushka/dep.rb +470 -0
  49. data/lib/babushka/dep_context.rb +18 -0
  50. data/lib/babushka/dep_definer.rb +115 -0
  51. data/lib/babushka/dep_pool.rb +49 -0
  52. data/lib/babushka/dep_runner.rb +85 -0
  53. data/lib/babushka/dsl.rb +26 -0
  54. data/lib/babushka/git_repo.rb +185 -0
  55. data/lib/babushka/helpers/git_helpers.rb +32 -0
  56. data/lib/babushka/helpers/log_helpers.rb +176 -0
  57. data/lib/babushka/helpers/path_helpers.rb +34 -0
  58. data/lib/babushka/helpers/run_helpers.rb +145 -0
  59. data/lib/babushka/helpers/shell_helpers.rb +229 -0
  60. data/lib/babushka/helpers/suggest_helpers.rb +16 -0
  61. data/lib/babushka/helpers/uri_helpers.rb +36 -0
  62. data/lib/babushka/ip.rb +160 -0
  63. data/lib/babushka/lambda_chooser.rb +40 -0
  64. data/lib/babushka/levenshtein.rb +125 -0
  65. data/lib/babushka/meta_dep.rb +65 -0
  66. data/lib/babushka/meta_dep_context.rb +15 -0
  67. data/lib/babushka/parameter.rb +143 -0
  68. data/lib/babushka/pkg_helper.rb +81 -0
  69. data/lib/babushka/pkg_helpers/apt_helper.rb +61 -0
  70. data/lib/babushka/pkg_helpers/base_helper.rb +19 -0
  71. data/lib/babushka/pkg_helpers/binpkgsrc_helper.rb +48 -0
  72. data/lib/babushka/pkg_helpers/binports_helper.rb +34 -0
  73. data/lib/babushka/pkg_helpers/brew_helper.rb +110 -0
  74. data/lib/babushka/pkg_helpers/gem_helper.rb +120 -0
  75. data/lib/babushka/pkg_helpers/macports_helper.rb +22 -0
  76. data/lib/babushka/pkg_helpers/npm_helper.rb +45 -0
  77. data/lib/babushka/pkg_helpers/pacman_helper.rb +27 -0
  78. data/lib/babushka/pkg_helpers/pip_helper.rb +45 -0
  79. data/lib/babushka/pkg_helpers/src_helper.rb +16 -0
  80. data/lib/babushka/pkg_helpers/yum_helper.rb +25 -0
  81. data/lib/babushka/popen.rb +40 -0
  82. data/lib/babushka/prompt.rb +176 -0
  83. data/lib/babushka/renderable.rb +67 -0
  84. data/lib/babushka/resource.rb +215 -0
  85. data/lib/babushka/run_reporter.rb +60 -0
  86. data/lib/babushka/shell.rb +108 -0
  87. data/lib/babushka/source.rb +216 -0
  88. data/lib/babushka/source_pool.rb +146 -0
  89. data/lib/babushka/system_definitions.rb +97 -0
  90. data/lib/babushka/system_profile.rb +210 -0
  91. data/lib/babushka/task.rb +142 -0
  92. data/lib/babushka/vars.rb +108 -0
  93. data/lib/babushka/version_of.rb +65 -0
  94. data/lib/babushka/version_str.rb +57 -0
  95. data/lib/babushka/xml_string.rb +28 -0
  96. data/lib/components.rb +82 -0
  97. data/lib/fancypath/fancypath.rb +200 -0
  98. data/lib/inkan/inkan.rb +76 -0
  99. data/spec/acceptance/acceptance.rb +43 -0
  100. data/spec/acceptance_helper.rb +113 -0
  101. data/spec/archives/Blah.app.zip +0 -0
  102. data/spec/archives/archive.tar +0 -0
  103. data/spec/archives/archive.tar.bz2 +0 -0
  104. data/spec/archives/archive.tar.gz +0 -0
  105. data/spec/archives/archive.tbz2 +0 -0
  106. data/spec/archives/archive.tgz +0 -0
  107. data/spec/archives/archive.zip +0 -0
  108. data/spec/archives/content.txt +5 -0
  109. data/spec/archives/invalid_archive +5 -0
  110. data/spec/archives/nested archive/content.txt +5 -0
  111. data/spec/archives/nested_archive.tar +0 -0
  112. data/spec/archives/really_a_gzip.zip +0 -0
  113. data/spec/archives/test-0.3.1.tgz +0 -0
  114. data/spec/archives/tgz_archive +0 -0
  115. data/spec/archives/zip_without_extension +0 -0
  116. data/spec/babushka/accepts_for_spec.rb +174 -0
  117. data/spec/babushka/accepts_for_support.rb +72 -0
  118. data/spec/babushka/cmdline/console_spec.rb +11 -0
  119. data/spec/babushka/cmdline/help_spec.rb +61 -0
  120. data/spec/babushka/cmdline/version_spec.rb +10 -0
  121. data/spec/babushka/core_patches_spec.rb +171 -0
  122. data/spec/babushka/dep_context_spec.rb +58 -0
  123. data/spec/babushka/dep_definer_spec.rb +152 -0
  124. data/spec/babushka/dep_definer_support.rb +36 -0
  125. data/spec/babushka/dep_spec.rb +567 -0
  126. data/spec/babushka/dep_support.rb +29 -0
  127. data/spec/babushka/deps_spec.rb +113 -0
  128. data/spec/babushka/gem_helper_spec.rb +90 -0
  129. data/spec/babushka/git_repo_spec.rb +396 -0
  130. data/spec/babushka/ip_spec.rb +131 -0
  131. data/spec/babushka/lambda_chooser_spec.rb +115 -0
  132. data/spec/babushka/meta_dep_definer_spec.rb +127 -0
  133. data/spec/babushka/meta_dep_wrapper_spec.rb +32 -0
  134. data/spec/babushka/parameter_spec.rb +135 -0
  135. data/spec/babushka/path_helpers_spec.rb +102 -0
  136. data/spec/babushka/prompt_spec.rb +188 -0
  137. data/spec/babushka/renderable_spec.rb +100 -0
  138. data/spec/babushka/resource_spec.rb +141 -0
  139. data/spec/babushka/run_helpers_spec.rb +26 -0
  140. data/spec/babushka/shell_helpers_spec.rb +244 -0
  141. data/spec/babushka/shell_spec.rb +19 -0
  142. data/spec/babushka/source_pool_spec.rb +320 -0
  143. data/spec/babushka/source_pool_support.rb +31 -0
  144. data/spec/babushka/source_spec.rb +382 -0
  145. data/spec/babushka/source_support.rb +17 -0
  146. data/spec/babushka/system_profile_spec.rb +61 -0
  147. data/spec/babushka/task_spec.rb +141 -0
  148. data/spec/babushka/uri_spec.rb +13 -0
  149. data/spec/babushka/vars_spec.rb +59 -0
  150. data/spec/babushka/version_of_spec.rb +110 -0
  151. data/spec/babushka/version_str_spec.rb +130 -0
  152. data/spec/babushka/version_str_support.rb +37 -0
  153. data/spec/babushka/xml_string_spec.rb +98 -0
  154. data/spec/deps/bad/broken.rb +7 -0
  155. data/spec/deps/bad/working.rb +3 -0
  156. data/spec/deps/good/meta.rb +14 -0
  157. data/spec/deps/good/test.rb +11 -0
  158. data/spec/deps/outer/deps.rb +19 -0
  159. data/spec/deps/outer/more deps.rb +11 -0
  160. data/spec/deps/params/params.rb +10 -0
  161. data/spec/fancypath/fancypath_spec.rb +272 -0
  162. data/spec/fancypath_support.rb +10 -0
  163. data/spec/inkan/inkan_spec.rb +217 -0
  164. data/spec/renderable/different_example.conf.erb +4 -0
  165. data/spec/renderable/example.conf.erb +3 -0
  166. data/spec/renderable/example.sh +6 -0
  167. data/spec/renderable/with_binding.conf.erb +4 -0
  168. data/spec/renderable/xml_example.conf.erb +8 -0
  169. data/spec/repos/remote.git.tgz +0 -0
  170. data/spec/spec_helper.rb +87 -0
  171. metadata +238 -0
data/deps/git.rb ADDED
@@ -0,0 +1,29 @@
1
+ dep 'git' do
2
+ requires {
3
+ # Use the binary installer on OS X, so installing babushka
4
+ # (which pulls in git) doesn't require a compiler.
5
+ on :osx, 'git.installer'
6
+ otherwise 'git.managed'
7
+ }
8
+ met? { in_path? 'git >= 1.5' }
9
+ end
10
+
11
+ dep 'git.managed' do
12
+ installs {
13
+ via :macports, 'git-core +svn +bash_completion'
14
+ via :apt, 'git-core'
15
+ via :binpkgsrc, 'scmgit'
16
+ otherwise 'git'
17
+ }
18
+ end
19
+
20
+ dep 'git.installer', :version do
21
+ version.default!('1.7.7')
22
+ source "http://git-osx-installer.googlecode.com/files/git-#{version}-intel-universal-snow-leopard.dmg"
23
+ provides "git >= #{version}"
24
+ after {
25
+ cd '/usr/local/bin', :create => true, :sudo => true do
26
+ sudo "ln -sf /usr/local/git/bin/git* ."
27
+ end
28
+ }
29
+ end
data/deps/homebrew.rb ADDED
@@ -0,0 +1,30 @@
1
+ meta :homebrew do
2
+ def path
3
+ Babushka::BrewHelper.present? ? Babushka::BrewHelper.prefix : '/usr/local'
4
+ end
5
+ def repo
6
+ Babushka::GitRepo.new path
7
+ end
8
+ end
9
+
10
+ dep 'binary.homebrew' do
11
+ requires 'repo.homebrew'
12
+ met? { which 'brew' }
13
+ meet { log_shell "Resetting to HEAD", "git reset --hard", :cd => path }
14
+ end
15
+
16
+ dep 'repo.homebrew' do
17
+ requires_when_unmet 'writable.fhs'.with(path), 'git'
18
+ met? {
19
+ if repo.exists? && !repo.include?('29d85578e75170a6c0eaebda4d701b46f1acf446')
20
+ unmeetable "There is a non-homebrew repo at #{path}."
21
+ else
22
+ repo.exists?
23
+ end
24
+ }
25
+ meet {
26
+ git "git://github.com/mxcl/homebrew.git" do
27
+ log_shell "Gitifying #{path}", "cp -r .git '#{path}'"
28
+ end
29
+ }
30
+ end
data/deps/os_x.rb ADDED
@@ -0,0 +1,33 @@
1
+ dep 'xcode tools', :template => 'external' do
2
+ expects 'gcc', 'g++', 'autoconf', 'make', 'ld'
3
+ otherwise {
4
+ log_and_open "Install Xcode, and then run Babushka again.", "http://developer.apple.com/technology/xcode.html"
5
+ }
6
+ end
7
+
8
+ dep 'xcode commandline tools', :template => 'installer' do
9
+ # These pkgs consist of the packages inside the Xcode installer that contain the
10
+ # commandline tools and compiler toolchain. They're not a custom build - they're
11
+ # unmodified from the original Xcode install; just a subset (i.e. excluding the
12
+ # packages for things like Interface Builder and Xcode.app).
13
+ #
14
+ # See http://github.com/kennethreitz/osx-gcc-installer for more info.
15
+ source {
16
+ on :lion, 'https://github.com/downloads/kennethreitz/osx-gcc-installer/GCC-10.7-v2.pkg'
17
+ on :snow_leopard, 'https://github.com/downloads/kennethreitz/osx-gcc-installer/GCC-10.6.pkg'
18
+ }
19
+ provides %w[cc gcc c++ g++ llvm-gcc llvm-g++ clang] # compilers
20
+ provides %w[ld libtool] # linkety link
21
+ provides %w[make automake autoconf] # configure and build tools
22
+ provides %w[cpp m4 nasm yacc bison] # misc - the preprocessor, assembler, grammar stuff
23
+ end
24
+
25
+ dep 'llvm in path', :for => :snow_leopard do
26
+ requires 'xcode tools'
27
+ met? { which 'llvm-gcc-4.2' }
28
+ meet {
29
+ cd('/usr/local/bin') {|path|
30
+ shell "ln -s /Developer/usr/llvm-gcc-4.2/bin/llvm* .", :sudo => !path.writable?
31
+ }
32
+ }
33
+ end
data/deps/packages.rb ADDED
@@ -0,0 +1,22 @@
1
+ dep 'curl.managed' do
2
+ installs {
3
+ via :apt, 'curl', 'libcurl4-openssl-dev'
4
+ via :yum, 'curl'
5
+ }
6
+ end
7
+
8
+ dep 'sudo' do
9
+ requires {
10
+ on :osx, 'sudo.external'
11
+ otherwise 'sudo.managed'
12
+ }
13
+ end
14
+
15
+ dep 'sudo.external' do
16
+ expects 'sudo'
17
+ otherwise {
18
+ log_error "Your system seems to be missing sudo."
19
+ }
20
+ end
21
+
22
+ dep 'sudo.managed'
@@ -0,0 +1,110 @@
1
+ dep 'macports.src' do
2
+ requires 'build tools'
3
+ provides 'port'
4
+ prefix '/opt/local'
5
+ source "http://distfiles.macports.org/MacPorts/MacPorts-1.8.0.tar.gz"
6
+ after { log_shell "Running port selfupdate", "port selfupdate", :sudo => true }
7
+ end
8
+
9
+ dep 'apt', :template => 'external' do
10
+ requires {
11
+ on :ubuntu, 'main.apt_source', 'universe.apt_source'
12
+ on :debian, 'main.apt_source'
13
+ }
14
+ expects 'apt-get'
15
+ otherwise {
16
+ log "Your system doesn't seem to have Apt installed. Is it Debian-based?"
17
+ }
18
+ end
19
+
20
+ dep 'pacman', :template => 'external' do
21
+ expects 'pacman'
22
+ otherwise {
23
+ log "You seem to be running Arch Linux, but are missing the Pacman package manager. Something is very, very wrong here."
24
+ }
25
+ end
26
+
27
+ meta :apt_source do
28
+ accepts_list_for :source_name
29
+ template {
30
+ met? {
31
+ source_name.all? {|name|
32
+ grep(/^deb .* #{Babushka::Base.host.name} (\w+ )*#{Regexp.escape(name.to_s)}/, '/etc/apt/sources.list')
33
+ }
34
+ }
35
+ before {
36
+ # Don't edit sources.list unless we know how to edit it for this debian flavour and version.
37
+ Babushka::AptHelper.source_for_system and Babushka::Base.host.name
38
+ }
39
+ meet {
40
+ source_name.each {|name|
41
+ append_to_file "deb #{Babushka::AptHelper.source_for_system} #{Babushka::Base.host.name} #{name}", '/etc/apt/sources.list', :sudo => true
42
+ }
43
+ }
44
+ after { Babushka::AptHelper.update_pkg_lists }
45
+ }
46
+ end
47
+
48
+ dep 'main.apt_source' do
49
+ source_name 'main'
50
+ end
51
+
52
+ dep 'universe.apt_source' do
53
+ source_name 'universe'
54
+ end
55
+
56
+ dep 'homebrew' do
57
+ requires 'binary.homebrew', 'build tools'
58
+ end
59
+
60
+ dep 'yum', :template => 'external' do
61
+ expects 'yum'
62
+ otherwise {
63
+ log "Your system doesn't seem to have Yum installed. Is it Redhat-based?"
64
+ }
65
+ end
66
+
67
+ dep 'npm' do
68
+ requires 'nodejs.src'
69
+ met? { which 'npm' }
70
+ meet {
71
+ log_shell "Installing npm", "curl http://npmjs.org/install.sh | #{'sudo' unless which('node').p.writable?} sh"
72
+ }
73
+ end
74
+
75
+ dep 'nodejs.src' do
76
+ source 'git://github.com/joyent/node.git'
77
+ provides 'node >= 0.4', 'node-waf'
78
+ end
79
+
80
+ dep 'pip' do
81
+ requires {
82
+ on :osx, 'pip.src'
83
+ otherwise 'pip.managed'
84
+ }
85
+ end
86
+
87
+ dep 'pip.managed' do
88
+ installs 'python-pip'
89
+ end
90
+
91
+ dep 'pip.src' do
92
+ source 'http://pypi.python.org/packages/source/p/pip/pip-0.8.3.tar.gz'
93
+ process_source {
94
+ log_shell "Installing pip", "python setup.py install", :sudo => !which('python').p.writable?
95
+ }
96
+ end
97
+
98
+ dep 'binpkgsrc', :template => 'external' do
99
+ expects 'pkg_radd'
100
+ otherwise {
101
+ log "You seem to be running DragonflyBSD or NETBSD, but are missing the pkgsrc package manager. Something is very, very wrong here."
102
+ }
103
+ end
104
+
105
+ dep 'binports', :template => 'external' do
106
+ expects 'pkg_add'
107
+ otherwise {
108
+ log "You seem to be running FreeBSD, but are missing the ports package manager. Something is very, very wrong here."
109
+ }
110
+ end
data/deps/ruby.rb ADDED
@@ -0,0 +1,23 @@
1
+ dep 'ruby' do
2
+ met? {
3
+ in_path? ['ruby >= 1.8.6', 'irb']
4
+ }
5
+ requires_when_unmet {
6
+ on :osx, 'ruby.external'
7
+ otherwise 'ruby.managed'
8
+ }
9
+ end
10
+
11
+ dep 'ruby.managed' do
12
+ installs {
13
+ via :maverick, %w[ruby ruby1.8-dev]
14
+ via :apt, %w[ruby irb ruby1.8-dev libopenssl-ruby]
15
+ via :yum, %w[ruby ruby-irb]
16
+ }
17
+ provides %w[ruby irb]
18
+ end
19
+
20
+ dep 'ruby.external' do
21
+ expects 'ruby >= 1.8.6', 'irb'
22
+ otherwise { log_error "This system should already have ruby on it." }
23
+ end
data/deps/rubygems.rb ADDED
@@ -0,0 +1,24 @@
1
+ dep 'rubygems', :version do
2
+ version.default!('1.8.10')
3
+ requires 'ruby'
4
+ requires_when_unmet 'curl.managed'
5
+ met? {
6
+ # We check for ruby here too to make sure `ruby` and `gem` run from the same place.
7
+ in_path? ["gem >= #{version}", 'ruby']
8
+ }
9
+ meet {
10
+ handle_source "http://production.cf.rubygems.org/rubygems/rubygems-#{version}.tgz" do
11
+ log_shell "Installing rubygems-#{version}", "ruby setup.rb", :spinner => true, :sudo => !File.writable?(which('ruby'))
12
+ end
13
+ }
14
+ after {
15
+ %w[cache ruby specs].each {|name| ('~/.gem' / name).mkdir }
16
+ cd cmd_dir('ruby') do
17
+ %w[gem1.8 gem18].each do |file|
18
+ if File.exists? file
19
+ shell "ln -sf #{file} gem", :sudo => !File.writable?(which('ruby'))
20
+ end
21
+ end
22
+ end
23
+ }
24
+ end
data/deps/system.rb ADDED
@@ -0,0 +1,10 @@
1
+ dep 'admins can sudo' do
2
+ requires 'admin group', 'sudo'
3
+ met? { !sudo('cat /etc/sudoers').split("\n").grep(/^%admin/).empty? }
4
+ meet { append_to_file '%admin ALL=(ALL) ALL', '/etc/sudoers', :sudo => true }
5
+ end
6
+
7
+ dep 'admin group' do
8
+ met? { grep(/^admin\:/, '/etc/group') }
9
+ meet { sudo 'groupadd admin' }
10
+ end
@@ -0,0 +1,68 @@
1
+ meta :app do
2
+ accepts_list_for :source
3
+ accepts_list_for :prefix, %w[~/Applications /Applications]
4
+ accepts_list_for :extra_source
5
+ accepts_list_for :provides, :name
6
+ accepts_block_for :current_version do |path| nil end
7
+ accepts_block_for :latest_version
8
+
9
+ def app_name_match
10
+ provides.first.to_s.sub(/\.app$/, '*.app')
11
+ end
12
+
13
+ def check_version path
14
+ current = current_version.call(path)
15
+ if current.nil? || version.nil?
16
+ debug "Can't check versions without both current and latest."
17
+ true
18
+ elsif current >= version
19
+ log_ok "#{name} is up to date at #{current}."
20
+ else
21
+ log "#{name} could be updated from #{current} to #{version}."
22
+ end
23
+ end
24
+
25
+ def prefix_to_use
26
+ prefix.map(&:p).find {|pre|
27
+ pre.directory?
28
+ } || '/Applications'.p
29
+ end
30
+
31
+ def discover_latest_version
32
+ latest_value = latest_version.call
33
+ # TODO this is just to detect the default block and ignore it. Yuck :)
34
+ set_version latest_value unless latest_value == true
35
+ end
36
+
37
+ template {
38
+ prepare {
39
+ setup_source_uris
40
+ }
41
+
42
+ met? {
43
+ discover_latest_version
44
+ installed = app_dir app_name_match
45
+ (installed && check_version(installed)).tap {|result|
46
+ log "Found at #{installed}." if result
47
+ }
48
+ }
49
+
50
+ meet {
51
+ process_sources {|archive|
52
+ Dir.glob("**/#{app_name_match}").select {|entry|
53
+ (entry / 'Contents/MacOS').exists? # must be an app bundle itself
54
+ }.reject {|entry|
55
+ entry['.app/'] # mustn't be inside another app bundle
56
+ }.map {|entry|
57
+ pre = prefix_to_use
58
+ target_path = pre / File.basename(entry)
59
+ if !target_path.exists? || confirm("Overwrite #{target_path}?") { target_path.rm }
60
+ log_block("Found #{entry}, copying to #{pre}") {
61
+ entry.p.copy target_path
62
+ }
63
+ end
64
+ }
65
+ }
66
+ }
67
+ }
68
+ end
@@ -0,0 +1,12 @@
1
+ meta :external do
2
+ accepts_list_for :expects
3
+ accepts_block_for :otherwise
4
+
5
+ template {
6
+ met? {
7
+ (in_path?(expects) || :fail).tap {|result|
8
+ otherwise.call if result == :fail
9
+ }
10
+ }
11
+ }
12
+ end
@@ -0,0 +1,31 @@
1
+ meta :installer do
2
+ accepts_list_for :source
3
+ accepts_list_for :extra_source
4
+ accepts_list_for :provides, :basename, :choose_with => :via
5
+ accepts_list_for :prefix, %w[~/Applications /Applications]
6
+
7
+ template {
8
+ prepare { setup_source_uris }
9
+ met? { in_path?(provides) }
10
+
11
+ # At the moment, we just try to install every .[m]pkg in the archive.
12
+ # Example:
13
+ #
14
+ # dep 'blah.installer' do
15
+ # source 'http://blah.org/blah-latest.dmg
16
+ # provides 'blah' # Only required if the name isn't 'blah'
17
+ # end
18
+ #
19
+ meet {
20
+ process_sources {|archive|
21
+ Dir.glob("**/*pkg").select {|entry|
22
+ entry[/\.m?pkg$/] # Everything ending in .pkg or .mpkg
23
+ }.reject {|entry|
24
+ entry[/\.m?pkg\//] # and isn't inside another package
25
+ }.map {|entry|
26
+ log_shell "Installing #{entry}", "installer -target / -pkg '#{entry}'", :sudo => true
27
+ }
28
+ }
29
+ }
30
+ }
31
+ end
@@ -0,0 +1,105 @@
1
+ managed_template = L{
2
+ def packages
3
+ installs.versions
4
+ end
5
+
6
+ def packages_present?
7
+ packages.all? {|pkg| pkg_manager.has? pkg }
8
+ end
9
+
10
+ def add_cfg_deps
11
+ cfg.all? {|target|
12
+ target_file = target.to_s
13
+ source_file = load_path.dirname / name / "#{File.basename(target_file)}.erb"
14
+ requires(dep("#{File.basename(target_file)} for #{name}") {
15
+ met? { babushka_config? target_file }
16
+ before {
17
+ shell "mkdir -p #{File.dirname(target_file)}", :sudo => !File.writable?(File.dirname(File.dirname(target_file)))
18
+ shell "chmod o+rx #{File.dirname(target_file)}", :sudo => !File.writable?(File.dirname(target_file))
19
+ }
20
+ meet { render_erb source_file, :to => target_file, :sudo => !File.writable?(File.dirname(target_file)) }
21
+ on :linux do
22
+ after { service_name.each {|s| sudo "/etc/init.d/#{s} restart" } }
23
+ end
24
+ })
25
+ }
26
+ end
27
+
28
+ requires pkg_manager.manager_dep
29
+ prepare {
30
+ add_cfg_deps
31
+ }
32
+ met? {
33
+ if installs.blank?
34
+ log_ok "Nothing to install on #{pkg_manager.manager_key}-based systems."
35
+ else
36
+ packages_present? and in_path?(provides)
37
+ end
38
+ }
39
+ before {
40
+ pkg_manager.update_pkg_lists_if_required
41
+ }
42
+ meet {
43
+ pkg_manager.install! packages
44
+ }
45
+ }
46
+
47
+ meta :managed do
48
+ accepts_list_for :installs, :basename, :choose_with => :via
49
+ accepts_list_for :provides, :basename, :choose_with => :via
50
+ accepts_list_for :service_name, :name
51
+ accepts_list_for :cfg
52
+
53
+ def pkg_manager
54
+ Babushka::Base.host.pkg_helper
55
+ end
56
+
57
+ def chooser
58
+ Babushka::Base.host.match_list
59
+ end
60
+
61
+ def chooser_choices
62
+ Babushka::PkgHelper.all_manager_keys + Babushka::SystemDefinitions.all_tokens
63
+ end
64
+
65
+ template(&managed_template)
66
+ end
67
+
68
+ meta :gem do
69
+ accepts_list_for :installs, :basename, :choose_with => :via
70
+ accepts_list_for :provides, :basename, :choose_with => :via
71
+ accepts_list_for :service_name, :name
72
+ accepts_list_for :cfg
73
+
74
+ def pkg_manager
75
+ Babushka::GemHelper
76
+ end
77
+
78
+ template(&managed_template)
79
+ end
80
+
81
+ meta :pip do
82
+ accepts_list_for :installs, :basename, :choose_with => :via
83
+ accepts_list_for :provides, :basename, :choose_with => :via
84
+ accepts_list_for :service_name, :name
85
+ accepts_list_for :cfg
86
+
87
+ def pkg_manager
88
+ Babushka::PipHelper
89
+ end
90
+
91
+ template(&managed_template)
92
+ end
93
+
94
+ meta :npm do
95
+ accepts_list_for :installs, :basename, :choose_with => :via
96
+ accepts_list_for :provides, [], :choose_with => :via
97
+ accepts_list_for :service_name, :name
98
+ accepts_list_for :cfg
99
+
100
+ def pkg_manager
101
+ Babushka::NpmHelper
102
+ end
103
+
104
+ template(&managed_template)
105
+ end