forked from crowbar/crowbar
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Guardfile.tree-merge
93 lines (87 loc) · 2.52 KB
/
Guardfile.tree-merge
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
#!/usr/bin/ruby
#
# Guardfile which uses guard-rsync to perform a real-time merge of the
# Crowbar repositories into a single hierarchy like the one which ends
# up under /opt/dell, or under /tmp/crowbar-dev-test/opt/dell when
# ./dev tests setup is run.
#
# The target location of the merge can be a local path or an rsync
# target such as [email protected]:/opt/dell
#
# This is a different approach to Guardfile.mirror, which mirrors the
# tree without performing any merging; it skips the need for manual
# runs of barclamp_install.rb, but has the consequent disadvantage of
# not taking care of uploading cookbooks via knife, etc.
#
# Usage
# -----
#
# First ensure you have the necessary gems by cd'ing to this directory
# and running 'bundle'. Doing this inside an rvm gemset is recommended.
#
# Then use as follows:
#
# # Optionally set the rsync target; defaults to /tmp/crowbar-dev-test/opt/dell
# $ export [email protected]:/opt/dell
#
# # Create the barclamps/ subdirectory so that rsyncing crowbar.yml files works
# $ ssh [email protected] mkdir -p /opt/dell/barclamps
#
# # Launch the guard watcher:
# $ bundle exec guard -G Guardfile.tree-merge
#
# Further info
# ------------
#
# More about Guard at https://github.com/guard/guard#readme
TARGET = ENV['GUARD_RSYNC_TARGET'] || '/tmp/crowbar-dev-test/opt/dell'
# This has to match how barclamp_install.rb (in 2.0) and
# barclamp_mgmt_lib.rb (< 2.0) do the tree merging.
#
# FIXME: The tree merging logic is release-specific, so this file
# should probably be moved to releases/$release. But by the time it
# starts mattering, hopefully we won't be doing all development on the
# master branch of this repo.
BC_FILTERS = [
"+ /BDD/",
"+ /bin/",
"+ /chef/",
"+ /crowbar_framework/",
# FIXME: barclamp_install.rb in 2.0 does fancy stuff
#"+ /crowbar_engine/",
"+ /doc/",
"+ /etc/",
"+ /updates/",
"- /*",
]
GENERAL_EXCLUDES = [
"- .#*#",
"- *.swp",
]
def guard_bc_dir(bc_dir)
guard_opts = {
:input => bc_dir + '/',
:output => TARGET,
:excludes => BC_FILTERS + GENERAL_EXCLUDES,
}
guard('rsync', guard_opts) do
watch(%r{^#{bc_dir}/.+})
end
end
def guard_bc_yaml(bc_dir)
bc_yaml = bc_dir + '/crowbar.yml'
return unless File.exist? bc_yaml
guard_opts = {
:input => bc_yaml,
:output => TARGET + '/' + bc_dir + '/',
}
guard('rsync', guard_opts) do
watch("#{bc_dir}/crowbar.yml")
end
end
group :barclamps do
Dir.glob('barclamps/*').each do |bc_dir|
guard_bc_dir bc_dir
guard_bc_yaml bc_dir
end
end