fpm-cookery 0.13.0 → 0.14.0

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore CHANGED
@@ -8,3 +8,6 @@ tmp-build/
8
8
  tmp-dest/
9
9
  .buildpath
10
10
  .project
11
+ .vagrant
12
+ Vagrantfile
13
+ /vendor
data/CHANGELOG.md CHANGED
@@ -1,3 +1,14 @@
1
+ # v0.14.0 (2013-05-31)
2
+ * Install dependencies via Puppet. (andytinycat)
3
+ * Add install-deps action to install dependencies. (andytinycat)
4
+ * Fix log message. (ryansch)
5
+ * Add a `patch` helper method to apply patches. (piavlo)
6
+ * Support for [Omnibus](http://wiki.opscode.com/display/chef/Omnibus+Information)-style
7
+ packaging. (andytinycat)
8
+ * Add recipe to build a fat (omnibus-style) package for fpm-cookery.
9
+ * Add `:args` option for the curl handler. (torrancew)
10
+ * Add `-V` command line option to show fpm-cookery and fpm versions.
11
+
1
12
  # v0.13.0 (2013-01-28)
2
13
  * Make local file source behave like the remote url source. (#14)
3
14
 
data/Gemfile CHANGED
@@ -1,3 +1,3 @@
1
- source :rubygems
1
+ source "https://rubygems.org"
2
2
 
3
3
  gemspec
data/LICENSE ADDED
@@ -0,0 +1,23 @@
1
+ Copyright (c) 2009-2012 Max Howell and other contributors.
2
+ Copyright (c) 2011 Bernd Ahlers
3
+
4
+ Redistribution and use in source and binary forms, with or without
5
+ modification, are permitted provided that the following conditions
6
+ are met:
7
+
8
+ 1. Redistributions of source code must retain the above copyright
9
+ notice, this list of conditions and the following disclaimer.
10
+ 2. Redistributions in binary form must reproduce the above copyright
11
+ notice, this list of conditions and the following disclaimer in the
12
+ documentation and/or other materials provided with the distribution.
13
+
14
+ THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
15
+ IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
16
+ OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
17
+ IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
18
+ INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
19
+ NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
20
+ DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
21
+ THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
22
+ (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
23
+ THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
data/README.md CHANGED
@@ -47,11 +47,13 @@ __fpm-cookery__ is my attempt to build such a tool.
47
47
  * Package creation via __fpm__.
48
48
  * Standalone recipe trees/books/you name it. No need to put the recipes into
49
49
  the __fpm-cookery__ source tree.
50
+ * Can build [Omnibus](http://wiki.opscode.com/display/chef/Omnibus+Information)
51
+ style packages (allows you to embed many builds into the same package -
52
+ used by the Opscode folks to build an embedded Ruby and the gems for Chef into
53
+ a single package; also the [Sensu](https://github.com/sensu/sensu) guys do something similar.)
50
54
 
51
55
  ## Upcoming Features
52
56
 
53
- * Apply custom patches.
54
- * Dependency checking.
55
57
  * Recipe validation.
56
58
  * More source types. (hg, bzr, ...)
57
59
  * Progress output and logging.
@@ -131,16 +133,17 @@ The following is an example recipe. I have some more in my recipe collection
131
133
  * No recipe documentation and API documentation yet.
132
134
  * No recipe validation yet.
133
135
  * No dependency validation yet.
134
- * No support for patches yet.
135
136
  * Pretty new and not well tested.
136
137
 
137
138
  ## Credits
138
139
 
139
140
  __fpm-cookery__ borrows lots of __ideas__ and also __code__ from the
140
141
  [homebrew](https://github.com/mxcl/homebrew) and
141
- [brew2deb](https://github.com/tmm1/brew2deb) projects. Both projects don't
142
- have any licensing information included in their repositories. So licensing
143
- is still an open question for now.
142
+ [brew2deb](https://github.com/tmm1/brew2deb) projects.
143
+
144
+ ## License
145
+
146
+ The BSD 2-Clause License - See [LICENSE](LICENSE) for details
144
147
 
145
148
  ## How To Contribute
146
149
 
data/fpm-cookery.gemspec CHANGED
@@ -19,8 +19,10 @@ Gem::Specification.new do |s|
19
19
  s.require_paths = ["lib"]
20
20
 
21
21
  s.add_development_dependency "fpm", "~> 0.4"
22
- s.add_development_dependency "minitest"
22
+ s.add_development_dependency "minitest", "~> 4.0"
23
23
  s.add_development_dependency "rake"
24
+ s.add_development_dependency "puppet"
24
25
  s.add_runtime_dependency "fpm", "~> 0.4"
25
26
  s.add_runtime_dependency "facter"
27
+ s.add_runtime_dependency "puppet"
26
28
  end
@@ -1,14 +1,22 @@
1
+ require 'singleton'
2
+
1
3
  module FPM
2
4
  module Cookery
3
5
  class Book
6
+ include Singleton
7
+
8
+ def initialize
9
+ @recipe = nil
10
+ end
11
+
4
12
  # Load the given file and instantiate an object. Wrap the class in an
5
13
  # anonymous module to avoid namespace cluttering. (see Kernel.load)
6
- def self.load_recipe(filename, &callback)
14
+ def load_recipe(filename, &callback)
7
15
  Kernel.load(filename, true)
8
16
  callback.call(@recipe.new(filename))
9
17
  end
10
18
 
11
- def self.loaded_recipe(klass)
19
+ def add_recipe_class(klass)
12
20
  @recipe = klass
13
21
  end
14
22
  end
@@ -9,7 +9,7 @@ module FPM
9
9
 
10
10
  module ClassMethods
11
11
  def inherited(klass)
12
- FPM::Cookery::Book.loaded_recipe(klass)
12
+ FPM::Cookery::Book.instance.add_recipe_class(klass)
13
13
  end
14
14
  end
15
15
  end
@@ -2,6 +2,7 @@ require 'fpm/cookery/book_hook'
2
2
  require 'fpm/cookery/recipe'
3
3
  require 'fpm/cookery/facts'
4
4
  require 'fpm/cookery/packager'
5
+ require 'fpm/cookery/omnibus_packager'
5
6
  require 'fpm/cookery/log'
6
7
  require 'fpm/cookery/log/output/console'
7
8
  require 'fpm/cookery/log/output/console_color'
@@ -21,8 +22,9 @@ module FPM
21
22
  options.banner = \
22
23
  "Usage: #{program} [options] [path/to/recipe.rb] action [...]"
23
24
  options.separator "Actions:"
24
- options.separator " package - builds the package"
25
- options.separator " clean - cleans up"
25
+ options.separator " package - builds the package"
26
+ options.separator " clean - cleans up"
27
+ options.separator " install-deps - installs build and runtime dependencies"
26
28
  options.separator "Options:"
27
29
 
28
30
  options.on("-c", "--color",
@@ -44,6 +46,14 @@ module FPM
44
46
  @platform = o
45
47
  end
46
48
 
49
+ options.on("-V", "--version", "Show fpm-cookery and fpm version") do
50
+ require 'fpm/version'
51
+ require 'fpm/cookery/version'
52
+
53
+ puts "fpm-cookery v#{FPM::Cookery::VERSION} (fpm v#{FPM::VERSION})"
54
+ exit 0
55
+ end
56
+
47
57
  # Parse flags and such, remainder is all non-option args.
48
58
  remainder = options.parse(argv)
49
59
 
@@ -112,14 +122,20 @@ module FPM
112
122
 
113
123
  FPM::Cookery::Recipe.send(:include, FPM::Cookery::BookHook)
114
124
 
115
- FPM::Cookery::Book.load_recipe(@filename) do |recipe|
125
+ FPM::Cookery::Book.instance.load_recipe(@filename) do |recipe|
116
126
  packager = FPM::Cookery::Packager.new(recipe)
117
127
  packager.target = FPM::Cookery::Facts.target.to_s
118
128
 
119
129
  @actions.each do |action|
120
130
  case action
121
131
  when "clean" ; packager.cleanup
122
- when "package" ; packager.dispense
132
+ when "package"
133
+ if recipe.omnibus_package == true
134
+ FPM::Cookery::OmnibusPackager.new(packager).run
135
+ else
136
+ packager.dispense
137
+ end
138
+ when "install-deps" ; packager.install_deps
123
139
  else
124
140
  # TODO(sissel): fail if this happens
125
141
  Log.error "Unknown action: #{action}"
@@ -0,0 +1,89 @@
1
+ require 'puppet'
2
+ require 'puppet/resource'
3
+ require 'puppet/transaction/report'
4
+ require 'fpm/cookery/facts'
5
+ require 'fpm/cookery/log'
6
+
7
+ # Init Puppet before using it
8
+ Puppet.initialize_settings
9
+
10
+ module FPM
11
+ module Cookery
12
+ class DependencyInspector
13
+
14
+ def self.verify!(depends, build_depends)
15
+
16
+ Log.info "Verifying build_depends and depends with Puppet"
17
+
18
+ missing = (build_depends + depends).reject do |package|
19
+ self.package_installed?(package)
20
+ end
21
+
22
+ if missing.length == 0
23
+ Log.info "All build_depends and depends packages installed"
24
+ else
25
+ Log.info "Missing/wrong version packages: #{missing.join(', ')}"
26
+ if Process.euid != 0
27
+ Log.error "Not running as root; please run 'sudo fpm-cook install-deps' to install dependencies."
28
+ exit 1
29
+ else
30
+ Log.info "Running as root; installing missing/wrong version build_depends and depends with Puppet"
31
+ missing.each do |package|
32
+ self.install_package(package)
33
+ end
34
+ end
35
+ end
36
+
37
+ end
38
+
39
+ def self.package_installed?(package)
40
+ Log.info("Verifying package: #{package}")
41
+ return unless self.package_suitable?(package)
42
+
43
+ # Use Puppet in noop mode to see if the package exists
44
+ Puppet[:noop] = true
45
+ resource = Puppet::Resource.new("package", package, :parameters => {
46
+ :ensure => "present"
47
+ })
48
+ result = Puppet::Resource.indirection.save(resource)[1]
49
+ !result.resource_statuses.values.first.out_of_sync
50
+ end
51
+
52
+ def self.install_package(package)
53
+ Log.info("Installing package: #{package}")
54
+ return unless self.package_suitable?(package)
55
+
56
+ # Use Puppet to install a package
57
+ Puppet[:noop] = false
58
+ resource = Puppet::Resource.new("package", package, :parameters => {
59
+ :ensure => "present"
60
+ })
61
+ result = Puppet::Resource.indirection.save(resource)[1]
62
+ failed = Puppet::Resource.indirection.save(resource)[1].resource_statuses.values.first.failed
63
+ if failed
64
+ Log.fatal "While processing depends package '#{package}':"
65
+ result.logs.each {|log_line| Log.fatal log_line}
66
+ exit 1
67
+ else
68
+ result.logs.each {|log_line| Log.info log_line}
69
+ end
70
+ end
71
+
72
+ def self.package_suitable?(package)
73
+ # How can we handle "or" style depends?
74
+ if package =~ / \| /
75
+ Log.warn "Required package '#{package}' is an 'or' string; not attempting to find/install a package to satisfy"
76
+ return false
77
+ end
78
+
79
+ # We can't handle >=, <<, >>, <=
80
+ if package =~ />=|<<|>>|<=/
81
+ Log.warn "Required package '#{package}' has a relative version requirement; not attempting to find/install a package to satisfy"
82
+ return false
83
+ end
84
+ true
85
+ end
86
+
87
+ end
88
+ end
89
+ end
@@ -0,0 +1,69 @@
1
+ require 'fpm/cookery/packager'
2
+ require 'fpm/cookery/facts'
3
+
4
+ module FPM
5
+ module Cookery
6
+ class OmnibusPackager
7
+ include FPM::Cookery::Utils
8
+
9
+ attr_reader :packager, :recipe
10
+
11
+ def initialize(packager)
12
+ @packager = packager
13
+ @recipe = packager.recipe
14
+ @depends = []
15
+ end
16
+
17
+ def run
18
+ # Omnibus packages are many builds in one package; e.g. Ruby + Puppet together.
19
+ Log.info "Recipe #{recipe.name} is an Omnibus package; looking for child recipes to build"
20
+
21
+ recipe.omnibus_recipes.each do |name|
22
+ recipe_file = build_recipe_file_path(name)
23
+
24
+ unless File.exists?(recipe_file)
25
+ Log.fatal "Cannot find a recipe for #{name} at #{recipe_file}"
26
+ exit 1
27
+ end
28
+
29
+ FPM::Cookery::Book.instance.load_recipe(recipe_file) do |dep_recipe|
30
+ dep_recipe.destdir = "#{recipe.omnibus_dir}/embedded" if recipe.omnibus_dir
31
+ dep_recipe.omnibus_installing = true if recipe.omnibus_dir
32
+
33
+ pkg = FPM::Cookery::Packager.new(dep_recipe, :skip_package => true, :keep_destdir => true)
34
+ pkg.target = FPM::Cookery::Facts.target.to_s
35
+
36
+ Log.info "Located recipe at #{recipe_file} for child recipe #{name}; starting build"
37
+ pkg.dispense
38
+
39
+ @depends += dep_recipe.depends
40
+ Log.info "Finished building #{name}, moving on to next recipe"
41
+ end
42
+ end
43
+
44
+ # Now all child recipes are built; set depends to combined set of dependencies
45
+ recipe.class.depends(@depends.flatten.uniq)
46
+ Log.info "Combined dependencies: #{recipe.depends.join(', ')}"
47
+
48
+ recipe.destdir = recipe.omnibus_dir if recipe.omnibus_dir
49
+
50
+ if recipe.omnibus_additional_paths
51
+ packager.config[:input] = [ recipe.destdir ] + recipe.omnibus_additional_paths
52
+ else
53
+ packager.config[:input] = recipe.destdir
54
+ end
55
+
56
+ packager.config[:keep_destdir] = true
57
+
58
+ packager.dispense
59
+ end
60
+
61
+ private
62
+
63
+ def build_recipe_file_path(name)
64
+ # Look for recipes in the same dir as the recipe we loaded
65
+ File.expand_path(File.dirname(recipe.filename) + "/#{name}.rb")
66
+ end
67
+ end
68
+ end
69
+ end
@@ -5,7 +5,7 @@ module FPM
5
5
  module Cookery
6
6
  module Package
7
7
  class Dir < SimpleDelegator
8
- def initialize(recipe)
8
+ def initialize(recipe, config = {})
9
9
  super(FPM::Package::Dir.new)
10
10
 
11
11
  self.name = recipe.name
@@ -29,11 +29,17 @@ module FPM
29
29
  attributes[:rpm_digest] = 'md5'
30
30
  attributes[:rpm_user] = 'root'
31
31
  attributes[:rpm_group] = 'root'
32
+ attributes[:rpm_defattrfile] = '-'
33
+ attributes[:rpm_defattrdir] = '-'
32
34
 
33
35
  # TODO replace remove_excluded_files() in packager with this.
34
36
  attributes[:excludes] = []
35
37
 
36
- input('.')
38
+ inputs = config.fetch(:input, nil) || '.'
39
+
40
+ Array(inputs).each do |path|
41
+ input(path)
42
+ end
37
43
 
38
44
  # The call to input() overwrites the license and vendor attributes.
39
45
  # XXX Needs to be fixed in fpm/package/dir.rb.
@@ -1,13 +1,12 @@
1
1
  #require 'digest/md5'
2
2
  #require 'fpm/cookery/recipe_inspector'
3
- #require 'fpm/cookery/dependency_inspector'
3
+ require 'fpm/cookery/dependency_inspector'
4
4
  require 'fpm/cookery/utils'
5
5
  require 'fpm/cookery/source_integrity_check'
6
6
  require 'fpm/cookery/path'
7
7
  require 'fpm/cookery/log'
8
8
  require 'fpm/cookery/package/dir'
9
- require 'fpm/package/deb'
10
- require 'fpm/package/rpm'
9
+ require 'fpm'
11
10
 
12
11
  module FPM
13
12
  module Cookery
@@ -21,6 +20,14 @@ module FPM
21
20
  @config = config
22
21
  end
23
22
 
23
+ def skip_package?
24
+ !!config[:skip_package]
25
+ end
26
+
27
+ def keep_destdir?
28
+ !!config[:keep_destdir]
29
+ end
30
+
24
31
  def target=(target)
25
32
  # TODO(sissel): do sanity checking
26
33
  @target = target
@@ -34,6 +41,11 @@ module FPM
34
41
  FileUtils.rm_rf(recipe.destdir)
35
42
  end
36
43
 
44
+ def install_deps
45
+ DependencyInspector.verify!(recipe.depends, recipe.build_depends)
46
+ Log.info("All dependencies installed!")
47
+ end
48
+
37
49
  def dispense
38
50
  env = ENV.to_hash
39
51
  package_name = "#{recipe.name}-#{recipe.version}"
@@ -44,7 +56,7 @@ module FPM
44
56
  Log.info ''
45
57
 
46
58
  # RecipeInspector.verify!(recipe)
47
- # DependencyInspector.verify!(recipe.depends, recipe.build_depends)
59
+ DependencyInspector.verify!(recipe.depends, recipe.build_depends)
48
60
 
49
61
  recipe.installing = false
50
62
 
@@ -92,12 +104,12 @@ module FPM
92
104
  if File.exists?(build_cookie)
93
105
  Log.info 'Skipping build (`fpm-cook clean` to rebuild)'
94
106
  else
95
- Log.info "Building in #{File.expand_path(extracted_source)}"
107
+ Log.info "Building in #{File.expand_path(extracted_source, recipe.builddir)}"
96
108
  recipe.build and FileUtils.touch(build_cookie)
97
109
  end
98
110
 
99
- FileUtils.rm_rf(recipe.destdir)
100
- recipe.destdir.mkdir
111
+ FileUtils.rm_rf(recipe.destdir) unless keep_destdir?
112
+ recipe.destdir.mkdir unless File.exists?(recipe.destdir)
101
113
 
102
114
  begin
103
115
  recipe.installing = true
@@ -109,7 +121,11 @@ module FPM
109
121
  end
110
122
  end
111
123
 
112
- build_package(recipe, config)
124
+ if skip_package?
125
+ Log.info "Package building disabled"
126
+ else
127
+ build_package(recipe, config)
128
+ end
113
129
  ensure
114
130
  # Make sure we reset the environment.
115
131
  ENV.replace(env)
@@ -141,13 +157,13 @@ module FPM
141
157
  version = [ver, vendor_rev].join(vendor_delimiter)
142
158
 
143
159
  maintainer = recipe.maintainer || begin
144
- username = `git config --get user.name`.strip
145
- useremail = `git config --get user.email`.strip
160
+ username = git_config('user.name')
161
+ useremail = git_config('user.email')
146
162
 
147
163
  username && useremail ? "#{username} <#{useremail}>" : nil
148
164
  end
149
165
 
150
- input = FPM::Cookery::Package::Dir.new(recipe)
166
+ input = FPM::Cookery::Package::Dir.new(recipe, :input => config[:input])
151
167
 
152
168
  input.version = version
153
169
  input.maintainer = maintainer
@@ -222,6 +238,15 @@ module FPM
222
238
  end
223
239
  end
224
240
  end
241
+
242
+ private
243
+
244
+ def git_config(key)
245
+ %x(git config --get #{key}).strip
246
+ rescue
247
+ Log.warn "Git config command for key '#{key}' failed."
248
+ nil
249
+ end
225
250
  end
226
251
  end
227
252
  end
@@ -3,12 +3,16 @@ require 'fpm/cookery/path'
3
3
  module FPM
4
4
  module Cookery
5
5
  module PathHelper
6
- attr_accessor :installing
6
+ attr_accessor :installing, :omnibus_installing
7
7
 
8
8
  def installing?
9
9
  installing
10
10
  end
11
11
 
12
+ def omnibus_installing?
13
+ omnibus_installing
14
+ end
15
+
12
16
  # Most of the path helper stuff comes from brew2deb and homebrew.
13
17
  def prefix(path = nil)
14
18
  current_pathname_for('usr')/path
@@ -61,7 +65,11 @@ module FPM
61
65
 
62
66
  private
63
67
  def current_pathname_for(dir)
64
- installing? ? destdir/dir : Path.new("/#{dir}")
68
+ if omnibus_installing?
69
+ Path.new("/#{dir}")
70
+ else
71
+ installing? ? destdir/dir : Path.new("/#{dir}")
72
+ end
65
73
  end
66
74
  end
67
75
  end
@@ -56,10 +56,11 @@ module FPM
56
56
  attr_rw :arch, :description, :homepage, :maintainer, :md5, :name,
57
57
  :revision, :section, :sha1, :sha256, :spec, :vendor, :version,
58
58
  :pre_install, :post_install, :pre_uninstall, :post_uninstall,
59
- :license
59
+ :license, :omnibus_package, :omnibus_dir
60
60
 
61
61
  attr_rw_list :build_depends, :config_files, :conflicts, :depends,
62
- :exclude, :patches, :provides, :replaces
62
+ :exclude, :patches, :provides, :replaces, :omnibus_recipes,
63
+ :omnibus_additional_paths
63
64
 
64
65
  class << self
65
66
  def source(source = nil, spec = {})
@@ -43,7 +43,8 @@ module FPM
43
43
 
44
44
  private
45
45
  def curl(url, path)
46
- safesystem('curl', '-fL', '--progress-bar', '-o', path, url)
46
+ args = options[:args] || '-fL'
47
+ safesystem('curl', args, '--progress-bar', '-o', path, url)
47
48
  end
48
49
 
49
50
  def extracted_source
@@ -0,0 +1,22 @@
1
+ require 'fpm/cookery/source_handler/template'
2
+
3
+ module FPM
4
+ module Cookery
5
+ class SourceHandler
6
+ class Noop < FPM::Cookery::SourceHandler::Template
7
+ CHECKSUM = false
8
+ NAME = :noop
9
+
10
+ def fetch
11
+ Log.info "Noop source_handler; do nothing."
12
+ end
13
+
14
+ def extract
15
+ Log.info "Not extracting - noop source handler"
16
+ builddir
17
+ end
18
+
19
+ end
20
+ end
21
+ end
22
+ end
@@ -4,6 +4,7 @@ require 'fpm/cookery/source_handler/svn'
4
4
  require 'fpm/cookery/source_handler/git'
5
5
  require 'fpm/cookery/source_handler/hg'
6
6
  require 'fpm/cookery/source_handler/local_path'
7
+ require 'fpm/cookery/source_handler/noop'
7
8
  require 'fpm/cookery/log'
8
9
 
9
10
  module FPM
@@ -4,13 +4,22 @@ module FPM
4
4
  protected
5
5
  # From fpm. (lib/fpm/util.rb)
6
6
  def safesystem(*args)
7
- success = system(*args)
7
+ success = system(*args.flatten)
8
8
  if !success
9
9
  raise "'system(#{args.inspect})' failed with error code: #{$?.exitstatus}"
10
10
  end
11
11
  return success
12
12
  end
13
13
 
14
+ def cleanenv_safesystem(*args)
15
+ bundler_vars = %w(BUNDLE_GEMFILE RUBYOPT BUNDLE_BIN_PATH GEM_HOME GEM_PATH)
16
+ bundled_env = ENV.to_hash
17
+ bundler_vars.each {|var| ENV.delete(var)}
18
+ result = safesystem(*args)
19
+ ENV.replace(bundled_env.to_hash)
20
+ result
21
+ end
22
+
14
23
  # From brew2deb. (lib/debian_formula.rb)
15
24
  def configure(*args)
16
25
  if args.last.is_a?(Hash)
@@ -57,6 +66,12 @@ module FPM
57
66
  end
58
67
  end
59
68
  alias_method :inreplace, :inline_replace # homebrew compat
69
+
70
+ def patch(src, level = 0)
71
+ raise "patch level must be integer" unless level.is_a?(Fixnum)
72
+ raise "#{src} does not exist" unless File.exist? src
73
+ safesystem "patch -p#{level} --batch < #{src}"
74
+ end
60
75
  end
61
76
  end
62
77
  end
@@ -1,5 +1,5 @@
1
1
  module FPM
2
2
  module Cookery
3
- VERSION = '0.13.0'
3
+ VERSION = '0.14.0'
4
4
  end
5
5
  end
@@ -0,0 +1,19 @@
1
+ #!/usr/bin/env bash
2
+
3
+ # Stolen from Vagrant
4
+
5
+ # Get the directory where this script is. This will also resolve
6
+ # any symlinks in the directory/script, so it will be the fully
7
+ # resolved path.
8
+ SOURCE="${BASH_SOURCE[0]}"
9
+ while [ -h "$SOURCE" ] ; do SOURCE="$(readlink "$SOURCE")"; done
10
+ DIR="$( cd -P "$( dirname "$SOURCE" )" && pwd )"
11
+
12
+ # Useful variables
13
+ EMBEDDED_DIR="${DIR}/../embedded"
14
+
15
+ # Unset some variables that might be set by rvm and friends.
16
+ unset RUBYOPT BUNDLE_GEMFILE BUNDLE_BIN_PATH GEM_HOME GEM_PATH GEMRC
17
+
18
+ # Call the actual fpm-cook bin with our arguments
19
+ ${EMBEDDED_DIR}/bin/fpm-cook "$@"
@@ -0,0 +1,72 @@
1
+ class FPMCookery < FPM::Cookery::Recipe
2
+ description 'building packages'
3
+
4
+ name 'fpm-cookery'
5
+ version '0.13.0'
6
+ revision 0
7
+ homepage 'https://github.com/bernd/fpm-cookery'
8
+
9
+ source '', :with => :noop
10
+
11
+ omnibus_package true
12
+ omnibus_recipes 'ruby'
13
+ omnibus_dir '/opt/fpm-cookery'
14
+
15
+ def build
16
+ gem_install 'fpm-cookery', version
17
+ end
18
+
19
+ def install
20
+ destdir('bin').install workdir('fpm-cook.bin'), 'fpm-cook'
21
+
22
+ with_trueprefix do
23
+ create_post_install_hook
24
+ create_pre_uninstall_hook
25
+ end
26
+ end
27
+
28
+ private
29
+
30
+ def gem_install(name, version = nil)
31
+ v = version.nil? ? '' : "-v #{version}"
32
+ cleanenv_safesystem "#{destdir}/embedded/bin/gem install #{v} #{name}"
33
+ end
34
+
35
+ def create_post_install_hook
36
+ File.open(builddir('post-install'), 'w', 0755) do |f|
37
+ f.write <<-__POSTINST
38
+ #!/bin/sh
39
+ set -e
40
+
41
+ BIN_PATH="#{destdir}/bin"
42
+ BIN="fpm-cook"
43
+
44
+ update-alternatives --install /usr/bin/$BIN $BIN $BIN_PATH/$BIN 100
45
+
46
+ exit 0
47
+ __POSTINST
48
+
49
+ self.class.post_install(File.expand_path(f.path))
50
+ end
51
+ end
52
+
53
+ def create_pre_uninstall_hook
54
+ File.open(builddir('pre-uninstall'), 'w', 0755) do |f|
55
+ f.write <<-__PRERM
56
+ #!/bin/sh
57
+ set -e
58
+
59
+ BIN_PATH="#{destdir}/bin"
60
+ BIN="fpm-cook"
61
+
62
+ if [ "$1" != "upgrade" ]; then
63
+ update-alternatives --remove $BIN $BIN_PATH/$BIN
64
+ fi
65
+
66
+ exit 0
67
+ __PRERM
68
+
69
+ self.class.pre_uninstall(File.expand_path(f.path))
70
+ end
71
+ end
72
+ end
@@ -0,0 +1,35 @@
1
+ class Ruby200 < FPM::Cookery::Recipe
2
+ description 'The Ruby virtual machine'
3
+
4
+ name 'ruby'
5
+ version '2.0.0.0'
6
+ revision 0
7
+ homepage 'http://www.ruby-lang.org/'
8
+ source 'http://ftp.ruby-lang.org/pub/ruby/2.0/ruby-2.0.0-p0.tar.bz2'
9
+ sha256 'c680d392ccc4901c32067576f5b474ee186def2fcd3fcbfa485739168093295f'
10
+
11
+ license 'The Ruby License'
12
+ section 'interpreters'
13
+
14
+ build_depends 'autoconf', 'libreadline6-dev', 'bison', 'zlib1g-dev',
15
+ 'libssl-dev', 'libyaml-dev', 'libffi-dev', 'libgdbm-dev', 'libncurses5-dev',
16
+ 'libreadline6-dev'
17
+
18
+ depends 'libffi6', 'libncurses5', 'libreadline6', 'libssl1.0.0',
19
+ 'libtinfo5', 'libyaml-0-2', 'zlib1g', 'libffi6', 'libgdbm3', 'libncurses5',
20
+ 'libreadline6'
21
+
22
+ def build
23
+ configure :prefix => destdir, 'disable-install-doc' => true
24
+ make
25
+ end
26
+
27
+ def install
28
+ make :install
29
+
30
+ # Shrink package.
31
+ rm_f "#{destdir}/lib/libruby-static.a"
32
+ safesystem "strip #{destdir}/bin/ruby"
33
+ safesystem "find #{destdir} -name '*.so*' | xargs strip"
34
+ end
35
+ end
@@ -0,0 +1,21 @@
1
+ class BundlerGem < FPM::Cookery::Recipe
2
+ description 'Bundler gem'
3
+
4
+ name 'bundler'
5
+ version '1.3.4'
6
+ revision 0
7
+ source "nothing", :with => :noop
8
+
9
+ vendor 'fpm'
10
+ license 'Unknown'
11
+
12
+ section 'interpreters'
13
+
14
+ def build
15
+ cleanenv_safesystem "#{destdir}/bin/gem install #{name} -v #{version}"
16
+ end
17
+
18
+ def install
19
+ # Do nothing!
20
+ end
21
+ end
@@ -0,0 +1,14 @@
1
+ class OmnibusTest < FPM::Cookery::Recipe
2
+ homepage 'http://test'
3
+
4
+ section 'interpreters'
5
+ name 'omnibus-test'
6
+ version '1.0.0'
7
+ description 'Testing Omnibus package'
8
+ revision 0
9
+
10
+ omnibus_package true
11
+ omnibus_recipes "ruby", "bundler-gem"
12
+ omnibus_dir '/opt/omnibustest'
13
+
14
+ end
@@ -0,0 +1,32 @@
1
+ class Ruby200 < FPM::Cookery::Recipe
2
+ description 'The Ruby virtual machine'
3
+
4
+ name 'ruby'
5
+ version '2.0.0.0'
6
+ revision 0
7
+ homepage 'http://www.ruby-lang.org/'
8
+ source 'http://ftp.ruby-lang.org/pub/ruby/2.0/ruby-2.0.0-p0.tar.bz2'
9
+ sha256 'c680d392ccc4901c32067576f5b474ee186def2fcd3fcbfa485739168093295f'
10
+
11
+ vendor 'fpm'
12
+ license 'The Ruby License'
13
+
14
+ section 'interpreters'
15
+
16
+ build_depends 'autoconf', 'libreadline6-dev', 'bison', 'zlib1g-dev',
17
+ 'libssl-dev', 'libyaml-dev', 'libffi-dev', 'libgdbm-dev', 'libncurses5-dev',
18
+ 'libreadline6-dev'
19
+
20
+ depends 'libffi6', 'libncurses5', 'libreadline6', 'libssl1.0.0',
21
+ 'libtinfo5', 'libyaml-0-2', 'zlib1g', 'libffi6', 'libgdbm3', 'libncurses5',
22
+ 'libreadline6'
23
+
24
+ def build
25
+ configure :prefix => destdir, 'disable-install-doc' => true
26
+ make
27
+ end
28
+
29
+ def install
30
+ make :install
31
+ end
32
+ end
@@ -61,6 +61,22 @@ describe "PathHelper" do
61
61
  helper.send(name, 'blah').to_s.must_equal "#{helper.destdir}#{path}/blah"
62
62
  end
63
63
  end
64
+
65
+ context "with omnibus_installing set to true" do
66
+ before { helper.omnibus_installing = true }
67
+
68
+ it "does not add anything to the path" do
69
+ helper.send(name, 'blah').to_s.must_equal "#{path}/blah"
70
+ end
71
+ end
72
+
73
+ context "with omnibus_installing and installing set to true" do
74
+ before { helper.omnibus_installing = true ; helper.installing = true }
75
+
76
+ it "does not add anything to the path" do
77
+ helper.send(name, 'blah').to_s.must_equal "#{path}/blah"
78
+ end
79
+ end
64
80
  end
65
81
  end
66
82
  end
@@ -83,6 +99,24 @@ describe "PathHelper" do
83
99
  end
84
100
  end
85
101
 
102
+ describe "#omnibus_installing?" do
103
+ context "with omnibus_installing set to true" do
104
+ before { helper.omnibus_installing = true }
105
+
106
+ it "returns true" do
107
+ helper.omnibus_installing?.must_equal true
108
+ end
109
+ end
110
+
111
+ context "with omnibus_installing set to false" do
112
+ before { helper.omnibus_installing = false }
113
+
114
+ it "returns false" do
115
+ helper.omnibus_installing?.must_equal false
116
+ end
117
+ end
118
+ end
119
+
86
120
  describe "#with_trueprefix" do
87
121
  context "with installing set to true" do
88
122
  before { helper.installing = true }
data/spec/recipe_spec.rb CHANGED
@@ -176,6 +176,18 @@ describe "Recipe" do
176
176
  end
177
177
  end
178
178
 
179
+ describe "#omnibus_package" do
180
+ it "can be set" do
181
+ check_attribute(:omnibus_package, true)
182
+ end
183
+ end
184
+
185
+ describe "#omnibus_dir" do
186
+ it "can be set" do
187
+ check_attribute(:omnibus_dir, '/foo')
188
+ end
189
+ end
190
+
179
191
  def self.spec_recipe_attribute_list(name, list)
180
192
  class_eval %Q{
181
193
  describe "##{name}" do
@@ -203,6 +215,7 @@ describe "Recipe" do
203
215
  spec_recipe_attribute_list(:patches, %w{one two})
204
216
  spec_recipe_attribute_list(:provides, %w{one two})
205
217
  spec_recipe_attribute_list(:replaces, %w{one two})
218
+ spec_recipe_attribute_list(:omnibus_recipes, %w{one two})
206
219
 
207
220
  describe ".source" do
208
221
  it "sets a source url" do
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fpm-cookery
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.13.0
4
+ version: 0.14.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-01-28 00:00:00.000000000 Z
12
+ date: 2013-05-31 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: fpm
@@ -29,6 +29,22 @@ dependencies:
29
29
  version: '0.4'
30
30
  - !ruby/object:Gem::Dependency
31
31
  name: minitest
32
+ requirement: !ruby/object:Gem::Requirement
33
+ none: false
34
+ requirements:
35
+ - - ~>
36
+ - !ruby/object:Gem::Version
37
+ version: '4.0'
38
+ type: :development
39
+ prerelease: false
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ~>
44
+ - !ruby/object:Gem::Version
45
+ version: '4.0'
46
+ - !ruby/object:Gem::Dependency
47
+ name: rake
32
48
  requirement: !ruby/object:Gem::Requirement
33
49
  none: false
34
50
  requirements:
@@ -44,7 +60,7 @@ dependencies:
44
60
  - !ruby/object:Gem::Version
45
61
  version: '0'
46
62
  - !ruby/object:Gem::Dependency
47
- name: rake
63
+ name: puppet
48
64
  requirement: !ruby/object:Gem::Requirement
49
65
  none: false
50
66
  requirements:
@@ -91,6 +107,22 @@ dependencies:
91
107
  - - ! '>='
92
108
  - !ruby/object:Gem::Version
93
109
  version: '0'
110
+ - !ruby/object:Gem::Dependency
111
+ name: puppet
112
+ requirement: !ruby/object:Gem::Requirement
113
+ none: false
114
+ requirements:
115
+ - - ! '>='
116
+ - !ruby/object:Gem::Version
117
+ version: '0'
118
+ type: :runtime
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ none: false
122
+ requirements:
123
+ - - ! '>='
124
+ - !ruby/object:Gem::Version
125
+ version: '0'
94
126
  description: A tool for building software packages with fpm.
95
127
  email:
96
128
  - bernd@tuneafish.de
@@ -103,6 +135,7 @@ files:
103
135
  - .gitignore
104
136
  - CHANGELOG.md
105
137
  - Gemfile
138
+ - LICENSE
106
139
  - README.md
107
140
  - Rakefile
108
141
  - bin/fpm-cook
@@ -110,12 +143,14 @@ files:
110
143
  - lib/fpm/cookery/book.rb
111
144
  - lib/fpm/cookery/book_hook.rb
112
145
  - lib/fpm/cookery/cli.rb
146
+ - lib/fpm/cookery/dependency_inspector.rb
113
147
  - lib/fpm/cookery/facts.rb
114
148
  - lib/fpm/cookery/log.rb
115
149
  - lib/fpm/cookery/log/color.rb
116
150
  - lib/fpm/cookery/log/output/console.rb
117
151
  - lib/fpm/cookery/log/output/console_color.rb
118
152
  - lib/fpm/cookery/log/output/null.rb
153
+ - lib/fpm/cookery/omnibus_packager.rb
119
154
  - lib/fpm/cookery/package/dir.rb
120
155
  - lib/fpm/cookery/packager.rb
121
156
  - lib/fpm/cookery/path.rb
@@ -127,12 +162,19 @@ files:
127
162
  - lib/fpm/cookery/source_handler/git.rb
128
163
  - lib/fpm/cookery/source_handler/hg.rb
129
164
  - lib/fpm/cookery/source_handler/local_path.rb
165
+ - lib/fpm/cookery/source_handler/noop.rb
130
166
  - lib/fpm/cookery/source_handler/svn.rb
131
167
  - lib/fpm/cookery/source_handler/template.rb
132
168
  - lib/fpm/cookery/source_integrity_check.rb
133
169
  - lib/fpm/cookery/utils.rb
134
170
  - lib/fpm/cookery/version.rb
171
+ - recipes/fpm-cookery/fpm-cook.bin
172
+ - recipes/fpm-cookery/recipe.rb
173
+ - recipes/fpm-cookery/ruby.rb
135
174
  - recipes/nodejs/recipe.rb
175
+ - recipes/omnibustest/bundler-gem.rb
176
+ - recipes/omnibustest/recipe.rb
177
+ - recipes/omnibustest/ruby.rb
136
178
  - recipes/redis/recipe.rb
137
179
  - recipes/redis/redis-server.init.d
138
180
  - spec/facts_spec.rb
@@ -155,15 +197,21 @@ required_ruby_version: !ruby/object:Gem::Requirement
155
197
  - - ! '>='
156
198
  - !ruby/object:Gem::Version
157
199
  version: '0'
200
+ segments:
201
+ - 0
202
+ hash: -1124392889621969599
158
203
  required_rubygems_version: !ruby/object:Gem::Requirement
159
204
  none: false
160
205
  requirements:
161
206
  - - ! '>='
162
207
  - !ruby/object:Gem::Version
163
208
  version: '0'
209
+ segments:
210
+ - 0
211
+ hash: -1124392889621969599
164
212
  requirements: []
165
213
  rubyforge_project: fpm-cookery
166
- rubygems_version: 1.8.24
214
+ rubygems_version: 1.8.25
167
215
  signing_key:
168
216
  specification_version: 3
169
217
  summary: A tool for building software packages with fpm.