rubycut-babushka 0.10.6
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile +8 -0
- data/Gemfile.lock +31 -0
- data/README.markdown +246 -0
- data/Rakefile +26 -0
- data/bin/babushka +11 -0
- data/deps/babushka.rb +101 -0
- data/deps/dev.rb +12 -0
- data/deps/fhs.rb +31 -0
- data/deps/git.rb +29 -0
- data/deps/homebrew.rb +30 -0
- data/deps/os_x.rb +33 -0
- data/deps/packages.rb +22 -0
- data/deps/pkg_managers.rb +110 -0
- data/deps/ruby.rb +23 -0
- data/deps/rubygems.rb +24 -0
- data/deps/system.rb +10 -0
- data/deps/templates/app.rb +68 -0
- data/deps/templates/external.rb +12 -0
- data/deps/templates/installer.rb +31 -0
- data/deps/templates/managed.rb +105 -0
- data/deps/templates/ppa.rb +24 -0
- data/deps/templates/src.rb +42 -0
- data/deps/templates/tmbundle.rb +15 -0
- data/lib/babushka.rb +28 -0
- data/lib/babushka/accepts_block_for.rb +72 -0
- data/lib/babushka/accepts_list_for.rb +49 -0
- data/lib/babushka/accepts_value_for.rb +24 -0
- data/lib/babushka/base.rb +78 -0
- data/lib/babushka/bug_reporter.rb +55 -0
- data/lib/babushka/cmdline.rb +133 -0
- data/lib/babushka/cmdline/handler.rb +41 -0
- data/lib/babushka/cmdline/helpers.rb +127 -0
- data/lib/babushka/cmdline/parser.rb +69 -0
- data/lib/babushka/colorizer.rb +59 -0
- data/lib/babushka/core_patches/array.rb +171 -0
- data/lib/babushka/core_patches/blank.rb +22 -0
- data/lib/babushka/core_patches/bytes.rb +52 -0
- data/lib/babushka/core_patches/hash.rb +107 -0
- data/lib/babushka/core_patches/hashish.rb +14 -0
- data/lib/babushka/core_patches/integer.rb +25 -0
- data/lib/babushka/core_patches/io.rb +8 -0
- data/lib/babushka/core_patches/numeric.rb +16 -0
- data/lib/babushka/core_patches/object.rb +27 -0
- data/lib/babushka/core_patches/string.rb +116 -0
- data/lib/babushka/core_patches/symbol.rb +12 -0
- data/lib/babushka/core_patches/try.rb +15 -0
- data/lib/babushka/core_patches/uri.rb +24 -0
- data/lib/babushka/dep.rb +470 -0
- data/lib/babushka/dep_context.rb +18 -0
- data/lib/babushka/dep_definer.rb +115 -0
- data/lib/babushka/dep_pool.rb +49 -0
- data/lib/babushka/dep_runner.rb +85 -0
- data/lib/babushka/dsl.rb +26 -0
- data/lib/babushka/git_repo.rb +185 -0
- data/lib/babushka/helpers/git_helpers.rb +32 -0
- data/lib/babushka/helpers/log_helpers.rb +176 -0
- data/lib/babushka/helpers/path_helpers.rb +34 -0
- data/lib/babushka/helpers/run_helpers.rb +145 -0
- data/lib/babushka/helpers/shell_helpers.rb +229 -0
- data/lib/babushka/helpers/suggest_helpers.rb +16 -0
- data/lib/babushka/helpers/uri_helpers.rb +36 -0
- data/lib/babushka/ip.rb +160 -0
- data/lib/babushka/lambda_chooser.rb +40 -0
- data/lib/babushka/levenshtein.rb +125 -0
- data/lib/babushka/meta_dep.rb +65 -0
- data/lib/babushka/meta_dep_context.rb +15 -0
- data/lib/babushka/parameter.rb +143 -0
- data/lib/babushka/pkg_helper.rb +81 -0
- data/lib/babushka/pkg_helpers/apt_helper.rb +61 -0
- data/lib/babushka/pkg_helpers/base_helper.rb +19 -0
- data/lib/babushka/pkg_helpers/binpkgsrc_helper.rb +48 -0
- data/lib/babushka/pkg_helpers/binports_helper.rb +34 -0
- data/lib/babushka/pkg_helpers/brew_helper.rb +110 -0
- data/lib/babushka/pkg_helpers/gem_helper.rb +120 -0
- data/lib/babushka/pkg_helpers/macports_helper.rb +22 -0
- data/lib/babushka/pkg_helpers/npm_helper.rb +45 -0
- data/lib/babushka/pkg_helpers/pacman_helper.rb +27 -0
- data/lib/babushka/pkg_helpers/pip_helper.rb +45 -0
- data/lib/babushka/pkg_helpers/src_helper.rb +16 -0
- data/lib/babushka/pkg_helpers/yum_helper.rb +25 -0
- data/lib/babushka/popen.rb +40 -0
- data/lib/babushka/prompt.rb +176 -0
- data/lib/babushka/renderable.rb +67 -0
- data/lib/babushka/resource.rb +215 -0
- data/lib/babushka/run_reporter.rb +60 -0
- data/lib/babushka/shell.rb +108 -0
- data/lib/babushka/source.rb +216 -0
- data/lib/babushka/source_pool.rb +146 -0
- data/lib/babushka/system_definitions.rb +97 -0
- data/lib/babushka/system_profile.rb +210 -0
- data/lib/babushka/task.rb +142 -0
- data/lib/babushka/vars.rb +108 -0
- data/lib/babushka/version_of.rb +65 -0
- data/lib/babushka/version_str.rb +57 -0
- data/lib/babushka/xml_string.rb +28 -0
- data/lib/components.rb +82 -0
- data/lib/fancypath/fancypath.rb +200 -0
- data/lib/inkan/inkan.rb +76 -0
- data/spec/acceptance/acceptance.rb +43 -0
- data/spec/acceptance_helper.rb +113 -0
- data/spec/archives/Blah.app.zip +0 -0
- data/spec/archives/archive.tar +0 -0
- data/spec/archives/archive.tar.bz2 +0 -0
- data/spec/archives/archive.tar.gz +0 -0
- data/spec/archives/archive.tbz2 +0 -0
- data/spec/archives/archive.tgz +0 -0
- data/spec/archives/archive.zip +0 -0
- data/spec/archives/content.txt +5 -0
- data/spec/archives/invalid_archive +5 -0
- data/spec/archives/nested archive/content.txt +5 -0
- data/spec/archives/nested_archive.tar +0 -0
- data/spec/archives/really_a_gzip.zip +0 -0
- data/spec/archives/test-0.3.1.tgz +0 -0
- data/spec/archives/tgz_archive +0 -0
- data/spec/archives/zip_without_extension +0 -0
- data/spec/babushka/accepts_for_spec.rb +174 -0
- data/spec/babushka/accepts_for_support.rb +72 -0
- data/spec/babushka/cmdline/console_spec.rb +11 -0
- data/spec/babushka/cmdline/help_spec.rb +61 -0
- data/spec/babushka/cmdline/version_spec.rb +10 -0
- data/spec/babushka/core_patches_spec.rb +171 -0
- data/spec/babushka/dep_context_spec.rb +58 -0
- data/spec/babushka/dep_definer_spec.rb +152 -0
- data/spec/babushka/dep_definer_support.rb +36 -0
- data/spec/babushka/dep_spec.rb +567 -0
- data/spec/babushka/dep_support.rb +29 -0
- data/spec/babushka/deps_spec.rb +113 -0
- data/spec/babushka/gem_helper_spec.rb +90 -0
- data/spec/babushka/git_repo_spec.rb +396 -0
- data/spec/babushka/ip_spec.rb +131 -0
- data/spec/babushka/lambda_chooser_spec.rb +115 -0
- data/spec/babushka/meta_dep_definer_spec.rb +127 -0
- data/spec/babushka/meta_dep_wrapper_spec.rb +32 -0
- data/spec/babushka/parameter_spec.rb +135 -0
- data/spec/babushka/path_helpers_spec.rb +102 -0
- data/spec/babushka/prompt_spec.rb +188 -0
- data/spec/babushka/renderable_spec.rb +100 -0
- data/spec/babushka/resource_spec.rb +141 -0
- data/spec/babushka/run_helpers_spec.rb +26 -0
- data/spec/babushka/shell_helpers_spec.rb +244 -0
- data/spec/babushka/shell_spec.rb +19 -0
- data/spec/babushka/source_pool_spec.rb +320 -0
- data/spec/babushka/source_pool_support.rb +31 -0
- data/spec/babushka/source_spec.rb +382 -0
- data/spec/babushka/source_support.rb +17 -0
- data/spec/babushka/system_profile_spec.rb +61 -0
- data/spec/babushka/task_spec.rb +141 -0
- data/spec/babushka/uri_spec.rb +13 -0
- data/spec/babushka/vars_spec.rb +59 -0
- data/spec/babushka/version_of_spec.rb +110 -0
- data/spec/babushka/version_str_spec.rb +130 -0
- data/spec/babushka/version_str_support.rb +37 -0
- data/spec/babushka/xml_string_spec.rb +98 -0
- data/spec/deps/bad/broken.rb +7 -0
- data/spec/deps/bad/working.rb +3 -0
- data/spec/deps/good/meta.rb +14 -0
- data/spec/deps/good/test.rb +11 -0
- data/spec/deps/outer/deps.rb +19 -0
- data/spec/deps/outer/more deps.rb +11 -0
- data/spec/deps/params/params.rb +10 -0
- data/spec/fancypath/fancypath_spec.rb +272 -0
- data/spec/fancypath_support.rb +10 -0
- data/spec/inkan/inkan_spec.rb +217 -0
- data/spec/renderable/different_example.conf.erb +4 -0
- data/spec/renderable/example.conf.erb +3 -0
- data/spec/renderable/example.sh +6 -0
- data/spec/renderable/with_binding.conf.erb +4 -0
- data/spec/renderable/xml_example.conf.erb +8 -0
- data/spec/repos/remote.git.tgz +0 -0
- data/spec/spec_helper.rb +87 -0
- 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,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
|