---
 Rakefile                       |   11 ++++++++
 contrib/deltacloud_recipe.spec |    6 ++++-
 rake/downloadtask.rb           |   51 ++++++++++++++++++++++++++++++++++++++++
 rake/rpmtask.rb                |    7 ++++-
 4 files changed, 73 insertions(+), 2 deletions(-)
 create mode 100644 rake/downloadtask.rb

diff --git a/Rakefile b/Rakefile
index cd96a85..63a4b64 100644
--- a/Rakefile
+++ b/Rakefile
@@ -3,22 +3,33 @@
 require 'rake/clean'
 require 'rake/rpmtask'
 require 'rake/yumtask'
+require 'rake/downloadtask'
 
 CURRENT_DIR  = File.dirname(__FILE__)
 RPMBUILD_DIR = "#{CURRENT_DIR}/build/rpmbuild"
 YUM_REPO     = "#{CURRENT_DIR}/repo"
+DOWNLOAD_DIR = "#{CURRENT_DIR}/pkg"
 
 CLEAN.include('pkg', 'build', 'repo')
 CLOBBER.include('deltacloud')
 PKG_NAME = "deltacloud_recipe"
 RPM_SPEC = "contrib/deltacloud_recipe.spec"
 
+PUPPET_MODULES    = ["firewall-recipe.tgz", "ntp-recipe.tgz", 
"postgres-recipe.tgz"]
+PUPPET_MODULE_SRC = "http://repos.fedorapeople.org/repos/deltacloud/puppet/";
+
+# Download external sources we need
+Rake::DownloadTask.new(DOWNLOAD_DIR) do |dl|
+  PUPPET_MODULES.each { |m| dl.sources << PUPPET_MODULE_SRC + m }
+end
+
 # Build the rpm
 rpm_task =
 Rake::RpmTask.new(RPM_SPEC) do |rpm|
   rpm.need_tar = true
   rpm.package_files.include("bin/*", "#{PKG_NAME}/**/*")
   rpm.topdir = "#{RPMBUILD_DIR}"
+  PUPPET_MODULES.each { |m| rpm.sources << DOWNLOAD_DIR + '/' + m }
 end
 
 # Construct yum repo
diff --git a/contrib/deltacloud_recipe.spec b/contrib/deltacloud_recipe.spec
index db645aa..0ec1b2d 100644
--- a/contrib/deltacloud_recipe.spec
+++ b/contrib/deltacloud_recipe.spec
@@ -10,6 +10,9 @@ Group:    Applications/Internet
 License:  GPLv2+
 URL:      http://deltacloud.org
 Source0:  %{name}-%{version}.tgz
+Source1:  firewall-recipe.tgz
+Source2:  ntp-recipe.tgz
+Source3:  postgres-recipe.tgz
 BuildRoot:  %{_tmppath}/%{name}-%{version}
 BuildArch:  noarch
 Requires:   ruby
@@ -23,7 +26,7 @@ Requires:  curl
 Deltacloud Puppet Recipe
 
 %prep
-%setup -q
+%setup -q -a 1 -a 2 -a 3
 
 %build
 
@@ -33,6 +36,7 @@ rm -rf %{buildroot}
 %{__cp} -R %{pbuild}/%{name}/deltacloud_recipe.pp %{buildroot}/%{dchome}
 %{__cp} -R %{pbuild}/%{name}/deltacloud_uninstall.pp %{buildroot}/%{dchome}
 %{__cp} -R %{pbuild}/%{name}/*/ %{buildroot}/%{dchome}/modules/%{name}
+%{__cp} -R %{pbuild}/firewall/ %{pbuild}/ntp/ %{pbuild}/postgres/ 
%{buildroot}/%{dchome}/modules
 %{__cp} -R %{pbuild}/bin/dc-install %{buildroot}/%{_sbindir}/
 %{__cp} -R %{pbuild}/bin/dc-uninstall %{buildroot}/%{_sbindir}/
 
diff --git a/rake/downloadtask.rb b/rake/downloadtask.rb
new file mode 100644
index 0000000..7f9d9f1
--- /dev/null
+++ b/rake/downloadtask.rb
@@ -0,0 +1,51 @@
+# Define a task library to aid in the definition of downloading files
+
+require 'rubygems'
+require 'rake'
+
+# TODO right now we just use http would like to
+# incorporate other d/l mechanisms as well
+require 'net/http'
+require 'uri'
+
+module Rake
+
+  # Download the specified sources into the specified directory
+  class DownloadTask < TaskLib
+    # Directory which to download sources into
+    attr_accessor :dir
+
+    # Source uris which to download
+    attr_accessor :sources
+
+    def initialize(dir)
+      init(dir)
+      yield self if block_given?
+      define if block_given?
+    end
+
+    def init(dir)
+      @dir = dir
+      @sources = []
+    end
+
+    def define
+      directory @dir
+      @dest_files = []
+
+      @sources.each { |src|
+        src_file  = src.split('/').last
+        dest_file = "#...@dir}/#{src_file}" 
+        @dest_files << dest_file
+        file dest_file => @dir do
+          # TODO error / redirection handling
+          res = Net::HTTP.get_response(URI.parse(src)).body
+          File.open(dest_file, "w") { |f| f.write res }
+        end
+      }
+
+      desc "Download the sources"
+      task :download => @dest_files
+    end
+  end
+end
diff --git a/rake/rpmtask.rb b/rake/rpmtask.rb
index ff2ee66..17185f1 100644
--- a/rake/rpmtask.rb
+++ b/rake/rpmtask.rb
@@ -18,6 +18,9 @@ module Rake
     # RPM build dir
     attr_accessor :topdir
 
+    # Other sources to make available to rpmbuild
+    attr_accessor :sources
+
     def initialize(rpm_spec)
       init(rpm_spec)
       yield self if block_given?
@@ -54,6 +57,7 @@ module Rake
       super(@name, @version)
 
       @rpmbuild_cmd = 'rpmbuild'
+      @sources      = Rake::FileList.new
     end
 
     def define
@@ -66,7 +70,8 @@ module Rake
       task :rpms => [rpm_file]
 
       # FIXME properly determine :package build artifact(s) to copy to sources 
dir
-      file rpm_file => [:package, "#...@topdir}/SOURCES", 
"#...@topdir}/SPECS"] do
+      file rpm_file => [:package, "#...@topdir}/SOURCES", 
"#...@topdir}/SPECS"] + @sources do
+        @sources.each { |src| cp src, "#...@topdir}/SOURCES/" }
         cp "#{package_dir}/#...@name}-#{@version}.tgz", "#...@topdir}/SOURCES/"
         cp @rpm_spec, "#...@topdir}/SPECS"
         sh "#...@rpmbuild_cmd} --define '_topdir #...@topdir}' -ba 
#...@rpm_spec}"
-- 
1.7.2.3

_______________________________________________
deltacloud-devel mailing list
[email protected]
https://fedorahosted.org/mailman/listinfo/deltacloud-devel

Reply via email to