-
Notifications
You must be signed in to change notification settings - Fork 0
/
babushka.me.rb
67 lines (62 loc) · 1.42 KB
/
babushka.me.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
meta :bab_tarball do
def uri
'git://github.com/benhoskings/babushka.git'
end
def latest
var(:tarball_path) / 'LATEST'
end
def repo
Babushka::GitRepo.new(Babushka::BuildPrefix / 'babushka')
end
def tarball
var(:tarball_path) / "babushka-#{repo.current_head}.tgz"
end
end
dep 'babushka tarball' do
requires 'linked.bab_tarball', 'LATEST.bab_tarball'
setup {
set :tarball_path, './public/tarballs'.p
}
end
dep 'LATEST.bab_tarball' do
met? {
latest.exists? && (latest.read.strip == repo.current_head)
}
meet {
shell "echo #{repo.current_head} > '#{latest}'"
}
end
dep 'linked.bab_tarball' do
requires 'exists.bab_tarball'
setup { git uri }
met? {
(var(:tarball_path) / 'babushka.tgz').readlink == tarball
}
meet {
shell "ln -sf #{tarball} babushka.tgz", :cd => var(:tarball_path), :create => true
}
end
dep 'exists.bab_tarball' do
met? {
shell "tar -t -f #{tarball}"
}
meet {
shell "mkdir -p #{tarball.parent}"
shell "tar -zcv --exclude .git -f '#{tarball}' babushka/", :cd => Babushka::BuildPrefix
}
end
dep 'babushka.me db dump' do
def db_dump_path
'./public/db'.p
end
def db_dump
db_dump_path / 'babushka.me.psql'
end
met? {
db_dump.exists? && (db_dump.mtime + 300 > Time.now) # less than 5 minutes old
}
meet {
db_dump_path.mkdir
shell "pg_dump babushka.me > '#{db_dump}.tmp' && mv '#{db_dump}.tmp' '#{db_dump}'"
}
end