Skip to content
Browse files

Import build-essential version 1.1.0

  • Loading branch information...
1 parent 849b2e6 commit c375f62b01baa596b777bbf94f571dc89d596ba6 Hoang Xuan Phu committed Jul 16, 2012
View
7 build-essential/CHANGELOG.md
@@ -1,3 +1,10 @@
+## v1.1.0:
+
+* [COOK-1098] - support amazon linux
+* [COOK-1149] - support Mac OS X
+* [COOK-1296] - allow for compile-time installation of packages
+ through an attribute (see README)
+
## v1.0.2:
* [COOK-1098] - Add Amazon Linux platform support
View
108 build-essential/README.md
@@ -1,15 +1,115 @@
-DESCRIPTION
+Description
===========
-Installs packages required for compiling C software from source.
+Installs packages required for compiling C software from source. Use
+this cookbook if you wish to compile C programs, or install RubyGems
+with native extensions.
-LICENSE AND AUTHOR
+Requirements
+============
+
+## Platform
+
+Supported platforms by platform family:
+
+* Linux (debian, rhel, fedora)
+* Darwin (`mac_os_x` 10.6+)
+
+Attributes
+==========
+
+* `node['build_essential']['compiletime']` - Whether the resources in
+the default recipe should be configured at the "Compile" phase of the
+Chef run. Defaults to false, see __Usage__ for more information.
+* `node['build_essential']['osx']['gcc_installer_url']` - The URL of
+ the OS X GCC package installer (.pkg).
+* `node['build_essential']['osx']['gcc_installer_checksum']` - The
+ SHA256 checksum of the OS X GCC installer.
+
+Recipes
+=======
+
+This cookbook has one recipe, default.
+
+On Linux platforms (see __Platform__ above for a supported list of
+families), packages required to build C source projects are installed.
+This includes GCC, make, autconf and others. On Debian-family
+distributions, the apt-cache may need to be updated, especially during
+compile time installation. See __Usage__ for further information.
+
+On Mac OS X, the GCC standalone installer by Kenneth Reitz is
+installed. Note that this is *not* the Xcode CLI package, as that does
+not include all programs and headers required to build some common
+GNU-style C projects, such as those that are available from projects
+such as MacPorts or Homebrew. Changing the attributes for the GCC
+installer URL and checksum to the Xcode values may work, but this is
+untested.
+
+Usage
+=====
+
+Simply include the `build-essential` and the required tools will be
+installed to the system, and later recipes will be able to compile
+software from C source code.
+
+For RubyGems that include native C extensions you wish to use with
+Chef, you should do two things.
+
+0. Ensure that the C libraries, include files and other assorted "dev"
+type packages are installed. You should do this in the compile phase
+after the build-essential recipe.
+1. Use the `chef_gem` resource in your recipes. This requires Chef version 0.10.10+.
+2. Set the `compiletime` attribute in roles where such recipes are
+required. This will ensure that the build tools are available to
+compile the RubyGems' extensions, as `chef_gem` happens during the
+compile phase, too.
+
+Example installation of a devel package at compile-time in a recipe:
+
+ package "mypackage-dev" do
+ action :nothing
+ end.run_action(:install)
+
+Example use of `chef_gem`:
+
+ chef_gem "mygem"
+
+Example role:
+
+ name "myapp"
+ run_list(
+ "recipe[build-essential]",
+ "recipe[myapp]"
+ )
+ default_attributes(
+ "build-essential" => {
+ "compiletime" => true
+ }
+ )
+
+The compile time option (via the attribute) is to ensure that the
+proper packages are available at the right time in the Chef run. It is
+recommended that the build-essential recipe appear early in the run
+list.
+
+The Chef wiki has documentation on
+[the anatomy of a chef run](http://wiki.opscode.com/display/chef/Anatomy+of+a+Chef+Run).
+
+Limitations
+===========
+
+It is not in the scope of this cookbook to handle installing the
+required headers for individual software projects in order to compile
+them, or to compile RubyGems with native C extensions. You should
+create a cookbook for handling that.
+
+License and Author
==================
Author:: Joshua Timberman (<joshua@opscode.com>)
Author:: Seth Chisamore (<schisamo@opscode.com>)
-Copyright 2009-2011, Opscode, Inc.
+Copyright 2009-2011, Opscode, Inc. (<legal@opscode.com>)
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
View
2 build-essential/attributes/default.rb
@@ -17,6 +17,8 @@
# limitations under the License.
#
+default['build_essential']['compiletime'] = false
+
case platform
when "mac_os_x"
case
View
2 build-essential/metadata.json
@@ -33,5 +33,5 @@
"recipes": {
"build-essential": "Installs packages required for compiling C software from source."
},
- "version": "1.0.2"
+ "version": "1.1.0"
}
View
2 build-essential/metadata.rb
@@ -2,7 +2,7 @@
maintainer_email "cookbooks@opscode.com"
license "Apache 2.0"
description "Installs C compiler / build tools"
-version "1.0.2"
+version "1.1.0"
recipe "build-essential", "Installs packages required for compiling C software from source."
%w{ fedora redhat centos ubuntu debian amazon }.each do |os|
View
48 build-essential/recipes/default.rb
@@ -19,41 +19,61 @@
require 'chef/shell_out'
+compiletime = node['build_essential']['compiletime']
+
case node['os']
when "linux"
- packages = value_for_platform(
- ["ubuntu", "debian"] => {
- "default" => ["build-essential", "binutils-doc"]
- },
- ["centos", "redhat", "fedora", "amazon"] => {
- "default" => ["gcc", "gcc-c++", "kernel-devel", "make"]
- }
- )
+
+ # on apt-based platforms when first provisioning we need to force
+ # apt-get update at compiletime if we are going to try to install at compiletime
+ if node['platform_family'] == "debian"
+ execute "apt-get update" do
+ action :nothing
+ # tip: to suppress this running every time, just use the apt cookbook
+ not_if do
+ ::File.exists?('/var/lib/apt/periodic/update-success-stamp') &&
+ ::File.mtime('/var/lib/apt/periodic/update-success-stamp') > Time.now - 86400*2
+ end
+ end.run_action(:run) if compiletime
+ end
+
+ packages = case node['platform_family']
+ when "debian"
+ %w{build-essential binutils-doc}
+ when "rhel", "fedora"
+ %w{gcc gcc-c++ kernel-devel make}
+ end
packages.each do |pkg|
- package pkg do
- action :install
+ r = package pkg do
+ action ( compiletime ? :nothing : :install )
end
+ r.run_action(:install) if compiletime
end
%w{autoconf flex bison}.each do |pkg|
- package pkg do
- action :install
+ r = package pkg do
+ action ( compiletime ? :nothing : :install )
end
+ r.run_action(:install) if compiletime
end
when "darwin"
result = Chef::ShellOut.new("pkgutil --pkgs").run_command
installed = result.stdout.split("\n").include?("com.apple.pkg.gcc4.2Leo")
pkg_filename = File.basename(node['build_essential']['osx']['gcc_installer_url'])
pkg_path = "#{Chef::Config[:file_cache_path]}/#{pkg_filename}"
- remote_file pkg_path do
+ r = remote_file pkg_path do
source node['build_essential']['osx']['gcc_installer_url']
checksum node['build_essential']['osx']['gcc_installer_checksum']
+ action ( compiletime ? :nothing : :create )
not_if { installed }
end
+ r.run_action(:create) if compiletime
- execute "sudo installer -pkg \"#{pkg_path}\" -target /" do
+ r = execute "sudo installer -pkg \"#{pkg_path}\" -target /" do
+ action ( compiletime ? :nothing : :run )
not_if { installed }
end
+ r.run_action(:run) if compiletime
end

0 comments on commit c375f62

Please sign in to comment.
Something went wrong with that request. Please try again.