bunchr 0.1.1 → 0.1.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (46) hide show
  1. data/README.md +148 -116
  2. data/bunchr.gemspec +1 -1
  3. data/lib/bunchr/version.rb +1 -1
  4. data/lib/bunchr.rb +2 -0
  5. data/pkg/bunchr-0.1.1/README.md +355 -0
  6. data/pkg/bunchr-0.1.1/Rakefile +9 -0
  7. data/pkg/bunchr-0.1.1/TODO +7 -0
  8. data/pkg/bunchr-0.1.1/bunchr.gemspec +34 -0
  9. data/pkg/bunchr-0.1.1/doc/Bunchr/Logger.html +201 -0
  10. data/pkg/bunchr-0.1.1/doc/Bunchr/Ohai.html +201 -0
  11. data/pkg/bunchr-0.1.1/doc/Bunchr/Packages.html +1840 -0
  12. data/pkg/bunchr-0.1.1/doc/Bunchr/Software.html +1727 -0
  13. data/pkg/bunchr-0.1.1/doc/Bunchr/Utils.html +334 -0
  14. data/pkg/bunchr-0.1.1/doc/Bunchr.html +124 -0
  15. data/pkg/bunchr-0.1.1/doc/_index.html +181 -0
  16. data/pkg/bunchr-0.1.1/doc/class_list.html +47 -0
  17. data/pkg/bunchr-0.1.1/doc/css/common.css +1 -0
  18. data/pkg/bunchr-0.1.1/doc/css/full_list.css +55 -0
  19. data/pkg/bunchr-0.1.1/doc/css/style.css +322 -0
  20. data/pkg/bunchr-0.1.1/doc/file.README.html +376 -0
  21. data/pkg/bunchr-0.1.1/doc/file_list.html +49 -0
  22. data/pkg/bunchr-0.1.1/doc/frames.html +13 -0
  23. data/pkg/bunchr-0.1.1/doc/index.html +376 -0
  24. data/pkg/bunchr-0.1.1/doc/js/app.js +205 -0
  25. data/pkg/bunchr-0.1.1/doc/js/full_list.js +173 -0
  26. data/pkg/bunchr-0.1.1/doc/js/jquery.js +16 -0
  27. data/pkg/bunchr-0.1.1/doc/method_list.html +438 -0
  28. data/pkg/bunchr-0.1.1/doc/top-level-namespace.html +105 -0
  29. data/pkg/bunchr-0.1.1/example_recipes/autoconf.rake +18 -0
  30. data/pkg/bunchr-0.1.1/example_recipes/libyaml.rake +18 -0
  31. data/pkg/bunchr-0.1.1/example_recipes/openssl.rake +54 -0
  32. data/pkg/bunchr-0.1.1/example_recipes/ruby.rake +38 -0
  33. data/pkg/bunchr-0.1.1/example_recipes/sensu.rake +18 -0
  34. data/pkg/bunchr-0.1.1/example_recipes/sensu_bin_stubs.rake +17 -0
  35. data/pkg/bunchr-0.1.1/example_recipes/sensu_configs.rake +30 -0
  36. data/pkg/bunchr-0.1.1/example_recipes/sensu_dashboard.rake +17 -0
  37. data/pkg/bunchr-0.1.1/example_recipes/zlib.rake +32 -0
  38. data/pkg/bunchr-0.1.1/lib/bunchr/logger.rb +18 -0
  39. data/pkg/bunchr-0.1.1/lib/bunchr/ohai.rb +18 -0
  40. data/pkg/bunchr-0.1.1/lib/bunchr/packages.rb +176 -0
  41. data/pkg/bunchr-0.1.1/lib/bunchr/software.rb +164 -0
  42. data/pkg/bunchr-0.1.1/lib/bunchr/utils.rb +36 -0
  43. data/pkg/bunchr-0.1.1/lib/bunchr/version.rb +3 -0
  44. data/pkg/bunchr-0.1.1/lib/bunchr.rb +44 -0
  45. data/pkg/bunchr-0.1.1.gem +0 -0
  46. metadata +123 -62
data/README.md CHANGED
@@ -29,7 +29,7 @@ to install and should not interfere with any other Ruby apps or scripts on the
29
29
  server.
30
30
 
31
31
  About the time the Sensu project was discussing a new packaging approach,
32
- (Adam Jacob) from [Opscode/Chef](http://opscode.com/) took notice and suggested
32
+ [Adam Jacob](http://twitter.com/adamhjk) from [Opscode/Chef](http://opscode.com/) took notice and suggested
33
33
  a slightly different approach that achieved the same goals. The approach was
34
34
  called 'omnibus' and was already in use at Opscode to produce a simple and
35
35
  uniform installer for Chef.
@@ -48,12 +48,25 @@ Installation
48
48
  gem install bunchr
49
49
  ```
50
50
 
51
+ Usage
52
+ -----
53
+
54
+ The simplest workflow is:
55
+
56
+ 1. Create a `Rakefile`
57
+ 2. Define 1 or more `Bunchr::Software` objects
58
+ 3. Define 1 `Bunchr::Packages` object.
59
+ 4. run `rake`
60
+ 5. receive new packages (.rpm or .deb, depending on platform) !
61
+
62
+ For details on the DSL and examples, continue reading.
63
+
51
64
  DSL Overview
52
65
  ------------
53
66
 
54
67
  A typical Bunchr project is comprised of one or more `Bunchr::Software` objects
55
- and a single `Bunchr::Packages` object. Define these all in a `Rakefile` or
56
- separate them into files.
68
+ and a single `Bunchr::Packages` object. Define these all in a single `Rakefile` or
69
+ separate them into files for readability and re-use.
57
70
 
58
71
  `Software` objects are responsible for downloading, building, and installing
59
72
  a single software component, such as `zlib` or `ruby`. `Software` objects
@@ -74,123 +87,19 @@ Currently supported package types:
74
87
  * .deb
75
88
  * .rpm
76
89
 
77
- ### Software DSL
78
-
79
- * Example software recipes: https://github.com/joemiller/bunchr/tree/master/example_recipes
80
-
81
- Example recipe for building and installing `ruby`:
82
-
83
- ```
84
- Bunchr::Software.new do |t|
85
- t.name = 'ruby'
86
- t.version = '1.9.3-p125'
87
-
88
- t.depends_on('autoconf')
89
- t.depends_on('zlib')
90
- t.depends_on('openssl')
91
- t.depends_on('libyaml')
92
-
93
- install_prefix = "#{Bunchr.install_dir}/embedded"
94
-
95
- os = t.ohai['os']
96
- arch = t.ohai['kernel']['machine']
97
-
98
- t.download_commands << "curl -O http://ftp.ruby-lang.org/pub/ruby/1.9/ruby-1.9.3-p125.tar.gz"
99
- t.download_commands << "tar xfvz ruby-1.9.3-p125.tar.gz"
100
-
101
- if os == 'darwin' && arch == 'x86_64'
102
- t.build_environment['LDFLAGS'] = "-arch x86_64 -R#{install_prefix}/lib -L#{install_prefix}/lib -I#{install_prefix}/include"
103
- t.build_environment['CFLAGS'] = "-arch x86_64 -m64 -L#{install_prefix}/lib -I#{install_prefix}/include"
104
- elsif os == 'linux'
105
- t.build_environment['LDFLAGS'] = "-Wl,-rpath #{install_prefix}/lib -L#{install_prefix}/lib -I#{install_prefix}/include"
106
- t.build_environment['CFLAGS'] = "-L#{install_prefix}/lib -I#{install_prefix}/include"
107
- elsif os == 'solaris2'
108
- t.build_environment['LDFLAGS'] = "-R#{install_prefix}/lib -L#{install_prefix}/lib -I#{install_prefix}/include"
109
- t.build_environment['CFLAGS'] = "-L#{install_prefix}/lib -I#{install_prefix}/include"
110
- end
111
-
112
- t.build_commands << "./configure --prefix=#{install_prefix} \
113
- --with-opt-dir=#{install_prefix} \
114
- --enable-shared \
115
- --disable-install-doc"
116
- t.build_commands << "make"
117
-
118
- t.install_commands << "make install"
119
-
120
- CLEAN << install_prefix
121
- end
122
- ```
123
-
124
- * `t.name` - Required. Name of the software component.
125
-
126
- * `t.version` - Optional. Version of the software component.
127
-
128
- * `t.depends_on(name)` - Optional. This is used to tell Bunchr that other
129
- `Software` components should be built before this one.
130
-
131
- * `t.ohai` - This provides access to the `Bunchr::Ohai` object which contains
132
- Ohai data about the system. By default, only the `platform` and `os` plugins
133
- are loaded. Since you have direct access to the Ohai object, other plugins
134
- can be loaded by calling `t.ohai.require_plugin`
135
-
136
- * `t.download_commands` - An array of shell commands used to download and
137
- uncompress the source. You could also do a `git clone ..` here. These commands
138
- are executed in the `download_dir` which is as `#{Bunchr.build_dir}/#{t.name}`.
139
- The `download_dir` cannot be changed.
140
-
141
- * `t.build_commands` - An array of shell commands used to compile the downloaded
142
- source. These commands are executed in the directory defined by
143
- `t.work_dir` which will be automatically determined from:
144
- 1) `#{download_dir}/#{t.name}-#{t.version}` (common for most tarballs), or
145
- 2) `#{download_dir}/#{t.name}` (if no `t.version` set), or
146
- 3) explicitly set by calling `t.work_dir = '/some/absolute/path'`
147
-
148
- * `t.install_commands` - An array of shell commands used to download and
149
- uncompress the source. You could also do a `git clone ..` here. These commands
150
- are executed in `t.work_dir` directory.
151
-
152
- * `CLEAN` - Optional. This is an array of files and directories that should be deleted
153
- when `rake clean` is executed.
154
-
155
- `download_commands`, `build_commands`, and `install_commands` are all optional,
156
- but unless one of them contains some commands your `Software` object won't be
157
- doing anything useful.
158
-
159
- If any of `download_commands`, `build_commands`, or `install_commands` exit
160
- with a non-zero status, the entire Bunchr process will stop
161
- and print any STDOUT or STDERR from the failed command to the Logger.
162
-
163
- Bunchr will keep track of what has succeeded so that you can restart a failed
164
- build after fixing an error. This can save quite a bit of time during package
165
- development, but you should consider doing a full `rake clean` before building
166
- any official packages.
167
-
168
-
169
- All tasks created by a `Bunchr::Software` object are prefixed into the
170
- `software:` namespace. To see the generated tasks:
171
-
172
- ```
173
- $ rake -T software:ruby
174
- rake software:ruby # Download, build, and install ruby 1.9.3-p125
175
- rake software:ruby:build # Build ruby 1.9.3-p125
176
- rake software:ruby:download # Download ruby 1.9.3-p125
177
- rake software:ruby:install # Install ruby 1.9.3-p125
178
- ```
179
-
180
- `Software` recipes can be defined directly in the Rakefile or they can
181
- be separated into individual files and loaded via `Bunchr.load_recipes(files)`.
182
-
183
90
  ### Packages DSL
184
91
 
185
92
  A project will typically only contain a single `Bunchr::Packages` object which
186
- is essentially a wrapper around `fpm` to create a single package. The Ohai
187
- `platform` data will be used to determined what type of packages can be built
188
- on the current system. Typically you would run the same Bunchr code on a
93
+ is essentially a wrapper around `fpm`.
94
+
95
+ The Ohai `platform` data will be used to determined what type of packages can be
96
+ built on the current system. Typically you would run the same Bunchr code on a
189
97
  Debian based box to build the .deb, and a Redhat based box to build the .rpm.
98
+ Vagrant can help with this.
190
99
 
191
100
  Example `Rakefile`:
192
101
 
193
- ```
102
+ ```ruby
194
103
  require 'bunchr'
195
104
 
196
105
  Bunchr.build_dir = '/tmp/build'
@@ -303,6 +212,114 @@ rake packages:sensu:build_tarball # Build tarball: sensu-0.9.5-1-x86_64.tar.gz
303
212
  The main task is `packages:#{name}`. Exec this task to create all relevant
304
213
  packages.
305
214
 
215
+
216
+ ### Software DSL
217
+
218
+ * Example software recipes: https://github.com/joemiller/bunchr/tree/master/example_recipes
219
+
220
+ Example recipe for building and installing `ruby`:
221
+
222
+ ```ruby
223
+ Bunchr::Software.new do |t|
224
+ t.name = 'ruby'
225
+ t.version = '1.9.3-p125'
226
+
227
+ t.depends_on('autoconf')
228
+ t.depends_on('zlib')
229
+ t.depends_on('openssl')
230
+ t.depends_on('libyaml')
231
+
232
+ install_prefix = "#{Bunchr.install_dir}/embedded"
233
+
234
+ os = t.ohai['os']
235
+ arch = t.ohai['kernel']['machine']
236
+
237
+ t.download_commands << "curl -O http://ftp.ruby-lang.org/pub/ruby/1.9/ruby-1.9.3-p125.tar.gz"
238
+ t.download_commands << "tar xfvz ruby-1.9.3-p125.tar.gz"
239
+
240
+ if os == 'darwin' && arch == 'x86_64'
241
+ t.build_environment['LDFLAGS'] = "-arch x86_64 -R#{install_prefix}/lib -L#{install_prefix}/lib -I#{install_prefix}/include"
242
+ t.build_environment['CFLAGS'] = "-arch x86_64 -m64 -L#{install_prefix}/lib -I#{install_prefix}/include"
243
+ elsif os == 'linux'
244
+ t.build_environment['LDFLAGS'] = "-Wl,-rpath #{install_prefix}/lib -L#{install_prefix}/lib -I#{install_prefix}/include"
245
+ t.build_environment['CFLAGS'] = "-L#{install_prefix}/lib -I#{install_prefix}/include"
246
+ elsif os == 'solaris2'
247
+ t.build_environment['LDFLAGS'] = "-R#{install_prefix}/lib -L#{install_prefix}/lib -I#{install_prefix}/include"
248
+ t.build_environment['CFLAGS'] = "-L#{install_prefix}/lib -I#{install_prefix}/include"
249
+ end
250
+
251
+ t.build_commands << "./configure --prefix=#{install_prefix} \
252
+ --with-opt-dir=#{install_prefix} \
253
+ --enable-shared \
254
+ --disable-install-doc"
255
+ t.build_commands << "make"
256
+
257
+ t.install_commands << "make install"
258
+
259
+ CLEAN << install_prefix
260
+ end
261
+ ```
262
+
263
+ * `t.name` - Required. Name of the software component.
264
+
265
+ * `t.version` - Optional. Version of the software component.
266
+
267
+ * `t.depends_on(name)` - Optional. This is used to tell Bunchr that other
268
+ `Software` components should be built before this one.
269
+
270
+ * `t.ohai` - This provides access to the `Bunchr::Ohai` object which contains
271
+ Ohai data about the system. By default, only the `platform` and `os` plugins
272
+ are loaded. Since you have direct access to the Ohai object, other plugins
273
+ can be loaded by calling `t.ohai.require_plugin`
274
+
275
+ * `t.download_commands` - An array of shell commands used to download and
276
+ uncompress the source. You could also do a `git clone ..` here. These commands
277
+ are executed in the `download_dir` which is `#{Bunchr.build_dir}/#{t.name}`.
278
+ The `download_dir` cannot be changed.
279
+
280
+ * `t.build_commands` - An array of shell commands used to compile the downloaded
281
+ source. These commands are executed in the directory defined by
282
+ `t.work_dir` which will be automatically determined from:
283
+ 1) `#{download_dir}/#{t.name}-#{t.version}` (common for most tarballs), or
284
+ 2) `#{download_dir}/#{t.name}` (if no `t.version` set), or
285
+ 3) explicitly set by calling `t.work_dir = '/some/absolute/path'`
286
+
287
+ * `t.install_commands` - An array of shell commands used to download and
288
+ uncompress the source. You could also do a `git clone ..` here. These commands
289
+ are executed in `t.work_dir` directory.
290
+
291
+ * `CLEAN` - Optional. This is an array of files and directories that should be deleted
292
+ when `rake clean` is executed.
293
+
294
+ `download_commands`, `build_commands`, and `install_commands` are all optional,
295
+ but unless one of them contains some commands your `Software` object won't be
296
+ doing anything useful.
297
+
298
+ If any of `download_commands`, `build_commands`, or `install_commands` exit
299
+ with a non-zero status, the entire Bunchr process will stop
300
+ and print any STDOUT or STDERR from the failed command to the Logger.
301
+
302
+ Bunchr will keep track of what has succeeded so that you can restart a failed
303
+ build after fixing an error. This can save quite a bit of time during package
304
+ development, but you should consider doing a full `rake clean` before building
305
+ any official packages.
306
+
307
+
308
+ All tasks created by a `Bunchr::Software` object are prefixed into the
309
+ `software:` namespace. To see the generated tasks:
310
+
311
+ ```
312
+ $ rake -T software:ruby
313
+ rake software:ruby # Download, build, and install ruby 1.9.3-p125
314
+ rake software:ruby:build # Build ruby 1.9.3-p125
315
+ rake software:ruby:download # Download ruby 1.9.3-p125
316
+ rake software:ruby:install # Install ruby 1.9.3-p125
317
+ ```
318
+
319
+ `Software` recipes can be defined directly in the Rakefile or they can
320
+ be separated into individual files and loaded via `Bunchr.load_recipes(files)`.
321
+
322
+
306
323
  Integration with Vagrant
307
324
  ------------------------
308
325
 
@@ -318,6 +335,21 @@ Author
318
335
 
319
336
  * [Joe Miller](https://twitter.com/miller_joe) - http://joemiller.me / https://github.com/joemiller
320
337
 
321
- Licensing
322
- ---------
323
- todo, apache
338
+ License
339
+ -------
340
+
341
+ Author:: Joe Miller (<joeym@joeym.net>)
342
+ Copyright:: Copyright (c) 2012 Joe Miller
343
+ License:: Apache License, Version 2.0
344
+
345
+ Licensed under the Apache License, Version 2.0 (the "License");
346
+ you may not use this file except in compliance with the License.
347
+ You may obtain a copy of the License at
348
+
349
+ http://www.apache.org/licenses/LICENSE-2.0
350
+
351
+ Unless required by applicable law or agreed to in writing, software
352
+ distributed under the License is distributed on an "AS IS" BASIS,
353
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
354
+ See the License for the specific language governing permissions and
355
+ limitations under the License.
data/bunchr.gemspec CHANGED
@@ -27,7 +27,7 @@ EOF
27
27
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
28
28
  s.specification_version = 3 if s.respond_to? :specification_version
29
29
 
30
- s.add_dependency("rake", ">= 0.8.0")
30
+ s.add_dependency("rake", ">= 0.8.7")
31
31
  s.add_dependency("ohai")
32
32
  s.add_dependency("systemu")
33
33
  s.add_dependency("fpm", "~> 0.4.6")
@@ -1,3 +1,3 @@
1
1
  module Bunchr
2
- VERSION = '0.1.1'
2
+ VERSION = '0.1.2'
3
3
  end
data/lib/bunchr.rb CHANGED
@@ -11,6 +11,8 @@ module Bunchr
11
11
  @@install_dir = nil
12
12
 
13
13
  class << self
14
+ include Rake::DSL if RAKEVERSION >= '0.9.0'
15
+
14
16
  def install_dir
15
17
  if @@install_dir.nil?
16
18
  raise "You must set `Bunchr.install_dir = '/path'` in your Rakefile."
@@ -0,0 +1,355 @@
1
+ Bunchr
2
+ ======
3
+
4
+ Overview
5
+ --------
6
+
7
+ Bunchr is a Rake/Ruby-based DSL for building and bundling complex software
8
+ projects into various package formats, ie: RPM, DEB, etc (packaging performed
9
+ by [fpm](https://github.com/jordansissel/fpm).
10
+
11
+ Originally developed to create "omnibus" style packages that include an entire
12
+ ruby stack along with one or more gems, but useful for general compilation and
13
+ packaging as well.
14
+
15
+ It is typically intended to be used in conjunction with [Vagrant](http://vagrantup.com)
16
+ but can be used without Vagrant as well.
17
+
18
+ History
19
+ -------
20
+
21
+ Bunchr was conceived as a tool to help the [Sensu](https://github.com/sensu)
22
+ monitoring project find a better way to create packages that would be as
23
+ easy as possible to deploy on a variety of platforms with minimal friction and
24
+ with little or no knowledge about the idiosyncrasies of the Ruby universe
25
+ (version incompatibilities, gem conflicts, etc). This was particularly desirable
26
+ for Sensu because one of the components is an agent that will be installed
27
+ on most or all servers in an infrastructure. Thus, the package should be easy
28
+ to install and should not interfere with any other Ruby apps or scripts on the
29
+ server.
30
+
31
+ About the time the Sensu project was discussing a new packaging approach,
32
+ [Adam Jacob](http://twitter.com/adamhjk) from [Opscode/Chef](http://opscode.com/) took notice and suggested
33
+ a slightly different approach that achieved the same goals. The approach was
34
+ called 'omnibus' and was already in use at Opscode to produce a simple and
35
+ uniform installer for Chef.
36
+
37
+ Opscode was using a Clojure-based tool at the time called [omnibus](https://github.com/opscode/omnibus)
38
+ and were working on a Ruby-based version of omnibus as well.
39
+
40
+ However, the Ruby based Omnibus was not available at the time, so Bunchr was
41
+ created and it re-implements many of the concepts of the Clojure-based Omnibus
42
+ but on top of Ruby / Rake with a few differences.
43
+
44
+ Installation
45
+ ------------
46
+
47
+ ```
48
+ gem install bunchr
49
+ ```
50
+
51
+ Usage
52
+ -----
53
+
54
+ The simplest workflow is:
55
+
56
+ 1. Create a `Rakefile`
57
+ 2. Define 1 or more `Bunchr::Software` objects
58
+ 3. Define 1 `Bunchr::Packages` object.
59
+ 4. run `rake`
60
+ 5. receive new packages (.rpm or .deb, depending on platform) !
61
+
62
+ For details on the DSL and examples, continue reading.
63
+
64
+ DSL Overview
65
+ ------------
66
+
67
+ A typical Bunchr project is comprised of one or more `Bunchr::Software` objects
68
+ and a single `Bunchr::Packages` object. Define these all in a single `Rakefile` or
69
+ separate them into files for readability and re-use.
70
+
71
+ `Software` objects are responsible for downloading, building, and installing
72
+ a single software component, such as `zlib` or `ruby`. `Software` objects
73
+ support platform-specific compilation options by making Ohai data available
74
+ for decision making.
75
+
76
+ `Packages` objects are used to combine `Software` objects into a single package.
77
+ It will automatically try to generate any packages supported by the current
78
+ platform, for example, RPMs will be built if the platform supports it, DEB
79
+ will be built if the platform supports it.
80
+
81
+ The goal is to be able to use a single code base to build _and_ package a
82
+ project on multiple platforms.
83
+
84
+ Currently supported package types:
85
+
86
+ * tar.gz
87
+ * .deb
88
+ * .rpm
89
+
90
+ ### Packages DSL
91
+
92
+ A project will typically only contain a single `Bunchr::Packages` object which
93
+ is essentially a wrapper around `fpm`.
94
+
95
+ The Ohai `platform` data will be used to determined what type of packages can be
96
+ built on the current system. Typically you would run the same Bunchr code on a
97
+ Debian based box to build the .deb, and a Redhat based box to build the .rpm.
98
+ Vagrant can help with this.
99
+
100
+ Example `Rakefile`:
101
+
102
+ ```ruby
103
+ require 'bunchr'
104
+
105
+ Bunchr.build_dir = '/tmp/build'
106
+ Bunchr.install_dir = '/opt/sensu'
107
+
108
+ Bunchr.load_recipes Dir['recipes/**/*.rake']
109
+
110
+ Bunchr::Packages.new do |t|
111
+ t.name = 'sensu'
112
+ t.version = ENV['SENSU_VERSION'] || '0.9.5'
113
+ t.iteration = ENV['BUILD_NUMBER'] || '1'
114
+
115
+ t.category = 'Monitoring'
116
+ t.license = 'MIT License'
117
+ t.vendor = 'Sonian Inc.'
118
+ t.url = 'https://github.com/sonian/sensu'
119
+ t.description = 'A monitoring framework that aims to be simple, malleable, and scalable. Publish/subscribe model.'
120
+
121
+ case t.ohai.platform_family
122
+ when 'debian'
123
+ t.scripts[:after_install] = 'pkg_scripts/deb/postinst'
124
+ t.scripts[:before_remove] = 'pkg_scripts/deb/prerm'
125
+ t.scripts[:after_remove] = 'pkg_scripts/deb/postrm'
126
+ when 'rhel', 'fedora'
127
+ t.scripts[:before_install] = 'pkg_scripts/rpm/pre'
128
+ t.scripts[:after_install] = 'pkg_scripts/rpm/post'
129
+ t.scripts[:before_remove] = 'pkg_scripts/rpm/preun'
130
+ end
131
+
132
+ t.include_software('ruby')
133
+ t.include_software('sensu')
134
+ t.include_software('sensu_dashboard')
135
+ t.include_software('sensu_configs')
136
+ t.include_software('sensu_bin_stubs')
137
+
138
+ t.files << Bunchr.install_dir # /opt/sensu
139
+ t.files << '/usr/share/sensu'
140
+ t.files << '/var/log/sensu'
141
+
142
+ t.files << '/etc/init.d/sensu-api'
143
+ t.files << '/etc/init.d/sensu-client'
144
+ t.files << '/etc/init.d/sensu-server'
145
+ t.files << '/etc/init.d/sensu-dashboard'
146
+
147
+ # need to enumerate config files for fpm
148
+ # these are installed from recipe/sensu_configs.rake
149
+ t.config_files << "/etc/sensu/handlers/default"
150
+ t.config_files << "/etc/sensu/conf.d/client.json"
151
+ t.config_files << "/etc/sensu/conf.d/checks.json"
152
+ t.config_files << "/etc/sensu/conf.d/handlers.json"
153
+ t.config_files << "/etc/sensu/config.json"
154
+
155
+ t.config_files << '/etc/logrotate.d/sensu'
156
+ end
157
+
158
+ # default task executed when `rake` is run with no args.
159
+ task :default => ['packages:sensu']
160
+ ```
161
+
162
+ Let's break it all down:
163
+
164
+ * `Bunchr.build_dir` - Required. This variable is available to all
165
+ `Bunchr::Software` recipes specifying a temporary directory used for
166
+ downloading and compiling.
167
+
168
+ * `Bunchr.install_dir` - Required. This variable is available to all
169
+ `Bunchr::Software` recipes. It will typically be the base directory
170
+ where all software is installed.
171
+
172
+ The following variables are used to drive `fpm` when building packages:
173
+
174
+ * `t.name`, `t.version`, `t.iteration` - Required.
175
+ Used by `fpm` to construct the package names, ie:
176
+ `name-version-iteration-arch.rpm`
177
+
178
+ * `t.arch` - Optional. Can be used to override the default detected
179
+ architecture, eg: `all` or `noarch`.
180
+
181
+ * `t.category`, `t.license`, `t.vendor`, `t.url`, `t.description` -
182
+ Optional. Package metadata.
183
+
184
+ * `t.include_software(name)` - Optional. This is used to tell Bunchr what
185
+ `Software` components should be built and installed before creating
186
+ packages.
187
+
188
+ * `t.scripts` - Optional. A hash with keys: `:after_install`, `:before_install`,
189
+ `:after_remove`, and `:before_remove`. The specified files will be included
190
+ with the packages.
191
+
192
+ * `t.files` - Required. An array of files and directories to include.
193
+
194
+ * `t.config_files` - Optional. An array of files that will be marked as
195
+ configuration files (if supported by the underlying package type).
196
+ Config_files are automatically added to the `t.files` array.
197
+
198
+ NOTE: you must specify individual files, not directories.
199
+
200
+ All tasks created by a `Bunchr::Packages` object are prefixed into the
201
+ `packages:` namespace. To see the generated tasks:
202
+
203
+ ```
204
+ $ rake -T packages
205
+ rake packages:sensu # Create bunchr packages for sensu 0.9.5-1
206
+ rake packages:sensu:build # Build all packages: sensu-0.9.5-1-x86_64
207
+ rake packages:sensu:build_deb # Build deb: sensu-0.9.5-1-x86_64
208
+ rake packages:sensu:build_rpm # Build RPM: sensu-0.9.5-1-x86_64
209
+ rake packages:sensu:build_tarball # Build tarball: sensu-0.9.5-1-x86_64.tar.gz
210
+ ```
211
+
212
+ The main task is `packages:#{name}`. Exec this task to create all relevant
213
+ packages.
214
+
215
+
216
+ ### Software DSL
217
+
218
+ * Example software recipes: https://github.com/joemiller/bunchr/tree/master/example_recipes
219
+
220
+ Example recipe for building and installing `ruby`:
221
+
222
+ ```ruby
223
+ Bunchr::Software.new do |t|
224
+ t.name = 'ruby'
225
+ t.version = '1.9.3-p125'
226
+
227
+ t.depends_on('autoconf')
228
+ t.depends_on('zlib')
229
+ t.depends_on('openssl')
230
+ t.depends_on('libyaml')
231
+
232
+ install_prefix = "#{Bunchr.install_dir}/embedded"
233
+
234
+ os = t.ohai['os']
235
+ arch = t.ohai['kernel']['machine']
236
+
237
+ t.download_commands << "curl -O http://ftp.ruby-lang.org/pub/ruby/1.9/ruby-1.9.3-p125.tar.gz"
238
+ t.download_commands << "tar xfvz ruby-1.9.3-p125.tar.gz"
239
+
240
+ if os == 'darwin' && arch == 'x86_64'
241
+ t.build_environment['LDFLAGS'] = "-arch x86_64 -R#{install_prefix}/lib -L#{install_prefix}/lib -I#{install_prefix}/include"
242
+ t.build_environment['CFLAGS'] = "-arch x86_64 -m64 -L#{install_prefix}/lib -I#{install_prefix}/include"
243
+ elsif os == 'linux'
244
+ t.build_environment['LDFLAGS'] = "-Wl,-rpath #{install_prefix}/lib -L#{install_prefix}/lib -I#{install_prefix}/include"
245
+ t.build_environment['CFLAGS'] = "-L#{install_prefix}/lib -I#{install_prefix}/include"
246
+ elsif os == 'solaris2'
247
+ t.build_environment['LDFLAGS'] = "-R#{install_prefix}/lib -L#{install_prefix}/lib -I#{install_prefix}/include"
248
+ t.build_environment['CFLAGS'] = "-L#{install_prefix}/lib -I#{install_prefix}/include"
249
+ end
250
+
251
+ t.build_commands << "./configure --prefix=#{install_prefix} \
252
+ --with-opt-dir=#{install_prefix} \
253
+ --enable-shared \
254
+ --disable-install-doc"
255
+ t.build_commands << "make"
256
+
257
+ t.install_commands << "make install"
258
+
259
+ CLEAN << install_prefix
260
+ end
261
+ ```
262
+
263
+ * `t.name` - Required. Name of the software component.
264
+
265
+ * `t.version` - Optional. Version of the software component.
266
+
267
+ * `t.depends_on(name)` - Optional. This is used to tell Bunchr that other
268
+ `Software` components should be built before this one.
269
+
270
+ * `t.ohai` - This provides access to the `Bunchr::Ohai` object which contains
271
+ Ohai data about the system. By default, only the `platform` and `os` plugins
272
+ are loaded. Since you have direct access to the Ohai object, other plugins
273
+ can be loaded by calling `t.ohai.require_plugin`
274
+
275
+ * `t.download_commands` - An array of shell commands used to download and
276
+ uncompress the source. You could also do a `git clone ..` here. These commands
277
+ are executed in the `download_dir` which is `#{Bunchr.build_dir}/#{t.name}`.
278
+ The `download_dir` cannot be changed.
279
+
280
+ * `t.build_commands` - An array of shell commands used to compile the downloaded
281
+ source. These commands are executed in the directory defined by
282
+ `t.work_dir` which will be automatically determined from:
283
+ 1) `#{download_dir}/#{t.name}-#{t.version}` (common for most tarballs), or
284
+ 2) `#{download_dir}/#{t.name}` (if no `t.version` set), or
285
+ 3) explicitly set by calling `t.work_dir = '/some/absolute/path'`
286
+
287
+ * `t.install_commands` - An array of shell commands used to download and
288
+ uncompress the source. You could also do a `git clone ..` here. These commands
289
+ are executed in `t.work_dir` directory.
290
+
291
+ * `CLEAN` - Optional. This is an array of files and directories that should be deleted
292
+ when `rake clean` is executed.
293
+
294
+ `download_commands`, `build_commands`, and `install_commands` are all optional,
295
+ but unless one of them contains some commands your `Software` object won't be
296
+ doing anything useful.
297
+
298
+ If any of `download_commands`, `build_commands`, or `install_commands` exit
299
+ with a non-zero status, the entire Bunchr process will stop
300
+ and print any STDOUT or STDERR from the failed command to the Logger.
301
+
302
+ Bunchr will keep track of what has succeeded so that you can restart a failed
303
+ build after fixing an error. This can save quite a bit of time during package
304
+ development, but you should consider doing a full `rake clean` before building
305
+ any official packages.
306
+
307
+
308
+ All tasks created by a `Bunchr::Software` object are prefixed into the
309
+ `software:` namespace. To see the generated tasks:
310
+
311
+ ```
312
+ $ rake -T software:ruby
313
+ rake software:ruby # Download, build, and install ruby 1.9.3-p125
314
+ rake software:ruby:build # Build ruby 1.9.3-p125
315
+ rake software:ruby:download # Download ruby 1.9.3-p125
316
+ rake software:ruby:install # Install ruby 1.9.3-p125
317
+ ```
318
+
319
+ `Software` recipes can be defined directly in the Rakefile or they can
320
+ be separated into individual files and loaded via `Bunchr.load_recipes(files)`.
321
+
322
+
323
+ Integration with Vagrant
324
+ ------------------------
325
+
326
+ * TODO. maybe link to sensu-bunchr here.
327
+
328
+ Other Examples
329
+ --------------
330
+
331
+ * TODO. maybe link to sensu-bunchr here, or a complete example of fpm
332
+
333
+ Author
334
+ ------
335
+
336
+ * [Joe Miller](https://twitter.com/miller_joe) - http://joemiller.me / https://github.com/joemiller
337
+
338
+ License
339
+ -------
340
+
341
+ Author:: Joe Miller (<joeym@joeym.net>)
342
+ Copyright:: Copyright (c) 2012 Joe Miller
343
+ License:: Apache License, Version 2.0
344
+
345
+ Licensed under the Apache License, Version 2.0 (the "License");
346
+ you may not use this file except in compliance with the License.
347
+ You may obtain a copy of the License at
348
+
349
+ http://www.apache.org/licenses/LICENSE-2.0
350
+
351
+ Unless required by applicable law or agreed to in writing, software
352
+ distributed under the License is distributed on an "AS IS" BASIS,
353
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
354
+ See the License for the specific language governing permissions and
355
+ limitations under the License.