Permalink
Browse files

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

project overrides of software definitions
  • Loading branch information...
2 parents b048ba9 + 4912658 commit 7d3ad8b4be1d4ee1ff96c0d805764af7f15922bc @lamont-granquist lamont-granquist committed Feb 27, 2014
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
@@ -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
@@ -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");
@@ -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
@@ -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)
@@ -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
@@ -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");
@@ -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
@@ -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
@@ -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
@@ -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");
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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");
@@ -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");
@@ -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");
@@ -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");
@@ -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");
@@ -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
@@ -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
@@ -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
@@ -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]
Oops, something went wrong.

0 comments on commit 7d3ad8b

Please sign in to comment.