Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Merge pull request #94 from opscode/versioned-dependencies-2

project overrides of software definitions
  • Loading branch information...
commit 7d3ad8b4be1d4ee1ff96c0d805764af7f15922bc 2 parents b048ba9 + 4912658
@lamont-granquist lamont-granquist authored
Showing with 476 additions and 121 deletions.
  1. +2 −2 NOTICE
  2. +63 −7 README.md
  3. +1 −1  lib/omnibus.rb
  4. +1 −1  lib/omnibus/build_version.rb
  5. +6 −4 lib/omnibus/builder.rb
  6. +1 −1  lib/omnibus/clean_tasks.rb
  7. +1 −1  lib/omnibus/cli.rb
  8. +1 −1  lib/omnibus/cli/application.rb
  9. +1 −1  lib/omnibus/cli/base.rb
  10. +1 −1  lib/omnibus/cli/build.rb
  11. +1 −1  lib/omnibus/cli/cache.rb
  12. +1 −1  lib/omnibus/cli/release.rb
  13. +1 −1  lib/omnibus/config.rb
  14. +21 −0 lib/omnibus/exceptions.rb
  15. +1 −1  lib/omnibus/fetcher.rb
  16. +1 −1  lib/omnibus/fetchers.rb
  17. +1 −1  lib/omnibus/fetchers/git_fetcher.rb
  18. +1 −1  lib/omnibus/fetchers/net_fetcher.rb
  19. +1 −1  lib/omnibus/fetchers/path_fetcher.rb
  20. +1 −1  lib/omnibus/fetchers/s3_cache_fetcher.rb
  21. +1 −1  lib/omnibus/health_check.rb
  22. +3 −3 lib/omnibus/library.rb
  23. +1 −1  lib/omnibus/package_release.rb
  24. +25 −4 lib/omnibus/project.rb
  25. +4 −4 lib/omnibus/reports.rb
  26. +1 −1  lib/omnibus/s3_cacher.rb
  27. +115 −22 lib/omnibus/software.rb
  28. +3 −3 lib/omnibus/util.rb
  29. +1 −1  lib/omnibus/version.rb
  30. +2 −2 omnibus.gemspec
  31. +1 −1  spec/artifact_spec.rb
  32. +1 −1  spec/build_version_spec.rb
  33. +41 −0 spec/data/projects/chefdk.rb
  34. +1 −1  spec/data/software/erchef.rb
  35. +67 −0 spec/data/software/zlib.rb
  36. +1 −1  spec/package_release_spec.rb
  37. +32 −0 spec/project_spec.rb
  38. +1 −1  spec/s3_cacher_spec.rb
  39. +67 −45 spec/software_spec.rb
View
4 NOTICE
@@ -1,9 +1,9 @@
omnibus-ruby NOTICE
===================
-Developed at Opscode (http://www.opscode.com).
+Developed at Chef Software, Inc (http://www.getchef.com).
Contributors and Copyright holders:
- * Copyright 2012, Opscode, Inc. <legal@opscode.com>
+ * Copyright 2012-2014, Chef Software, Inc. <legal@getchef.com>
View
70 README.md
@@ -92,10 +92,10 @@ anything from the `omnibus-software` repository.)
An example:
```ruby
-name "ruby"
-version "1.9.2-p290"
-source :url => "http://ftp.ruby-lang.org/pub/ruby/1.9/ruby-#{version}.tar.gz",
- :md5 => "604da71839a6ae02b5b5b5e1b792d5eb"
+name "ruby"
+default_version "1.9.2-p290"
+source :url => "http://ftp.ruby-lang.org/pub/ruby/1.9/ruby-#{version}.tar.gz",
+ :md5 => "604da71839a6ae02b5b5b5e1b792d5eb"
dependency "zlib"
dependency "ncurses"
@@ -112,9 +112,9 @@ end
Some of the DSL methods available include:
-**name**: The name of the software component.
+**name**: The name of the software component (this should come first).
-**version**: The version of the software component.
+**default_version**: The version of the software component.
**source**: Directions to the location of the source.
@@ -179,11 +179,67 @@ platforms (though Omnibus is not limited to just those!) is created
for each project that you generate using `omnibus project
$MY_PROJECT_NAME`
+## Multiple Software Versions and Version Overrides
+
+You can support building multiple verisons of the same software in the same
+software definition file:
+
+```ruby
+name "ruby"
+default_version "1.9.2-p290"
+
+version "1.9.2-p290" do
+ source :url => "http://ftp.ruby-lang.org/pub/ruby/1.9/ruby-#{version}.tar.gz",
+ :md5 => "604da71839a6ae02b5b5b5e1b792d5eb"
+end
+
+version "2.1.1" do
+ source :url => "http://ftp.ruby-lang.org/pub/ruby/2.1/ruby-#{version}.tar.gz",
+ :md5 => "e57fdbb8ed56e70c43f39c79da1654b2"
+end
+
+
+dependency "zlib"
+dependency "ncurses"
+dependency "openssl"
+
+relative_path "ruby-#{version}"
+
+build do
+ command "./configure"
+ command "make"
+ command "make install"
+end
+```
+
+Since the software definitions are simply ruby code, you can conditionally
+execute anything by wrapping it with pure ruby that tests for the version number.
+
+The project definitions can then take advange of this by passing in overrides
+to use the correct version:
+
+```ruby
+name "chef-full"
+maintainer "YOUR NAME"
+homepage "http://yoursite.com"
+
+install_path "/opt/chef"
+build_version "0.10.8"
+build_iteration 4
+
+override :chef, version: "2.1.1"
+
+dependency "chef"
+```
+
+There is no checking that the version override that you supply has been
+provided in a version override block in the software definition.
+
## License
See the LICENSE and NOTICE files for more information.
-Copyright: Copyright (c) 2012--2013 Opscode, Inc.
+Copyright: Copyright (c) 2012--2013-2014 Chef Software, Inc.
License: Apache License, Version 2.0
Licensed under the Apache License, Version 2.0 (the "License");
View
2  lib/omnibus.rb
@@ -1,5 +1,5 @@
#
-# Copyright:: Copyright (c) 2012 Opscode, Inc.
+# Copyright:: Copyright (c) 2012-2014 Chef Software, Inc.
# License:: Apache License, Version 2.0
#
# Licensed under the Apache License, Version 2.0 (the "License");
View
2  lib/omnibus/build_version.rb
@@ -1,5 +1,5 @@
#
-# Copyright:: Copyright (c) 2012 Opscode, Inc.
+# Copyright:: Copyright (c) 2012-2014 Chef Software, Inc.
# License:: Apache License, Version 2.0
#
# Licensed under the Apache License, Version 2.0 (the "License");
View
10 lib/omnibus/builder.rb
@@ -1,5 +1,5 @@
#
-# Copyright:: Copyright (c) 2012 Opscode, Inc.
+# Copyright:: Copyright (c) 2012-2014 Chef Software, Inc.
# License:: Apache License, Version 2.0
#
# Licensed under the Apache License, Version 2.0 (the "License");
@@ -140,12 +140,12 @@ def patch(*args)
end
plevel = args[:plevel] || 1
- if args[:target]
+ if args[:target]
target = File.expand_path("#{project_dir}/#{args[:target]}")
- @build_commands <<
+ @build_commands <<
"cat #{source} | patch -p#{plevel} #{target}"
else
- @build_commands <<
+ @build_commands <<
"patch -d #{project_dir} -p#{plevel} -i #{source}"
end
end
@@ -210,6 +210,8 @@ def log(message)
def build
log "building #{name}"
+ log "version overridden from #{@software.default_version} to " \
+ "#{@software.version}" if @software.overridden?
time_it("#{name} build") do
@build_commands.each do |cmd|
execute(cmd)
View
2  lib/omnibus/clean_tasks.rb
@@ -1,5 +1,5 @@
#
-# Copyright:: Copyright (c) 2012 Opscode, Inc.
+# Copyright:: Copyright (c) 2012-2014 Chef Software, Inc.
# License:: Apache License, Version 2.0
#
# Licensed under the Apache License, Version 2.0 (the "License");
View
2  lib/omnibus/cli.rb
@@ -1,5 +1,5 @@
#
-# Copyright:: Copyright (c) 2012 Opscode, Inc.
+# Copyright:: Copyright (c) 2012-2014 Chef Software, Inc.
# License:: Apache License, Version 2.0
#
# Licensed under the Apache License, Version 2.0 (the "License");
View
2  lib/omnibus/cli/application.rb
@@ -1,5 +1,5 @@
#
-# Copyright:: Copyright (c) 2013 Opscode, Inc.
+# Copyright:: Copyright (c) 2013-2014 Chef Software, Inc.
# License:: Apache License, Version 2.0
#
# Licensed under the Apache License, Version 2.0 (the "License");
View
2  lib/omnibus/cli/base.rb
@@ -1,5 +1,5 @@
#
-# Copyright:: Copyright (c) 2013 Opscode, Inc.
+# Copyright:: Copyright (c) 2013-2014 Chef Software, Inc.
# License:: Apache License, Version 2.0
#
# Licensed under the Apache License, Version 2.0 (the "License");
View
2  lib/omnibus/cli/build.rb
@@ -1,5 +1,5 @@
#
-# Copyright:: Copyright (c) 2013 Opscode, Inc.
+# Copyright:: Copyright (c) 2013-2014 Chef Software, Inc.
# License:: Apache License, Version 2.0
#
# Licensed under the Apache License, Version 2.0 (the "License");
View
2  lib/omnibus/cli/cache.rb
@@ -1,5 +1,5 @@
#
-# Copyright:: Copyright (c) 2013 Opscode, Inc.
+# Copyright:: Copyright (c) 2013-2014 Chef Software, Inc.
# License:: Apache License, Version 2.0
#
# Licensed under the Apache License, Version 2.0 (the "License");
View
2  lib/omnibus/cli/release.rb
@@ -1,5 +1,5 @@
#
-# Copyright:: Copyright (c) 2013 Opscode, Inc.
+# Copyright:: Copyright (c) 2013-2014 Chef Software, Inc.
# License:: Apache License, Version 2.0
#
# Licensed under the Apache License, Version 2.0 (the "License");
View
2  lib/omnibus/config.rb
@@ -1,5 +1,5 @@
#
-# Copyright:: Copyright (c) 2012 Opscode, Inc.
+# Copyright:: Copyright (c) 2012-2014 Chef Software, Inc.
# License:: Apache License, Version 2.0
#
# Licensed under the Apache License, Version 2.0 (the "License");
View
21 lib/omnibus/exceptions.rb
@@ -91,6 +91,7 @@ def to_s
"""
end
end
+
# Raise this error if a needed Project configuration value has not
# been set.
class MissingProjectConfiguration < RuntimeError
@@ -111,6 +112,26 @@ def to_s
end
end
+ # Raise this error if a needed Software configuration value has not
+ # been set.
+ class MissingSoftwareConfiguration < RuntimeError
+ def initialize(software_name, parameter_name, sample_value)
+ @software_name, @parameter_name, @sample_value = software, parameter_name, sample_value
+ end
+
+ def to_s
+ """
+ You are attempting to build software #{@sofware_name}, but have not specified
+ a value for '#{@parameter_name}'!
+
+ Please add code similar to the following to your software DSL file:
+
+ #{@parameter_name} '#{@sample_value}'
+
+ """
+ end
+ end
+
class MissingPatch < RuntimeError
def initialize(patch_name, search_paths)
@patch_name, @search_paths = patch_name, search_paths
View
2  lib/omnibus/fetcher.rb
@@ -1,5 +1,5 @@
#
-# Copyright:: Copyright (c) 2012 Opscode, Inc.
+# Copyright:: Copyright (c) 2012-2014 Chef Software, Inc.
# License:: Apache License, Version 2.0
#
# Licensed under the Apache License, Version 2.0 (the "License");
View
2  lib/omnibus/fetchers.rb
@@ -1,5 +1,5 @@
#
-# Copyright:: Copyright (c) 2012 Opscode, Inc.
+# Copyright:: Copyright (c) 2012-2014 Chef Software, Inc.
# License:: Apache License, Version 2.0
#
# Licensed under the Apache License, Version 2.0 (the "License");
View
2  lib/omnibus/fetchers/git_fetcher.rb
@@ -1,5 +1,5 @@
#
-# Copyright:: Copyright (c) 2012 Opscode, Inc.
+# Copyright:: Copyright (c) 2012-2014 Chef Software, Inc.
# License:: Apache License, Version 2.0
#
# Licensed under the Apache License, Version 2.0 (the "License");
View
2  lib/omnibus/fetchers/net_fetcher.rb
@@ -1,5 +1,5 @@
#
-# Copyright:: Copyright (c) 2012 Opscode, Inc.
+# Copyright:: Copyright (c) 2012-2014 Chef Software, Inc.
# License:: Apache License, Version 2.0
#
# Licensed under the Apache License, Version 2.0 (the "License");
View
2  lib/omnibus/fetchers/path_fetcher.rb
@@ -1,5 +1,5 @@
#
-# Copyright:: Copyright (c) 2012 Opscode, Inc.
+# Copyright:: Copyright (c) 2012-2014 Chef Software, Inc.
# License:: Apache License, Version 2.0
#
# Licensed under the Apache License, Version 2.0 (the "License");
View
2  lib/omnibus/fetchers/s3_cache_fetcher.rb
@@ -1,5 +1,5 @@
#
-# Copyright:: Copyright (c) 2012 Opscode, Inc.
+# Copyright:: Copyright (c) 2012-2014 Chef Software, Inc.
# License:: Apache License, Version 2.0
#
# Licensed under the Apache License, Version 2.0 (the "License");
View
2  lib/omnibus/health_check.rb
@@ -1,5 +1,5 @@
#
-# Copyright:: Copyright (c) 2012 Opscode, Inc.
+# Copyright:: Copyright (c) 2012-2014 Chef Software, Inc.
# License:: Apache License, Version 2.0
#
# Licensed under the Apache License, Version 2.0 (the "License");
View
6 lib/omnibus/library.rb
@@ -1,5 +1,5 @@
#
-# Copyright:: Copyright (c) 2012 Opscode, Inc.
+# Copyright:: Copyright (c) 2012-2014 Chef Software, Inc.
# License:: Apache License, Version 2.0
#
# Licensed under the Apache License, Version 2.0 (the "License");
@@ -33,9 +33,9 @@ def component_added(component)
def version_map
@components.inject({}) {|map, component|
- map[component.name] = if component.given_version
+ map[component.name] = if component.default_version
{:version => component.version,
- :given_version => component.given_version,
+ :default_version => component.default_version,
:overridden => component.overridden?,
:version_guid => component.version_guid}
else
View
2  lib/omnibus/package_release.rb
@@ -1,5 +1,5 @@
#
-# Copyright:: Copyright (c) 2012 Opscode, Inc.
+# Copyright:: Copyright (c) 2012-2014 Chef Software, Inc.
# License:: Apache License, Version 2.0
#
# Licensed under the Apache License, Version 2.0 (the "License");
View
29 lib/omnibus/project.rb
@@ -1,5 +1,5 @@
#
-# Copyright:: Copyright (c) 2012 Opscode, Inc.
+# Copyright:: Copyright (c) 2012-2014 Chef Software, Inc.
# Copyright:: Copyright (c) 2014 Noah Kantrowitz
# License:: Apache License, Version 2.0
#
@@ -64,6 +64,7 @@ def initialize(io, filename)
@description = nil
@replaces = nil
@mac_pkg_identifier = nil
+ @overrides = { }
@exclusions = Array.new
@conflicts = Array.new
@@ -124,7 +125,7 @@ def package_name(val=NULL_ARG)
# must be set in order to build a project)
def install_path(val=NULL_ARG)
@install_path = val unless val.equal?(NULL_ARG)
- @install_path || raise(MissingProjectConfiguration.new("install_path", "/opt/opscode"))
+ @install_path || raise(MissingProjectConfiguration.new("install_path", "/opt/chef"))
end
# Set or retrieve the the package maintainer.
@@ -137,7 +138,7 @@ def install_path(val=NULL_ARG)
# be set in order to build a project)
def maintainer(val=NULL_ARG)
@maintainer = val unless val.equal?(NULL_ARG)
- @maintainer || raise(MissingProjectConfiguration.new("maintainer", "Opscode, Inc."))
+ @maintainer || raise(MissingProjectConfiguration.new("maintainer", "Chef Software, Inc."))
end
# Set or retrive the package homepage.
@@ -150,7 +151,7 @@ def maintainer(val=NULL_ARG)
# set in order to build a project)
def homepage(val=NULL_ARG)
@homepage = val unless val.equal?(NULL_ARG)
- @homepage || raise(MissingProjectConfiguration.new("homepage", "http://www.opscode.com"))
+ @homepage || raise(MissingProjectConfiguration.new("homepage", "http://www.getchef.com"))
end
# Defines the iteration for the package to be generated. Adheres
@@ -258,6 +259,26 @@ def package_user(val=NULL_ARG)
@pkg_user
end
+ # Set or retrieve the full overrides hash for all software being overridden. Calling it as
+ # a setter does not merge hash entries and will obliterate any previous overrides that have been setup.
+ #
+ # @param val [Hash]
+ # @return [Hash]
+ def overrides(val=NULL_ARG)
+ @overrides = val unless val.equal?(NULL_ARG)
+ @overrides
+ end
+
+ # Set or retrieve the overrides hash for one piece of software being overridden. Calling it as a
+ # setter does not merge hash entries and it will set all the overrides for a given software definition.
+ #
+ # @param val [Hash]
+ # @return [Hash]
+ def override(name, val=NULL_ARG)
+ @overrides[name] = val unless val.equal?(NULL_ARG)
+ @overrides[name]
+ end
+
# Set or retrieve the {deb/rpm/solaris}-group fpm argument.
#
# @param val [String]
View
8 lib/omnibus/reports.rb
@@ -1,5 +1,5 @@
#
-# Copyright:: Copyright (c) 2012 Opscode, Inc.
+# Copyright:: Copyright (c) 2012-2014 Chef Software, Inc.
# License:: Apache License, Version 2.0
#
# Licensed under the Apache License, Version 2.0 (the "License");
@@ -54,7 +54,7 @@ def pretty_version_map(project)
# because we want to output a column only if something was
# overridden, but nothing if no packages were changed
overridden_versions = non_nil_values(version_map.values.select{|v| v[:overridden]},
- :given_version)
+ :default_version)
# Determine how wide the printed table columns need to be
@@ -80,14 +80,14 @@ def pretty_version_map(project)
version = version_map[name][:version]
version_guid = version_map[name][:version_guid]
- given_version = version_map[name][:given_version]
+ default_version = version_map[name][:default_version]
overridden = version_map[name][:overridden]
out << "#{name}".ljust(name_width)
out << version.to_s.ljust(version_width)
out << version_guid.to_s.ljust(guid_width) if version_guid
# Only print out column if something was overridden
- out << given_version.ljust(override_width) if overridden
+ out << default_version.ljust(override_width) if overridden
out << "\n"
end
out
View
2  lib/omnibus/s3_cacher.rb
@@ -1,5 +1,5 @@
#
-# Copyright:: Copyright (c) 2012 Opscode, Inc.
+# Copyright:: Copyright (c) 2012-2014 Chef Software, Inc.
# License:: Apache License, Version 2.0
#
# Licensed under the Apache License, Version 2.0 (the "License");
View
137 lib/omnibus/software.rb
@@ -35,6 +35,7 @@ class Software
include Rake::DSL
NULL_ARG = Object.new
+ UNINITIALIZED = Object.new
# It appears that this is not used
attr_reader :builder
@@ -49,18 +50,20 @@ class Software
attr_reader :project
- attr_reader :given_version
- attr_reader :override_version
+ attr_reader :version
+
+ attr_reader :overrides
+
attr_reader :whitelist_files
- def self.load(filename, project, overrides={})
- new(IO.read(filename), filename, project, overrides)
+ def self.load(filename, project, repo_overrides={})
+ new(IO.read(filename), filename, project, repo_overrides)
end
# @param io [String]
# @param filename [String]
# @param project [???] Is this a string or an Omnibus::Project?
- # @param overrides [Hash]
+ # @param repo_overrides [Hash]
#
# @see Omnibus::Overrides
#
@@ -70,9 +73,9 @@ def self.load(filename, project, overrides={})
# project, and override hash directly? That is, why io AND a
# filename, if the filename can always get you the contents you
# need anyway?
- def initialize(io, filename, project, overrides={})
- @given_version = nil
- @override_version = nil
+ def initialize(io, filename, project, repo_overrides={})
+ @version = nil
+ @overrides = UNINITIALIZED
@name = nil
@description = nil
@source = nil
@@ -81,6 +84,7 @@ def initialize(io, filename, project, overrides={})
@source_config = filename
@project = project
@always_build = false
+ @repo_overrides = repo_overrides
# Seems like this should just be Builder.new(self) instead
@builder = NullBuilder.new(self)
@@ -89,17 +93,50 @@ def initialize(io, filename, project, overrides={})
@whitelist_files = Array.new
instance_eval(io, filename, 0)
- # Set override information after the DSL file has been consumed
- @override_version = overrides[name]
-
render_tasks
end
+
+ # Retrieves the override_version
+ #
+ # @return [Hash]
+ #
+ # @todo: can't we just use #version here or are we testing this against nil? somewhere and
+ # not using #overridden?
+ def override_version
+ $stderr.puts "The #override_version is DEPRECATED, please use #version or test with #overridden?"
+ overrides[:version]
+ end
+
+ # Retrieves the repo-level and project-level overrides for the software.
+ #
+ # @return [Hash]
+ def overrides
+ # deliberately not providing a setter since that feels like a shotgun pointed at a foot
+ if @overrides == UNINITIALIZED
+ # lazily initialized because we need the 'name' to be parsed first
+ @overrides = {}
+ @overrides = project.overrides[name.to_sym].dup if project.overrides[name.to_sym]
+ if @repo_overrides[name]
+ @overrides[:version] = @repo_overrides[name]
+ end
+ end
+ @overrides
+ end
+
+ # Sets or retreives the name of the software
+ #
+ # @param val [String] name of the Software
+ # @return [String]
def name(val=NULL_ARG)
@name = val unless val.equal?(NULL_ARG)
- @name
+ @name || raise(MissingSoftwareConfiguration.new(name, "name", "libxslt"))
end
+ # Sets the description of the software
+ #
+ # @param val [String] description of the Software
+ # @return [void]
def description(val)
@description = val
end
@@ -140,19 +177,60 @@ def dependencies(val=NULL_ARG)
#
# @todo Consider changing this to accept two arguments instead
# @todo This should throw an error if an invalid key is given, or
- # if more than one pair is given, or if no source value is ever
- # set.
+ # if more than one pair is given
def source(val=NULL_ARG)
- @source = val unless val.equal?(NULL_ARG)
- @source
+ unless val.equal?(NULL_ARG)
+ @source ||= {}
+ @source.merge!(val)
+ end
+ apply_overrides(:source)
end
- # Set a version from a software descriptor file, or receive the
- # effective version, taking into account any override information
- # (if set)
+ # Retieve the default_version of the software
+ #
+ # @return [String]
+ #
+ # @todo: remove this in favor of default_version
+ def given_version
+ $stderr.puts "Getting the default version via #given_version is DEPRECATED, please use 'default_version'"
+ default_version
+ end
+
+ # Set or retieve the default_version of the software to build
+ #
+ # @param val [String]
+ # @return [String]
+ def default_version(val=NULL_ARG)
+ @version = val unless val.equal?(NULL_ARG)
+ @version
+ end
+
+ # Evaluate a block only if the version matches.
+ #
+ # Note that passing only a string without a block will set the default_version but this
+ # behavior is deprecated and will be removed, use the default_version method instead.
+ #
+ # @param val [String] version of the software.
+ # @param block [Proc] block to run if the version we are building matches the argument.
+ # @return [void]
+ #
+ # @todo remove deprecated setting of version
def version(val=NULL_ARG)
- @given_version = val unless val.equal?(NULL_ARG)
- @override_version || @given_version
+ if block_given?
+ if val.equal?(NULL_ARG)
+ raise "block needs a version argument to apply against"
+ else
+ if val == apply_overrides(:version)
+ yield
+ end
+ end
+ else
+ unless val.equal?(NULL_ARG)
+ $stderr.puts "Setting the version via 'version' is DEPRECATED, please use 'default_version'"
+ @version = val
+ end
+ end
+ apply_overrides(:version)
end
# Add an Omnibus software dependency.
@@ -169,7 +247,8 @@ def whitelist_file(file)
#
# @return [Boolean]
def overridden?
- @override_version && (@override_version != @given_version)
+ # note: using instance variables to bypass accessors that enforce overrides
+ @overrides.has_key?(:version) && (@overrides[:version] != @version)
end
# @todo see comments on {Omnibus::Fetcher#without_caching_for}
@@ -356,6 +435,20 @@ def architecture
private
+ # Apply overrides in the @overrides hash that mask instance variables
+ # that are set by parsing the DSL
+ #
+ def apply_overrides(attr)
+ val = instance_variable_get(:"@#{attr}")
+ if val.is_a?(Hash) || overrides[attr].is_a?(Hash)
+ val ||= {}
+ override = overrides[attr] || {}
+ val.merge(override)
+ else
+ overrides[attr] || val
+ end
+ end
+
# @todo What?!
# @todo It seems that this is not used... remove it
# @deprecated Use something else (?)
View
6 lib/omnibus/util.rb
@@ -1,6 +1,6 @@
#
-# Author:: Seth Chisamore (<schisamo@opscode.com>)
-# Copyright:: Copyright (c) 2013 Opscode, Inc.
+# Author:: Seth Chisamore (<schisamo@getchef.com>)
+# Copyright:: Copyright (c) 2013-2014 Chef Software, Inc.
# License:: Apache License, Version 2.0
#
# Licensed under the Apache License, Version 2.0 (the "License");
@@ -20,7 +20,7 @@
module Omnibus
#
- # @author Seth Chisamore (<schisamo@opscode.com>)
+ # @author Seth Chisamore (<schisamo@getchef.com>)
#
module Util
# Shells out and runs +command+.
View
2  lib/omnibus/version.rb
@@ -1,5 +1,5 @@
#
-# Copyright:: Copyright (c) 2012 Opscode, Inc.
+# Copyright:: Copyright (c) 2012-2014 Chef Software, Inc.
# License:: Apache License, Version 2.0
#
# Licensed under the Apache License, Version 2.0 (the "License");
View
4 omnibus.gemspec
@@ -7,8 +7,8 @@ Gem::Specification.new do |gem|
gem.name = "omnibus"
gem.version = Omnibus::VERSION
gem.license = "Apache 2.0"
- gem.author = "Opscode"
- gem.email = "info@opscode.com"
+ gem.author = "Chef Software, Inc."
+ gem.email = "info@getchef.com"
gem.description = "Omnibus helps you build self-installing, full-stack software builds."
gem.summary = gem.description
gem.homepage = "https://github.com/opscode/omnibus-ruby"
View
2  spec/artifact_spec.rb
@@ -1,5 +1,5 @@
#
-# Copyright:: Copyright (c) 2012 Opscode, Inc.
+# Copyright:: Copyright (c) 2012-2014 Chef Software, Inc.
# License:: Apache License, Version 2.0
#
# Licensed under the Apache License, Version 2.0 (the "License");
View
2  spec/build_version_spec.rb
@@ -1,5 +1,5 @@
#
-# Copyright:: Copyright (c) 2012 Opscode, Inc.
+# Copyright:: Copyright (c) 2012-2014 Chef Software, Inc.
# License:: Apache License, Version 2.0
#
# Licensed under the Apache License, Version 2.0 (the "License");
View
41 spec/data/projects/chefdk.rb
@@ -0,0 +1,41 @@
+#
+# Copyright:: Copyright (c) 2012-2014 Chef Software, Inc.
+# License:: Apache License, Version 2.0
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+name "chefdk"
+maintainer "Chef Software, Inc."
+homepage "http://www.getchef.com"
+
+install_path "/opt/chefdk"
+build_version Omnibus::BuildVersion.full
+build_iteration 4
+
+override :berkshelf, version: "3.0.0.beta6"
+override :bundler, version: "1.5.2"
+override :libedit, version: "20130712-3.1"
+override :libtool, version: "2.4.2"
+override :libxml2, version: "2.9.1"
+override :libxslt, version: "1.1.28"
+override :nokogiri, version: "1.6.1"
+override :ruby, version: "2.1.0"
+override :rubygems, version: "2.2.1"
+override :yajl, version: "1.2.0"
+override :zlib, version: "1.2.8"
+
+dependency "preparation"
+dependency "chefdk"
+dependency "ohai"
+dependency "version-manifest"
View
2  spec/data/software/erchef.rb
@@ -1,5 +1,5 @@
#
-# Copyright:: Copyright (c) 2012 Opscode, Inc.
+# Copyright:: Copyright (c) 2012-2014 Chef Software, Inc.
# License:: Apache License, Version 2.0
#
# Licensed under the Apache License, Version 2.0 (the "License");
View
67 spec/data/software/zlib.rb
@@ -0,0 +1,67 @@
+#
+# Copyright:: Copyright (c) 2012-2014 Chef Software, Inc.
+# License:: Apache License, Version 2.0
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+name "zlib"
+default_version "1.2.6"
+
+dependency "libgcc"
+
+version "1.2.6" do
+ source md5: "618e944d7c7cd6521551e30b32322f4a"
+end
+
+version "1.2.8" do
+ source md5: "44d667c142d7cda120332623eab69f40"
+end
+
+source :url => "http://downloads.sourceforge.net/project/libpng/zlib/#{version}/zlib-#{version}.tar.gz"
+
+relative_path "zlib-#{version}"
+configure_env =
+ case platform
+ when "aix"
+ {
+ "CC" => "xlc -q64",
+ "CXX" => "xlC -q64",
+ "LD" => "ld -b64",
+ "CFLAGS" => "-q64 -I#{install_dir}/embedded/include -O",
+ "OBJECT_MODE" => "64",
+ "ARFLAGS" => "-X64 cru",
+ "LDFLAGS" => "-q64 -L#{install_dir}/embedded/lib -Wl,-blibpath:#{install_dir}/embedded/lib:/usr/lib:/lib",
+ }
+ when "mac_os_x"
+ {
+ "LDFLAGS" => "-R#{install_dir}/embedded/lib -L#{install_dir}/embedded/lib -I#{install_dir}/embedded/include",
+ "CFLAGS" => "-I#{install_dir}/embedded/include -L#{install_dir}/embedded/lib"
+ }
+ when "solaris2"
+ {
+ "LDFLAGS" => "-R#{install_dir}/embedded/lib -L#{install_dir}/embedded/lib -I#{install_dir}/embedded/include -static-libgcc",
+ "CFLAGS" => "-L#{install_dir}/embedded/lib -I#{install_dir}/embedded/include -DNO_VIZ"
+ }
+ else
+ {
+ "LDFLAGS" => "-Wl,-rpath #{install_dir}/embedded/lib -L#{install_dir}/embedded/lib -I#{install_dir}/embedded/include",
+ "CFLAGS" => "-I#{install_dir}/embedded/include -L#{install_dir}/embedded/lib"
+ }
+ end
+
+build do
+ command "./configure --prefix=#{install_dir}/embedded", :env => configure_env
+ command "make -j #{max_build_jobs}"
+ command "make -j #{max_build_jobs} install"
+end
View
2  spec/package_release_spec.rb
@@ -1,5 +1,5 @@
#
-# Copyright:: Copyright (c) 2012 Opscode, Inc.
+# Copyright:: Copyright (c) 2012-2014 Chef Software, Inc.
# License:: Apache License, Version 2.0
#
# Licensed under the Apache License, Version 2.0 (the "License");
View
32 spec/project_spec.rb
@@ -103,4 +103,36 @@
end
end
end
+
+ describe "#overrides" do
+ let(:project) { Omnibus::Project.load(project_path('chefdk')) }
+
+ it 'should set an override for the zlib version' do
+ expect(project.overrides[:zlib][:version]).to eq("1.2.8")
+ end
+
+ it 'should access the zlib version through the #override method as well' do
+ expect(project.override(:zlib)[:version]).to eq("1.2.8")
+ end
+
+ it 'should set all the things through #overrides' do
+ project.overrides(:thing => {:version => "6.6.6" })
+ expect(project.override(:zlib)).to be_nil
+ end
+
+ it 'should retrieve the things set through #overrides' do
+ project.overrides(:thing => {:version => "6.6.6" })
+ expect(project.override(:thing)[:version]).to eq("6.6.6")
+ end
+
+ it 'should not set other things through setting a single #override' do
+ project.override(:thing, :version => "6.6.6" )
+ expect(project.override(:zlib)[:version]).to eq("1.2.8")
+ end
+
+ it 'should retrieve the things set through #overrides' do
+ project.override(:thing, :version => "6.6.6" )
+ expect(project.override(:thing)[:version]).to eq("6.6.6")
+ end
+ end
end
View
2  spec/s3_cacher_spec.rb
@@ -1,5 +1,5 @@
#
-# Copyright:: Copyright (c) 2013 Opscode, Inc.
+# Copyright:: Copyright (c) 2013-2014 Chef Software, Inc.
# License:: Apache License, Version 2.0
#
# Licensed under the Apache License, Version 2.0 (the "License");
View
112 spec/software_spec.rb
@@ -6,79 +6,101 @@
describe Omnibus::Software do
let(:project) do
- p = double(Omnibus::Project)
- p.stub(:install_path).and_return("monkeys")
- p
+ double(Omnibus::Project, :install_path => "monkeys", :overrides => {})
end
let(:software_name) { "erchef" }
- let(:software_file){ software_path(software_name) }
- let(:version_from_file){ "4b19a96d57bff9bbf4764d7323b92a0944009b9e" }
- let(:software){ Omnibus::Software.load(software_file, project) }
-
- before :each do
- # We don't want to mess with any of this stuff for these
- # tests... we're just looking at version info right now
- Omnibus::Software.any_instance.stub(:render_tasks)
+ let(:software_file) { software_path(software_name) }
+
+ let(:software) do
+ Omnibus::Software.load(software_file, project)
end
- subject { software }
+ before do
+ allow_any_instance_of(Omnibus::Software).to receive(:render_tasks)
+ end
describe "#whitelist_file" do
it "appends to the whitelist_files array" do
- software.whitelist_files.size.should equal 0
+ expect(software.whitelist_files.size).to equal 0
software.whitelist_file(/foo\/bar/)
- software.whitelist_files.size.should equal 1
+ expect(software.whitelist_files.size).to equal 1
end
it "converts Strings to Regexp instances" do
software.whitelist_file "foo/bar"
- software.whitelist_files.size.should equal 1
- software.whitelist_files.first.should be_kind_of(Regexp)
+ expect(software.whitelist_files.size).to equal 1
+ expect(software.whitelist_files.first).to be_kind_of(Regexp)
end
end
- context "testing version overrides" do
+ context "testing repo-level version overrides" do
+ let(:software_name) { "zlib" }
+ let(:default_version) { "1.2.6" }
+ let(:expected_version) { "1.2.6" }
+ let(:expected_override_version) { nil }
+ let(:expected_md5) { "618e944d7c7cd6521551e30b32322f4a" }
+ let(:expected_url) { "http://downloads.sourceforge.net/project/libpng/zlib/1.2.6/zlib-1.2.6.tar.gz" }
+
+ shared_examples_for "a software definition" do
+ it "should have the same name" do
+ expect(software.name).to eq(software_name)
+ end
- context "without overrides" do
- its(:name){should eq(software_name)}
- its(:version){should eq(version_from_file)}
- its(:given_version){should eq(software.version)}
- its(:override_version){should be_nil}
- end
+ it "should have the same version" do
+ expect(software.version).to eq(expected_version)
+ end
- context "with overrides" do
- let(:override_software_version){"6.6.6"}
- let(:overrides) do
- {override_software_name => override_software_version}
+ it "should have the right default_version" do
+ expect(software.default_version).to eq(default_version)
end
- let(:software){Omnibus::Software.load(software_file, project, overrides)}
- context "but not for this software" do
- let(:override_software_name){"chaos_monkey"}
+ it "should have nil for an override_version" do
+ expect(software.override_version).to eq(expected_override_version)
+ end
- it "really should not have any overrides for this software" do
- overrides.should_not have_key(software_name)
- end
+ it "should have the md5 of the default version" do
+ expect(software.source[:md5]).to eq(expected_md5)
+ end
- its(:version){should eq(version_from_file)}
- its(:given_version){should eq(software.version)}
- its(:override_version){should be_nil}
+ it "should have the url of the default version" do
+ expect(software.source[:url]).to eq(expected_url)
end
+ end
- context "for this software" do
- let(:override_software_name){software_name}
+ context "without overrides" do
+ it_behaves_like "a software definition"
+ end
+
+ context "with overrides for different software" do
+ let(:overrides) { { "chaos_monkey" => "1.2.8" } }
+ let(:software) { Omnibus::Software.load(software_file, project, overrides) }
+
+ it_behaves_like "a software definition"
+ end
+
+ context "with overrides for this software" do
+ let(:expected_version) { "1.2.8" }
+ let(:expected_override_version) { "1.2.8" }
+ let(:overrides) { { software_name => expected_override_version } }
+ let(:software) { Omnibus::Software.load(software_file, project, overrides) }
+ let(:expected_md5) { "44d667c142d7cda120332623eab69f40" }
+ let(:expected_url) { "http://downloads.sourceforge.net/project/libpng/zlib/1.2.8/zlib-1.2.8.tar.gz" }
- it "really should have an override for this software" do
- overrides.should have_key(software_name)
- end
+ it_behaves_like "a software definition"
+ end
- its(:version){should eq(override_software_version)}
- its(:override_version){should eq(software.version)}
- its(:version){should_not eq(software.given_version)}
- its(:given_version){should eq(version_from_file)}
+ context "with an overide in the project" do
+ let(:project) do
+ double(Omnibus::Project, :install_path => "monkeys", :overrides => { :zlib => { :version => "1.2.8"} })
end
+ let(:expected_version) { "1.2.8" }
+ let(:expected_override_version) { "1.2.8" }
+ let(:expected_md5) { "44d667c142d7cda120332623eab69f40" }
+ let(:expected_url) { "http://downloads.sourceforge.net/project/libpng/zlib/1.2.8/zlib-1.2.8.tar.gz" }
+
+ it_behaves_like "a software definition"
end
end
Please sign in to comment.
Something went wrong with that request. Please try again.