[PATCH aeolus-image-rubygem] Changes to build behavior in rpmtask.rb, Rakefile

Steve Linabery slinaber at redhat.com
Wed Dec 21 21:14:28 UTC 2011


Source a .spec.in file and output .spec.
Determine whether to include extra_release based on setting of Release in .spec.in
Make Version a constant in Rakefile.
---
 Rakefile                     |    6 ++-
 rake/rpmtask.rb              |   28 ++++++++----
 rubygem-aeolus-image.spec    |   99 ------------------------------------------
 rubygem-aeolus-image.spec.in |   99 ++++++++++++++++++++++++++++++++++++++++++
 4 files changed, 122 insertions(+), 110 deletions(-)
 delete mode 100644 rubygem-aeolus-image.spec
 create mode 100644 rubygem-aeolus-image.spec.in

diff --git a/Rakefile b/Rakefile
index abb6d46..121a297 100644
--- a/Rakefile
+++ b/Rakefile
@@ -23,10 +23,12 @@ require 'rake/rpmtask'
 
 RPMBUILD_DIR = "#{File.expand_path('~')}/rpmbuild"
 RPM_SPEC = "rubygem-aeolus-image.spec"
+RPM_SPEC_IN = "rubygem-aeolus-image.spec.in"
+PKG_VERSION = "0.3.0"
 
 spec = Gem::Specification.new do |s|
   s.name = 'aeolus-image'
-  s.version = '0.3.0'
+  s.version = PKG_VERSION
   s.summary= 'cli for aeolus cloud suite'
   s.description = 'Commandline interface for working with the aeolus cloud management suite'
   s.author = 'Jason Guiditta, Martyn Taylor'
@@ -65,7 +67,7 @@ RSpec::Core::RakeTask.new do |t|
   t.pattern = FileList['spec/**/*.rb']
 end
 
-Rake::RpmTask.new(RPM_SPEC) do |rpm|
+Rake::RpmTask.new(RPM_SPEC_IN,RPM_SPEC,PKG_VERSION) do |rpm|
   rpm.need_tar = true
   rpm.package_files.include("lib/*")
   rpm.topdir = "#{RPMBUILD_DIR}"
diff --git a/rake/rpmtask.rb b/rake/rpmtask.rb
index 93d24e9..934ad06 100644
--- a/rake/rpmtask.rb
+++ b/rake/rpmtask.rb
@@ -26,25 +26,39 @@ module Rake
   # Create a package based upon a RPM spec.
   # RPM packages, can be produced by this task.
   class RpmTask < PackageTask
-    # RPM spec containing the metadata for this package
+    # input RPM spec containing the metadata for this package
+    attr_accessor :rpm_spec_in
+
+    # filename for output RPM spec
     attr_accessor :rpm_spec
 
+    # package version
+    attr_accessor :pkg_version
+    
     # RPM build dir
     attr_accessor :topdir
 
     # Include extra_release information in the rpm
     attr_accessor :include_extra_release
 
-    def initialize(rpm_spec)
-      init(rpm_spec)
+    def initialize(rpm_spec_in,rpm_spec,pkg_version)
+      init(rpm_spec_in,rpm_spec,pkg_version)
       yield self if block_given?
       define if block_given?
     end
 
-    def init(rpm_spec)
-      @include_extra_release = true
+    def init(rpm_spec_in,rpm_spec,pkg_version)
+      @rpm_spec_in = rpm_spec_in
       @rpm_spec = rpm_spec
+      @pkg_version = pkg_version
+
+      @include_extra_release = eval `grep -q '^[[:space:]]*Release:[[:space:]]*0' #{@rpm_spec_in} && echo true || echo false`
+
+      git_head = `git log -1 --pretty=format:%h`
+      extra_release = @include_extra_release ? ("." + Time.now.strftime("%Y%m%d%H%M%S").gsub(/\s/, '') + "git" + "#{git_head}") : ''
 
+      `sed -e "s|@VERSION@|#{@pkg_version}|;s|^\\(Release:[^%]*\\)|\\1#{extra_release}|" #{@rpm_spec_in} > #{@rpm_spec}`
+      
       # parse this out of the rpmbuild macros,
       # not ideal but better than hardcoding this
       File.open('/etc/rpm/macros.dist', "r") { |f|
@@ -94,16 +108,12 @@ module Rake
 
       # FIXME properly determine :package build artifact(s) to copy to sources dir
       file rpm_file, [:include_extra_release] => [:package, "#{@topdir}/SOURCES", "#{@topdir}/SPECS"] do |t,args|
-        @include_extra_release = args.include_extra_release != "false"
-        git_head = `git log -1 --pretty=format:%h`
-        extra_release = "." + Time.now.strftime("%Y%m%d%H%M%S").gsub(/\s/, '') + "git" + "#{git_head}"
         cp "#{package_dir}/#{@name}-#{@version}.tgz", "#{@topdir}/SOURCES/"
         # FIXME - This seems like a hack, but we don't know the gem's name
 	cp "#{package_dir}/#{@name.gsub('rubygem-', '')}-#{@version}.gem", "#{@topdir}/SOURCES/"
         cp @rpm_spec, "#{@topdir}/SPECS"
         sh "#{@rpmbuild_cmd} " +
            "--define '_topdir #{@topdir}' " +
-           "--define 'extra_release #{@include_extra_release ? extra_release : ''}' " +
            "-ba #{@rpm_spec}"
       end
     end
diff --git a/rubygem-aeolus-image.spec b/rubygem-aeolus-image.spec
deleted file mode 100644
index e3c4c3a..0000000
--- a/rubygem-aeolus-image.spec
+++ /dev/null
@@ -1,99 +0,0 @@
-%global gemdir %(ruby -rubygems -e 'puts Gem::dir' 2>/dev/null)
-%global gemname aeolus-image
-%global geminstdir %{gemdir}/gems/%{gemname}-%{version}
-%global rubyabi 1.8
-
-Summary: Ruby Client for interacting with Image Warehouse and Image Factory
-Name: rubygem-aeolus-image
-Version: 0.3.0
-Release: 0%{?extra_release}%{?dist}
-Group: Development/Languages
-License: ASL 2.0
-URL: http://aeolusproject.org
-
-Source0: %{gemname}-%{version}.gem
-
-Requires: ruby(abi) = %{rubyabi}
-Requires: rubygems
-Requires: rubygem(nokogiri) >= 1.4.0
-Requires: rubygem(rest-client)
-Requires: rubygem(imagefactory-console) >= 0.4.0
-Requires: rubygem(oauth)
-Requires: rubygem(vcr)
-Requires: rubygem(webmock)
-Requires: rubygem(timecop)
-
-BuildRequires: ruby
-BuildRequires: rubygems
-
-BuildArch: noarch
-Provides: rubygem(%{gemname}) = %{version}
-
-%description
-Ruby Client for Image Warehouse and Image Factory
-
-%prep
-%setup -q -c -T
-mkdir -p ./%{gemdir}
-gem install --local --install-dir ./%{gemdir} --force --rdoc %{SOURCE0}
-
-%build
-
-%install
-rm -rf %{buildroot}
-mkdir -p %{buildroot}%{gemdir}
-cp -a .%{gemdir}/* %{buildroot}%{gemdir}/
-
-rm -rf %{buildroot}%{gemdir}/gems/%{gemname}-%{version}/.yardoc
-
-%files
-%doc %{geminstdir}/COPYING
-%doc %{gemdir}/doc/%{gemname}-%{version}
-%dir %{geminstdir}
-%{geminstdir}/Rakefile
-%{geminstdir}/lib
-%{geminstdir}/spec
-%{gemdir}/cache/%{gemname}-%{version}.gem
-%{gemdir}/specifications/%{gemname}-%{version}.gemspec
-
-%changelog
-* Thu Dec  1 2011 Steve Linabery <slinaber at redhat.com> - 0.2.0-1
-- d451628 Fixed creation of a bucket when saving a bucket object
-- 289dcbf Added builder helper methods
-- 4f708c8 Added couple of helper methods to image model
-- 6ae089c Added convenience methods for checking providerimages on image/build
-- 90154e0 Updated models to use iwhd query syntax
-- 1cba777 Fixed comparing of two warehouse objects
-- 2e2d735 Commented out couple of tests
-- 4b6408d Updated fetching of template for an image
-- 424c117 Added create method and enabled access to body
-- dd829cd BZ#752494 Handle 404 for status in rubygem
-- 5d4cdc0 Add tests for aeolus-image-rubygem
-- 0706f29 Fixed request_without_oauth method
-- a121b34 Fixed template body initialize
-- 105420b Updated warehouse models initialize method and fixed image body
-- cd55966 adding icicle support
-- 3aa588a Fixes formatting of README.md
-- 0cf1a58 Adds README file
-
-* Tue Nov 29 2011 Steve Linabery <slinaber at redhat.com> - 0.2.0-0
-- Bump release, set version to 0
-
-* Mon Oct 17 2011 Matt Wagner <matt.wagner at redhat.com> - 0.0.1-4
-- Adds OAuth support for Factory client
-- Add vcr and webmock dependencies
-
-* Tue Sep 20 2011 Martyn Taylor  <mtaylor at redhat.com>  - 0.0.1-3
-- split out command line tools
-
-* Wed Jul 20 2011 Mo Morsi <mmorsi at redhat.com>  - 0.0.1-3
-- more updates to conform to fedora guidelines
-
-* Fri Jul 15 2011 Mo Morsi <mmorsi at redhat.com>  - 0.0.1-2
-- updated package to conform to fedora guidelines
-
-* Mon Jul 04 2011  <mtaylor at redhat.com>  - 0.0.1-1
-- Added man files
-
-* Wed Jun 15 2011  <jguiditt at redhat.com> - 0.0.1-1
-- Initial package
diff --git a/rubygem-aeolus-image.spec.in b/rubygem-aeolus-image.spec.in
new file mode 100644
index 0000000..8e700a3
--- /dev/null
+++ b/rubygem-aeolus-image.spec.in
@@ -0,0 +1,99 @@
+%global gemdir %(ruby -rubygems -e 'puts Gem::dir' 2>/dev/null)
+%global gemname aeolus-image
+%global geminstdir %{gemdir}/gems/%{gemname}-%{version}
+%global rubyabi 1.8
+
+Summary: Ruby Client for interacting with Image Warehouse and Image Factory
+Name: rubygem-aeolus-image
+Version: @VERSION@
+Release: 0%{?extra_release}%{?dist}
+Group: Development/Languages
+License: ASL 2.0
+URL: http://aeolusproject.org
+
+Source0: %{gemname}-%{version}.gem
+
+Requires: ruby(abi) = %{rubyabi}
+Requires: rubygems
+Requires: rubygem(nokogiri) >= 1.4.0
+Requires: rubygem(rest-client)
+Requires: rubygem(imagefactory-console) >= 0.4.0
+Requires: rubygem(oauth)
+Requires: rubygem(vcr)
+Requires: rubygem(webmock)
+Requires: rubygem(timecop)
+
+BuildRequires: ruby
+BuildRequires: rubygems
+
+BuildArch: noarch
+Provides: rubygem(%{gemname}) = %{version}
+
+%description
+Ruby Client for Image Warehouse and Image Factory
+
+%prep
+%setup -q -c -T
+mkdir -p ./%{gemdir}
+gem install --local --install-dir ./%{gemdir} --force --rdoc %{SOURCE0}
+
+%build
+
+%install
+rm -rf %{buildroot}
+mkdir -p %{buildroot}%{gemdir}
+cp -a .%{gemdir}/* %{buildroot}%{gemdir}/
+
+rm -rf %{buildroot}%{gemdir}/gems/%{gemname}-%{version}/.yardoc
+
+%files
+%doc %{geminstdir}/COPYING
+%doc %{gemdir}/doc/%{gemname}-%{version}
+%dir %{geminstdir}
+%{geminstdir}/Rakefile
+%{geminstdir}/lib
+%{geminstdir}/spec
+%{gemdir}/cache/%{gemname}-%{version}.gem
+%{gemdir}/specifications/%{gemname}-%{version}.gemspec
+
+%changelog
+* Thu Dec  1 2011 Steve Linabery <slinaber at redhat.com> - 0.2.0-1
+- d451628 Fixed creation of a bucket when saving a bucket object
+- 289dcbf Added builder helper methods
+- 4f708c8 Added couple of helper methods to image model
+- 6ae089c Added convenience methods for checking providerimages on image/build
+- 90154e0 Updated models to use iwhd query syntax
+- 1cba777 Fixed comparing of two warehouse objects
+- 2e2d735 Commented out couple of tests
+- 4b6408d Updated fetching of template for an image
+- 424c117 Added create method and enabled access to body
+- dd829cd BZ#752494 Handle 404 for status in rubygem
+- 5d4cdc0 Add tests for aeolus-image-rubygem
+- 0706f29 Fixed request_without_oauth method
+- a121b34 Fixed template body initialize
+- 105420b Updated warehouse models initialize method and fixed image body
+- cd55966 adding icicle support
+- 3aa588a Fixes formatting of README.md
+- 0cf1a58 Adds README file
+
+* Tue Nov 29 2011 Steve Linabery <slinaber at redhat.com> - 0.2.0-0
+- Bump release, set version to 0
+
+* Mon Oct 17 2011 Matt Wagner <matt.wagner at redhat.com> - 0.0.1-4
+- Adds OAuth support for Factory client
+- Add vcr and webmock dependencies
+
+* Tue Sep 20 2011 Martyn Taylor  <mtaylor at redhat.com>  - 0.0.1-3
+- split out command line tools
+
+* Wed Jul 20 2011 Mo Morsi <mmorsi at redhat.com>  - 0.0.1-3
+- more updates to conform to fedora guidelines
+
+* Fri Jul 15 2011 Mo Morsi <mmorsi at redhat.com>  - 0.0.1-2
+- updated package to conform to fedora guidelines
+
+* Mon Jul 04 2011  <mtaylor at redhat.com>  - 0.0.1-1
+- Added man files
+
+* Wed Jun 15 2011  <jguiditt at redhat.com> - 0.0.1-1
+- Initial package
-- 
1.7.6.4




More information about the aeolus-devel mailing list