Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

tar cookbook

  • Loading branch information...
commit be4e2221899ba60ac36908d11d53054c45f34f64 1 parent 4d2ad06
@smith smith authored
View
51 tar/README.md
@@ -0,0 +1,51 @@
+DESCRIPTION
+===========
+
+Installs tar and a resource for source package compilation.
+
+LICENSE AND AUTHOR
+==================
+
+Author:: Nathan L Smith (<nathan@cramerdev.com>)
+
+Copyright 2011, Cramer Development, Inc.
+
+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.
+
+Resources/Providers
+===================
+
+A `tar_package` LWRP provides an easy way to download remote files and compile and install them.
+
+This only works for the most basic Autoconf programs that can do `./configure && make && make install`.
+
+# Actions
+
+- :install: Installs the package
+
+# Attribute Parameters
+
+- source: name attribute. The source remote URL.
+- prefix: Directory to be used as the `--prefix` configure flag.
+- source\_directory: Directory to which source files are download.
+- creates: A file this command creates - if the file exists, the command will not be run.
+- configure\_flags: Array of additional flags to be passed to `./configure`.
+
+# Example
+
+ tar_package 'http://pgfoundry.org/frs/download.php/1446/pgpool-3.4.1.tar.gz' do
+ prefix '/usr/local'
+ creates '/usr/local/bin/pgpool'
+ end
+
+This will download, compile, and install the package from the given URL and install it into /usr/local.
View
6 tar/metadata.rb
@@ -0,0 +1,6 @@
+maintainer "Cramer Development, Inc."
+maintainer_email "sysadmin@cramerdev.com"
+license "Apache 2.0"
+description "Installs tar and a tar_package resource"
+long_description IO.read(File.join(File.dirname(__FILE__), 'README.md'))
+version "0.0.1"
View
48 tar/providers/package.rb
@@ -0,0 +1,48 @@
+#
+# Cookbook Name:: tar
+# Provider:: package
+#
+# Author:: Nathan L Smith (<nathan@cramerdev.com>)
+#
+# Copyright 2011, Cramer Development, Inc.
+#
+# 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.
+#
+
+action :install do
+ r = new_resource
+ basename = ::File.basename(r.name)
+ dirname = basename.chomp('.tar.gz') # Assuming .tar.gz
+ src_dir = r.source_directory
+
+ remote_file basename do
+ source r.name
+ path "#{src_dir}/#{basename}"
+ backup false
+ action :create_if_missing
+ end
+
+ execute "extract #{basename}" do
+ command "tar xfz #{basename}"
+ cwd src_dir
+ creates "#{src_dir}/#{dirname}"
+ end
+
+ execute "compile & install #{dirname}" do
+ flags = (r.prefix ? "--prefix=#{r.prefix}" : '') + "#{r.configure_flags.join(' ')}"
+ command "./configure --quiet #{flags} && make --quiet && make --quiet install"
+ cwd "#{src_dir}/#{dirname}"
+ creates r.creates
+ end
+end
+
View
22 tar/recipes/default.rb
@@ -0,0 +1,22 @@
+#
+# Cookbook Name:: tar
+# Recipe:: default
+#
+# Author:: Nathan L Smith (<nathan@cramerdev.com>)
+#
+# Copyright 2011, Cramer Development, Inc.
+#
+# 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.
+#
+
+package 'tar'
View
34 tar/resources/package.rb
@@ -0,0 +1,34 @@
+#
+# Cookbook Name:: tar
+# Resource:: package
+#
+# Author:: Nathan L Smith (<nathan@cramerdev.com>)
+#
+# Copyright 2011, Cramer Development, Inc.
+#
+# 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.
+#
+
+actions :install
+
+attribute :source, :name_attribute => true, :kind_of => String
+attribute :prefix, :kind_of => String
+attribute :source_directory, :kind_of => String, :default => '/usr/local/src'
+attribute :creates, :kind_of => String
+attribute :configure_flags, :kind_of => Array, :default => []
+
+# Make :install the default action
+def initialize(*args)
+ super
+ @action = :install
+end
Please sign in to comment.
Something went wrong with that request. Please try again.