Permalink
Browse files

add autogen.sh support and extension attribute

  • Loading branch information...
1 parent eb7c3ef commit bd621b2b8f1a90954e9879ba04e5c2b8bbfcdd50 @bryanwb committed May 23, 2012
Showing with 65 additions and 30 deletions.
  1. +15 −0 CHANGELOG.md
  2. +4 −9 README.md
  3. +4 −0 files/default/tests/minitest/test_test.rb
  4. +33 −19 libraries/provider_ark.rb
  5. +2 −1 libraries/resource_ark.rb
  6. +1 −1 metadata.rb
  7. +6 −0 recipes/test.rb
View
@@ -0,0 +1,15 @@
+0.0.10 (May 23, 2012)
+---------------------
+
+New features
+* use autogen.sh to generate configure script for configure action
+ https://github.com/bryanwb/chef-ark/issues/16
+* support more file extensions https://github.com/bryanwb/chef-ark/pull/18
+* add extension attribute which allows you to download files which do
+ not have the file extension as part of the URL
+
+Bug fixes
+* strip_leading_dir not working for zip files
+ https://github.com/bryanwb/chef-ark/issues/19
+
+
View
@@ -1,14 +1,6 @@
Overview
========
-
-''Notice''
-14 April 2012: The ark API has changed!
-
-The ark_put, ark_dump, ark_cherry_pick have been rolled into the main
-ark library as the actions :put, :dump, and :cherry_pick. Please
-review the README carefully
-
An ''ark'' is like an archive but ''Kewler''
Does the fetch-unpack-configure-build-install dance. This is a
@@ -105,7 +97,10 @@ ark
currently supported. Also supports special syntax
:name:version:apache_mirror: that will auto-magically construct
download url from the apache mirrors site
-- version: software version, required
+- version: software version, defaults to "1" if not specified. The :dump, :cherry_pick, and :put actions do not use it
+- extension: The file extension of the file you are trying to
+ download. If not specified, ark tries to determine the file
+ extension by parsing the URL
- checksum: sha256 checksum, used for security
- mode: file mode for app_home, is an integer TODO
- prefix_root: default prefix_root, for use with :install* actions
@@ -82,5 +82,9 @@
it "sends notification when resource updated" do
file("/tmp/foobarbaz/notification_successful.txt").must_exist
end
+
+ it "uses autogen.sh to generate configure script" do
+ file("/usr/local/test_autogen-1/configure").must_exist
+ end
end
View
@@ -58,16 +58,28 @@ def action_install
action_link_paths
end
+ def action_autogen
+ b = Chef::Resource::Script::Bash.new("autogen.sh to generate configure", run_context)
+ b.cwd new_resource.path
+ b.environment new_resource.environment
+ b.code "./autogen.sh"
+ b.run_action(:run)
+ end
+
def action_configure
set_paths
action_download
action_unpack
- b = Chef::Resource::Execute.new("configure with autoconf", run_context)
- b.cwd new_resource.path
- b.environment new_resource.environment
- b.command "./configure #{new_resource.autoconf_opts.join(' ')}"
- b.not_if{ ::File.exists?(::File.join(new_resource.path, 'config.status')) }
- b.run_action(:run)
+ unless ::File.exists?(::File.join(new_resource.path, 'configure'))
+ action_autogen
+ end
+ unless ::File.exists?(::File.join(new_resource.path, 'config.status'))
+ b = Chef::Resource::Execute.new("configure with autoconf", run_context)
+ b.cwd new_resource.path
+ b.environment new_resource.environment
+ b.command "./configure #{new_resource.autoconf_opts.join(' ')}"
+ b.run_action(:run)
+ end
end
def action_build_with_make
@@ -203,6 +215,7 @@ def set_paths
end
# set effective paths
new_resource.prefix_bin = prefix_bin
+ new_resource.version ||= "1" # initialize to one if nil
new_resource.path = ::File.join(prefix_root, "#{new_resource.name}-#{new_resource.version}")
new_resource.home_dir ||= default_home_dir
Chef::Log.debug("path is #{new_resource.path}")
@@ -223,17 +236,20 @@ def set_dump_paths
end
def parse_file_extension
- # purge any trailing redirect
- url = new_resource.url.clone
- url =~ /^https?:\/\/.*(.gz|bz2|bin|zip|jar|tgz|tbz)(\/.*\/)/
- url.gsub!($2, '') unless $2.nil?
- # remove tailing query string
- release_basename = ::File.basename(url.gsub(/\?.*\z/, '')).gsub(/-bin\b/, '')
- # (\?.*)? accounts for a trailing querystring
- Chef::Log.debug("release_basename is #{release_basename}")
- release_basename =~ %r{^(.+?)\.(tar\.gz|tar\.bz2|zip|war|jar|tgz|tbz)(\?.*)?}
- Chef::Log.debug("file_extension is #{$2}")
- extension = $2
+ if new_resource.extension.nil?
+ # purge any trailing redirect
+ url = new_resource.url.clone
+ url =~ /^https?:\/\/.*(.gz|bz2|bin|zip|jar|tgz|tbz)(\/.*\/)/
+ url.gsub!($2, '') unless $2.nil?
+ # remove tailing query string
+ release_basename = ::File.basename(url.gsub(/\?.*\z/, '')).gsub(/-bin\b/, '')
+ # (\?.*)? accounts for a trailing querystring
+ Chef::Log.debug("release_basename is #{release_basename}")
+ release_basename =~ %r{^(.+?)\.(tar\.gz|tar\.bz2|zip|war|jar|tgz|tbz)(\?.*)?}
+ Chef::Log.debug("file_extension is #{$2}")
+ new_resource.extension = $2
+ end
+ new_resource.extension
end
def set_apache_url(url_ref)
@@ -258,8 +274,6 @@ def unzip
subdir = subdirectory_children[0]
subdirectory_children = Dir.glob("#{subdir}/**")
end
- require 'pry'
- binding.pry
FileUtils.mv subdirectory_children, new_resource.path
FileUtils.rm_rf tmpdir
else
@@ -32,7 +32,7 @@ def initialize(name, run_context=nil)
@provider = Chef::Provider::Ark
end
- attr_accessor :path, :release_file, :prefix_bin, :prefix_root, :home_dir
+ attr_accessor :path, :release_file, :prefix_bin, :prefix_root, :home_dir, :extension, :version
attribute :owner, :kind_of => String, :default => 'root'
attribute :group, :kind_of => [String, Fixnum], :default => 0
@@ -56,6 +56,7 @@ def initialize(name, run_context=nil)
attribute :make_opts, :kind_of => Array, :default => []
attribute :home_dir, :kind_of => String, :default => nil
attribute :autoconf_opts, :kind_of => Array, :default => []
+ attribute :extension, :kind_of => String
end
end
View
@@ -3,7 +3,7 @@
license "Apache 2.0"
description "Installs/Configures ark"
long_description IO.read(File.join(File.dirname(__FILE__), 'README.md'))
-version "0.0.9"
+version "0.0.10"
%w{ debian ubuntu centos redhat fedora }.each do |os|
supports os
View
@@ -123,3 +123,9 @@
action :dump
notifies :create, "ruby_block[test_notification]", :immediately
end
+
+ark "test_autogen" do
+ url 'https://github.com/zeromq/libzmq/tarball/master'
+ extension "tar.gz"
+ action :configure
+end

0 comments on commit bd621b2

Please sign in to comment.