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/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,31 @@
|
|
1
|
+
GEM
|
2
|
+
remote: http://rubygems.org/
|
3
|
+
specs:
|
4
|
+
cloudservers (0.4.1)
|
5
|
+
json
|
6
|
+
diff-lcs (1.1.2)
|
7
|
+
fuubar (0.0.6)
|
8
|
+
rspec (~> 2.0)
|
9
|
+
rspec-instafail (~> 0.1.8)
|
10
|
+
ruby-progressbar (~> 0.0.10)
|
11
|
+
json (1.5.3)
|
12
|
+
rake (0.9.2)
|
13
|
+
rspec (2.6.0)
|
14
|
+
rspec-core (~> 2.6.0)
|
15
|
+
rspec-expectations (~> 2.6.0)
|
16
|
+
rspec-mocks (~> 2.6.0)
|
17
|
+
rspec-core (2.6.4)
|
18
|
+
rspec-expectations (2.6.0)
|
19
|
+
diff-lcs (~> 1.1.2)
|
20
|
+
rspec-instafail (0.1.8)
|
21
|
+
rspec-mocks (2.6.0)
|
22
|
+
ruby-progressbar (0.0.10)
|
23
|
+
|
24
|
+
PLATFORMS
|
25
|
+
ruby
|
26
|
+
|
27
|
+
DEPENDENCIES
|
28
|
+
cloudservers
|
29
|
+
fuubar
|
30
|
+
rake
|
31
|
+
rspec
|
data/README.markdown
ADDED
@@ -0,0 +1,246 @@
|
|
1
|
+
# About this repo
|
2
|
+
|
3
|
+
While using this gem, keep in mind:
|
4
|
+
|
5
|
+
* This software is packaged as rubycut-babushka, since author asked us not to use babushka as gem name since he wants to keep only one way of installing babushka (see https://github.com/benhoskings/babushka/issues/173 for details)
|
6
|
+
* by using this babushka as gem, it is not possible for babushka to configure ruby and rubygems
|
7
|
+
* switching the active rvm/rbenv ruby, or installing a new ruby that shadows the existing one, changes the set of gems that are in the path, which would make it look like babushka had disappeared.
|
8
|
+
* lot of tools are confined to a single set of gems, or a single bundle. But babushka should exist outside of those things so it can configure them.
|
9
|
+
* This is unstandard way to install babushka, standard way is explained at: http://babushka.me/installing
|
10
|
+
* This gem is built using https://github.com/rubycut/babushka, we try to follow main repo but can not guearantee that we will produce gem same day official babushka version comes out
|
11
|
+
* we will not be adding any new code to babhushka source code for now, but we will add more source documentation
|
12
|
+
|
13
|
+
|
14
|
+
## Development status
|
15
|
+
|
16
|
+
This gem is not fully tested in realistic environment, although all the spec work.
|
17
|
+
|
18
|
+
# babushka: test-driven sysadmin.
|
19
|
+
|
20
|
+
When you spend time researching something new, it's pretty easy to forget what you found, and have to re-research it again next time.
|
21
|
+
|
22
|
+
A lot of the tech jobs we do manually aren't challenging or fun, but they're finicky and have to be done just right. They're chores. Things that are important to do, but that are better automated than done manually by us people, right? After all, that's what is supposed to happen in the future. And the future is good, because in the future, we'll all have jetpants. So, onward.
|
23
|
+
|
24
|
+
The idea is this: you take a job that you'd rather not do manually, and describe it to babushka using its DSL. The way it works, babushka not only knows how to accomplish each part of the job, it also knows how to check if each part is already done. You're teaching babushka to achieve an end goal with whatever runtime conditions you throw at it, not just to perform the task that would get you there from the very start.
|
25
|
+
|
26
|
+
|
27
|
+
# installing
|
28
|
+
|
29
|
+
Installing is really easy on supported systems (currently, OS X and Ubuntu). All it takes is one command, and it can be the first command you run on the machine. (Babushka will happily install on any machine though, not just new ones.)
|
30
|
+
|
31
|
+
If you have curl (OS X):
|
32
|
+
|
33
|
+
bash -c "`curl babushka.me/up`"
|
34
|
+
|
35
|
+
If you have wget (Ubuntu):
|
36
|
+
|
37
|
+
bash -c "`wget -O - babushka.me/up`"
|
38
|
+
|
39
|
+
|
40
|
+
# kicking the tyres
|
41
|
+
|
42
|
+
Once the install process has finished, you're ready to rock. If you have a Mac, maybe a good example is to install homebrew. To do that, we run the dependency (in babushka parlance, 'dep') called `homebrew`:
|
43
|
+
|
44
|
+
babushka homebrew
|
45
|
+
|
46
|
+
Or check that your rubygems install is looking good - latest version + gem sources. This demonstrates how babushka works: it's the goal (rubygems set up well) that's important. You can safely run this whether rubygems is outdated, up to date, or missing, and babushka will work out what tasks need to be done in order to achieve the end goal. The `rubygems` dep handles that for us:
|
47
|
+
|
48
|
+
babushka rubygems
|
49
|
+
|
50
|
+
Things like rubygems and homebrew aren't hard to install on their own, but with babushka it's _really_ easy, and _fast_. But more importantly, you know the job is being done just right, every time.
|
51
|
+
|
52
|
+
OK, something more complex now---a full nginx/passenger stack.
|
53
|
+
|
54
|
+
babushka benhoskings:'webserver configured'
|
55
|
+
|
56
|
+
Then you can set up each virtualhost with
|
57
|
+
|
58
|
+
babushka benhoskings:'vhost configured'
|
59
|
+
|
60
|
+
That's how I set up all my production machines. If something isn't working, you have a list of things that aren't the culprit: everything in the output with a green √ beside it. Conversely, if babushka can detect the problem, the failing dep will have a red × beside it instead, which leads you straight to the cause of the problem. Test-driven sysadmin!
|
61
|
+
|
62
|
+
|
63
|
+
# nothing up my sleeve…
|
64
|
+
|
65
|
+
Creating and sharing this knowledge is central to babushka. It's all very well to run `babushka rubygems` and have it do a job for you, but the real power is in babushka's ability to automate whatever chore you want, not just ones that others have thought of already.
|
66
|
+
|
67
|
+
To that end, I've tried really hard to make the process quick and satisfying. If you spend a little bit of time getting the feel for how to efficiently use babushka's DSL, you'll be cranking out deps just like the `rubygems` and `homebrew` ones above.
|
68
|
+
|
69
|
+
|
70
|
+
## yeah, but how?
|
71
|
+
|
72
|
+
A dep is one single piece of a larger task. A little nugget of code that does just one thing, and does it right. Here's a babushka dep, at its most generic.
|
73
|
+
|
74
|
+
dep 'name' do
|
75
|
+
requires 'other deps', 'whatever they might be'
|
76
|
+
met? {
|
77
|
+
# is this dependency already met?
|
78
|
+
}
|
79
|
+
meet {
|
80
|
+
# this code gets run if it isn't.
|
81
|
+
}
|
82
|
+
end
|
83
|
+
|
84
|
+
The important bit here is that when you're writing a dep, you don't have to think about context at all, just the one little task it's doing in isolation. As long as your `requires` are correct, you can leave the overall structure to babushka and just write each little dep separately. When you run `babushka name`, babushka uses the `requires` in each dep to assemble a tree of deps and achieve the end goal you're after.
|
85
|
+
|
86
|
+
The idea is to keep a clean separation between `met?` and `meet`: the code in `met?` should do nothing except just check whether the dep is met and return a boolean, and `meet` should unconditionally satisfy the dep without doing any checks.
|
87
|
+
|
88
|
+
Right, here's one I prepared earlier. Given you're on a Mac with Xcode installed, this dep knows how to achieve the goal of having llvm available in the PATH.
|
89
|
+
|
90
|
+
dep 'llvm in path', :for => :snow_leopard do
|
91
|
+
requires 'xcode tools'
|
92
|
+
met? { which 'llvm-gcc-4.2' }
|
93
|
+
meet {
|
94
|
+
cd('/usr/local/bin') {|path|
|
95
|
+
shell "ln -s /Developer/usr/llvm-gcc-4.2/bin/llvm* .", :sudo => !path.writable?
|
96
|
+
}
|
97
|
+
}
|
98
|
+
end
|
99
|
+
|
100
|
+
All the common logic is handled by babushka, which means that all the code in the dep is specific to the job at hand. The idea is maximising that signal-to-noise ratio: as much of the code in the dep above should be talking about llvm, not about other things that can be inferred elsewhere.
|
101
|
+
|
102
|
+
Notice that there's no conditional or nested logic within the dep. That's by design: the more declarative things are, the more composable and re-interpretable they are later.
|
103
|
+
|
104
|
+
If you find you're checking for the presence of some condition in your `meet` block, it probably means you're trying to do too much in a single dep, and you should be splitting it up into smaller ones. Remember, deps are small, self-contained and context-free - the more focused, the better.
|
105
|
+
|
106
|
+
|
107
|
+
## let's get declarative
|
108
|
+
|
109
|
+
The basic dep, with just `requires`, `met?` and `meet`, is all you need to describe an end goal. But this generic nature of `met?` and `meet` means just as they're general purpose, they can lack focus. For example, installing an app using the system's package manager has a predictable `met?` block---check whether the package is present and its binaries are in the path.
|
110
|
+
|
111
|
+
A lot of chores are variations on a theme like this, or just too cumbersome to do repeatedly at a low level. So babushka provides a way to write dep templates, or _meta deps_, that can be reused later. These meta deps allow you to focus the DSL, and make it even more concise.
|
112
|
+
|
113
|
+
For example, Babushka ships with a meta dep that knows how to install TextMate bundles, given just the URL. All the actual logic, including the code for `met?` and `meet`, is wrapped up in the meta dep.
|
114
|
+
|
115
|
+
meta :tmbundle, :for => :osx do
|
116
|
+
accepts_list_for :source
|
117
|
+
|
118
|
+
template {
|
119
|
+
requires 'TextMate.app'
|
120
|
+
def path
|
121
|
+
'~/Library/Application Support/TextMate/Bundles' / name
|
122
|
+
end
|
123
|
+
met? { path.dir? }
|
124
|
+
before { shell "mkdir -p #{path.parent}" }
|
125
|
+
meet {
|
126
|
+
source.each {|uri|
|
127
|
+
git uri, :to => path
|
128
|
+
}
|
129
|
+
}
|
130
|
+
after { shell %Q{osascript -e 'tell app "TextMate" to reload bundles'} }
|
131
|
+
}
|
132
|
+
end
|
133
|
+
|
134
|
+
Notice how the contents of the `template` block looks like a normal dep. That's cause it is---the meta dep is a factory, that takes values defined by `accepts_list_for` (in this case, `source`) and produces regular deps at runtime under the covers.
|
135
|
+
|
136
|
+
Given the `tmbundle` meta dep, this dep handles the cucumber bundle:
|
137
|
+
|
138
|
+
dep 'Cucumber.tmbundle' do
|
139
|
+
source 'git://github.com/bmabey/cucumber-tmbundle.git'
|
140
|
+
end
|
141
|
+
|
142
|
+
Notice there's no imperative code there at all---just declarations. That's what the DSL aims for. Instead of saying "do this, then do this, then do this", the code should say "here's a description of the problem, now you work it out." Also notice that there's no TextMate-specific logic. Adding this extra level of abstraction means all that's left are the specifics for _this_ TextMate bundle.
|
143
|
+
|
144
|
+
|
145
|
+
# a runtime example
|
146
|
+
|
147
|
+
All that means that babushka isn't just blindly running a bunch of code to make things happen. Each step of the way, it's checking what should be done, and only doing the bits that aren't done already. (In babushka parlance, it's only meeting dependencies that aren't already met.)
|
148
|
+
|
149
|
+
If you already have TextMate installed, babushka notices and just installs the bundle.
|
150
|
+
|
151
|
+
Cucumber.tmbundle {
|
152
|
+
TextMate.app {
|
153
|
+
Found at /Applications/TextMate.app.
|
154
|
+
} √ TextMate.app
|
155
|
+
not already met.
|
156
|
+
Cloning from git://github.com/bmabey/cucumber-tmbundle.git... done.
|
157
|
+
Cucumber.tmbundle met.
|
158
|
+
} √ Cucumber.tmbundle
|
159
|
+
|
160
|
+
But if you don't have TextMate, that's an unmet dependency, so it gets pulled in too.
|
161
|
+
|
162
|
+
Cucumber.tmbundle {
|
163
|
+
TextMate.app {
|
164
|
+
not already met.
|
165
|
+
Downloading http://download-b.macromates.com/TextMate_1.5.9.dmg... done.
|
166
|
+
Attaching TextMate_1.5.9.dmg... done.
|
167
|
+
Found TextMate.app in the DMG, copying to /Applications... done.
|
168
|
+
Detaching TextMate_1.5.9.dmg... done.
|
169
|
+
Found at /Applications/TextMate.app.
|
170
|
+
TextMate.app met.
|
171
|
+
} √ TextMate.app
|
172
|
+
not already met.
|
173
|
+
Cloning from git://github.com/bmabey/cucumber-tmbundle.git... done.
|
174
|
+
Cucumber.tmbundle met.
|
175
|
+
} √ Cucumber.tmbundle
|
176
|
+
|
177
|
+
|
178
|
+
## dep sources
|
179
|
+
|
180
|
+
Babushka only contains the deps that it needs to know how to install itself, and set up a bare minimum of software like package managers, `ruby` and `git`. Everything else is stored separately, in _dep sources_. A dep source is a babushka-managed git repo that contains a bunch of ruby files.
|
181
|
+
|
182
|
+
The organisation and naming of the files within the source is completely up to you - babushka will recursively load all the .rb files it can find in the source, in alphabetical order.
|
183
|
+
|
184
|
+
You can define deps and templates in the same source, arranged however you like. You don't have to worry about having templates loaded before deps that are defined against them, because the load is a two-stage process that first reads every file and sets up the templates, and then defines all the deps that were found.
|
185
|
+
|
186
|
+
The best way manage your own source is to make <tt>~/.babushka/deps</tt> a git repo, and push it to <tt>git://github.com/username/babushka-deps.git</tt>.
|
187
|
+
|
188
|
+
To run deps from others' sources, you don't need to add the source explicitly. Just prefix the dep name with the correct username:
|
189
|
+
|
190
|
+
babushka freelancing-god:rvm
|
191
|
+
|
192
|
+
The dep source will be cloned into <tt>~/.babushka/sources/freelancing-god</tt>, or updated if it's already there, and then babushka will search for a dep called "rvm" within that source. Because of this partitioning, you don't have to worry about naming conflicts with other people; everything is per-source.
|
193
|
+
|
194
|
+
If you want to rename a source, or add one with a custom URL, you can add sources manually like this:
|
195
|
+
|
196
|
+
babushka sources -a custom-name git://example.com/custom/url.git
|
197
|
+
|
198
|
+
That will make the source available in <tt>~/.babushka/sources/custom-name</tt>.
|
199
|
+
|
200
|
+
There's no configuration file for dep sources; the only state is stored in the contents of <tt>~/.babushka/sources</tt>. Specifically, the source names are the directory names, and the URLs are the locations of the corresponding 'origin' git remotes.
|
201
|
+
|
202
|
+
Because of this, you can safely add, remove, rename and edit the directories and repositories in there as much as you like---but importantly, *babushka assumes it has free run of <tt>~/.babushka/sources</tt>, and won't hesitate to `git reset --hard`. If you leave uncommitted or unpushed changes in a source, they'll be lost when that source is updated.*
|
203
|
+
|
204
|
+
If you want to write deps just for yourself that you don't plan to push online, just drop them in <tt>~/.babushka/deps</tt>. If you'd rather keep them elsewhere, like in <tt>~/src</tt> or similar, you can symlink the directory into <tt>~/.babushka/deps</tt>.
|
205
|
+
|
206
|
+
Finally, babushka also loads deps from `./babushka-deps` in the directory from which it was run. This is a good place for project-specific deps, because you can keep them within the project's source control.
|
207
|
+
|
208
|
+
|
209
|
+
## n.b.
|
210
|
+
|
211
|
+
A dep can run any code. Run deps of unknown origin at your own risk, and when choosing deps and dep sources, use the only real security there is: a network of trust.
|
212
|
+
|
213
|
+
Many deps will change your system irreversibly, which is kind of the whole point, but it has to be said anyway. Use caution and always have a backup.
|
214
|
+
|
215
|
+
|
216
|
+
## acknowledgements
|
217
|
+
|
218
|
+
[Fancypath](http://github.com/tred/fancypath/), by [Myles Byrne](http://www.myles.id.au/) & [Chris Lloyd](http://thelincolnshirepoacher.com/). It's how I made the paths so fancy.
|
219
|
+
|
220
|
+
[Levenshtein](http://raa.ruby-lang.org/project/levenshtein/), for typo correction. Thanks to [Paul Battley](http://twitter.com/threedaymonk) for letting me dual-license it under BSD.
|
221
|
+
|
222
|
+
Thanks to my rubyist friends who've helped with brainstorming and testing---the likes of
|
223
|
+
[@glenmaddern](http://twitter.com/glenmaddern),
|
224
|
+
[@nathan_scott](http://twitter.com/nathan_scott),
|
225
|
+
[@notahat](http://twitter.com/notahat),
|
226
|
+
[@quamen](http://twitter.com/quamen),
|
227
|
+
[@dgoodlad](http://twitter.com/dgoodlad),
|
228
|
+
[@chrisberkhout](http://twitter.com/chrisberkhout),
|
229
|
+
[@pat](http://twitter.com/pat),
|
230
|
+
[@brentsnook](http://twitter.com/brentsnook),
|
231
|
+
[@odaeus](http://twitter.com/odaeus),
|
232
|
+
[@lachlanhardy](http://twitter.com/lachlanhardy),
|
233
|
+
[@aussiegeek](http://twitter.com/aussiegeek),
|
234
|
+
[@bjeanes](http://twitter.com/bjeanes),
|
235
|
+
[@chendo](http://twitter.com/chendo),
|
236
|
+
[@ryanbigg](http://twitter.com/ryanbigg) &
|
237
|
+
[@drnic](http://twitter.com/drnic).
|
238
|
+
|
239
|
+
|
240
|
+
## license
|
241
|
+
|
242
|
+
Babushka is licensed under the BSD license, except for the following exception:
|
243
|
+
|
244
|
+
lib/support/levenshtein.rb, which is licensed under the MIT license.
|
245
|
+
|
246
|
+
The BSD license can be found in full in the LICENSE file, and the MIT license at the top of lib/support/levenshtein.rb.
|
data/Rakefile
ADDED
@@ -0,0 +1,26 @@
|
|
1
|
+
require 'rake'
|
2
|
+
require 'rspec/core/rake_task'
|
3
|
+
|
4
|
+
desc 'Run the spec suite'
|
5
|
+
RSpec::Core::RakeTask.new('spec') {|t|
|
6
|
+
t.rspec_opts = ['--colour', '--format Fuubar']
|
7
|
+
}
|
8
|
+
|
9
|
+
desc 'Run the acceptance suite'
|
10
|
+
RSpec::Core::RakeTask.new('acceptance') {|t|
|
11
|
+
t.pattern = "./spec/acceptance/*.rb"
|
12
|
+
t.rspec_opts = ['--colour']
|
13
|
+
}
|
14
|
+
|
15
|
+
desc 'Profile the spec suite'
|
16
|
+
RSpec::Core::RakeTask.new('profile') {|t|
|
17
|
+
t.rspec_opts = %w[--colour --profile]
|
18
|
+
}
|
19
|
+
|
20
|
+
desc 'Run code coverage'
|
21
|
+
RSpec::Core::RakeTask.new('rcov') {|t|
|
22
|
+
t.rcov = true
|
23
|
+
t.rcov_opts = %w[--exclude spec]
|
24
|
+
}
|
25
|
+
|
26
|
+
task :default => :spec
|
data/bin/babushka
ADDED
@@ -0,0 +1,11 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'babushka'
|
4
|
+
|
5
|
+
Object.send :include, Babushka::DSL
|
6
|
+
|
7
|
+
# Handle ctrl-c gracefully during babushka runs.
|
8
|
+
Babushka::Base.exit_on_interrupt!
|
9
|
+
|
10
|
+
# Invoke babushka, returning the correct exit status to the shell.
|
11
|
+
exit !!Babushka::Base.run
|
data/deps/babushka.rb
ADDED
@@ -0,0 +1,101 @@
|
|
1
|
+
meta :babushka do
|
2
|
+
def repo
|
3
|
+
Babushka::GitRepo.new(path)
|
4
|
+
end
|
5
|
+
end
|
6
|
+
|
7
|
+
dep 'babushka', :from, :path, :branch do
|
8
|
+
requires 'up to date.babushka'.with(from, path, branch)
|
9
|
+
requires 'in path.babushka'.with(from, path)
|
10
|
+
path.ask("Where would you like babushka installed").default('/usr/local/babushka')
|
11
|
+
path.default!(Babushka::Path.path) if Babushka::Path.run_from_path?
|
12
|
+
branch.default!('master')
|
13
|
+
end
|
14
|
+
|
15
|
+
dep 'up to date.babushka', :from, :path, :branch do
|
16
|
+
requires 'repo clean.babushka'.with(from, path)
|
17
|
+
requires 'update would fast forward.babushka'.with(from, path, branch)
|
18
|
+
met? {
|
19
|
+
(!repo.behind?).tap {|result|
|
20
|
+
if result
|
21
|
+
log_ok "babushka is up to date at revision #{repo.current_head}."
|
22
|
+
else
|
23
|
+
log "babushka can be updated: #{repo.current_head}..#{repo.repo_shell("git rev-parse --short origin/#{branch}")}"
|
24
|
+
end
|
25
|
+
}
|
26
|
+
}
|
27
|
+
meet {
|
28
|
+
log "#{repo.repo_shell("git diff --stat #{repo.current_head}..origin/#{branch}")}"
|
29
|
+
repo.reset_hard! "origin/#{branch}"
|
30
|
+
}
|
31
|
+
end
|
32
|
+
|
33
|
+
dep 'update would fast forward.babushka', :from, :path, :branch do
|
34
|
+
requires 'on correct branch.babushka'.with(from, path, branch)
|
35
|
+
met? {
|
36
|
+
if !repo.repo_shell('git fetch origin')
|
37
|
+
unmeetable "Couldn't pull the latest code - check your internet connection."
|
38
|
+
else
|
39
|
+
if !repo.remote_branch_exists?
|
40
|
+
unmeetable "The current branch, #{repo.current_branch}, isn't pushed to origin/#{repo.current_branch}."
|
41
|
+
elsif repo.ahead?
|
42
|
+
unmeetable "There are unpushed commits in #{repo.current_branch}."
|
43
|
+
else
|
44
|
+
true
|
45
|
+
end
|
46
|
+
end
|
47
|
+
}
|
48
|
+
end
|
49
|
+
|
50
|
+
dep 'on correct branch.babushka', :from, :path, :branch do
|
51
|
+
requires 'branch exists.babushka'.with(from, path, branch)
|
52
|
+
requires_when_unmet 'repo clean.babushka'.with(from, path)
|
53
|
+
met? { repo.current_branch == branch.to_s }
|
54
|
+
meet { repo.checkout! branch }
|
55
|
+
end
|
56
|
+
|
57
|
+
dep 'branch exists.babushka', :from, :path, :branch do
|
58
|
+
requires 'installed.babushka'.with(from, path)
|
59
|
+
met? { repo.branches.include? branch.to_s }
|
60
|
+
meet { repo.track! "origin/#{branch}" }
|
61
|
+
end
|
62
|
+
|
63
|
+
dep 'repo clean.babushka', :from, :path do
|
64
|
+
requires 'installed.babushka'.with(from, path)
|
65
|
+
met? {
|
66
|
+
repo.clean? or unmeetable("There are local changes in #{repo.path}.")
|
67
|
+
}
|
68
|
+
end
|
69
|
+
|
70
|
+
dep 'in path.babushka', :from, :path do
|
71
|
+
requires 'installed.babushka'.with(from, path)
|
72
|
+
def bin_path
|
73
|
+
repo.path / '../bin'
|
74
|
+
end
|
75
|
+
setup {
|
76
|
+
unmeetable "The binary path alongside babushka, #{bin_path}, isn't in your $PATH." unless ENV['PATH'].split(':').include?(bin_path)
|
77
|
+
}
|
78
|
+
met? { which 'babushka' }
|
79
|
+
prepare {
|
80
|
+
unmeetable "The current user, #{shell('whoami')}, can't write to #{bin_path} (to symlink babushka into the path)." unless bin_path.hypothetically_writable?
|
81
|
+
}
|
82
|
+
meet {
|
83
|
+
bin_path.mkdir
|
84
|
+
log_shell "Linking babushka into #{bin_path}", %Q{ln -sf "#{repo.path / 'bin/babushka.rb'}" "#{bin_path / 'babushka'}"}
|
85
|
+
}
|
86
|
+
end
|
87
|
+
|
88
|
+
dep 'installed.babushka', :from, :path do
|
89
|
+
from.default!("git://github.com/benhoskings/babushka.git")
|
90
|
+
|
91
|
+
requires 'ruby', 'git'
|
92
|
+
setup {
|
93
|
+
unmeetable "The current user, #{shell('whoami')}, can't write to #{repo.path}." unless repo.path.hypothetically_writable?
|
94
|
+
}
|
95
|
+
met? { repo.exists? }
|
96
|
+
meet {
|
97
|
+
log_block "Cloning #{from} into #{repo.path}" do
|
98
|
+
repo.clone! from
|
99
|
+
end
|
100
|
+
}
|
101
|
+
end
|
data/deps/dev.rb
ADDED
@@ -0,0 +1,12 @@
|
|
1
|
+
dep 'build tools' do
|
2
|
+
requires {
|
3
|
+
on :osx, 'xcode commandline tools'
|
4
|
+
on :snow_leopard, 'llvm in path'
|
5
|
+
on :yum, dep('gcc'), dep('gcc-c++'), dep('autoconf.managed'), dep('automake.managed'), dep('libtool.managed')
|
6
|
+
on :linux, 'build-essential', dep('autoconf.managed'), dep('automake.managed'), dep('libtool.managed')
|
7
|
+
}
|
8
|
+
end
|
9
|
+
|
10
|
+
dep 'build-essential', :template => 'managed' do
|
11
|
+
provides 'gcc', 'g++', 'make', 'ld'
|
12
|
+
end
|
data/deps/fhs.rb
ADDED
@@ -0,0 +1,31 @@
|
|
1
|
+
meta :fhs do
|
2
|
+
def subpaths
|
3
|
+
%w[. bin etc include lib sbin share share/doc var].concat(
|
4
|
+
(1..9).map {|i| "share/man/man#{i}" }
|
5
|
+
)
|
6
|
+
end
|
7
|
+
end
|
8
|
+
|
9
|
+
dep 'writable.fhs', :path do
|
10
|
+
requires 'layout.fhs'.with(path)
|
11
|
+
requires_when_unmet 'admins can sudo'
|
12
|
+
met? {
|
13
|
+
_, nonwritable = subpaths.partition {|subpath| File.writable_real?(path / subpath) }
|
14
|
+
nonwritable.empty?.tap {|result|
|
15
|
+
log "Some directories within #{path} aren't writable by #{shell 'whoami'}." unless result
|
16
|
+
}
|
17
|
+
}
|
18
|
+
meet {
|
19
|
+
confirm "About to enable write access to #{path} for admin users - is that OK?" do
|
20
|
+
subpaths.each {|subpath|
|
21
|
+
sudo %Q{chgrp admin '#{path / subpath}'}
|
22
|
+
sudo %Q{chmod g+w '#{path / subpath}'}
|
23
|
+
}
|
24
|
+
end
|
25
|
+
}
|
26
|
+
end
|
27
|
+
|
28
|
+
dep 'layout.fhs', :path do
|
29
|
+
met? { subpaths.all? {|subpath| File.directory?(path / subpath) } }
|
30
|
+
meet { sudo "mkdir -p #{subpaths.map {|subpath| "'#{path / subpath}'" }.join(' ')}" }
|
31
|
+
end
|