Skip to content
Browse files

Added Rakefile to help with creating tarball for distribution

  • Loading branch information...
1 parent 7f2d1a0 commit 1b202670c1a684403837b058c1a12ee1682aa1fb @kohder committed Jul 6, 2011
Showing with 35 additions and 0 deletions.
  1. +35 −0 Rakefile
View
35 Rakefile
@@ -0,0 +1,35 @@
+require 'fileutils'
+require 'tempfile'
+
+COOKBOOK_DIR = File.dirname(__FILE__)
+COOKBOOK_NAME = 'hosts-awareness'
+MANIFEST = %w{
+ attributes
+ libraries
+ recipes
+ metadata.*
+ README.*
+}
+
+desc 'Create tarball of cookbook for distribution'
+task :create_tarball do
+ metadata_rb = File.join(COOKBOOK_DIR, 'metadata.rb')
+ system("knife cookbook metadata from file #{metadata_rb}")
+ tarball_name = "#{COOKBOOK_NAME}.tgz"
+ temp_dir = File.join(Dir.tmpdir, 'chef-cookbooks')
+ temp_cookbook_dir = File.join(temp_dir, COOKBOOK_NAME)
+ dist_dir = File.join(COOKBOOK_DIR, 'dist')
+
+ FileUtils.mkdir_p(dist_dir)
+ FileUtils.mkdir(temp_dir)
+ FileUtils.mkdir(temp_cookbook_dir)
+
+ files = MANIFEST.inject([]) do |arr, manifest_entry|
+ arr + Dir.glob(File.join(COOKBOOK_DIR, manifest_entry))
+ end
+ FileUtils.cp_r files, temp_cookbook_dir
+
+ system('tar', '-C', temp_dir, '-cvzf', File.join(dist_dir, tarball_name), File.join('.', COOKBOOK_NAME))
+
+ FileUtils.rm_rf temp_dir
+end

0 comments on commit 1b20267

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