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

Steve Linabery slinaber at redhat.com
Wed Dec 21 21:27:36 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                         |    4 +-
 contrib/aeolus-configure.spec    |  152 --------------------------------------
 contrib/aeolus-configure.spec.in |  152 ++++++++++++++++++++++++++++++++++++++
 rake/rpmtask.rb                  |   28 +++++--
 4 files changed, 174 insertions(+), 162 deletions(-)
 delete mode 100644 contrib/aeolus-configure.spec
 create mode 100644 contrib/aeolus-configure.spec.in

diff --git a/Rakefile b/Rakefile
index ccf7601..852828c 100644
--- a/Rakefile
+++ b/Rakefile
@@ -28,10 +28,12 @@ CLEAN.include('pkg', 'repo')
 CLOBBER.include('aeolus')
 PKG_NAME = "aeolus-configure"
 RPM_SPEC = "contrib/aeolus-configure.spec"
+RPM_SPEC_IN = "contrib/aeolus-configure.spec.in"
+PKG_VERSION = "2.5.0"
 
 # Build the rpm
 rpm_task =
-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("COPYING", "bin/*", "recipes/**/*", "conf/*")
   rpm.topdir = "#{RPMBUILD_DIR}"
diff --git a/contrib/aeolus-configure.spec b/contrib/aeolus-configure.spec
deleted file mode 100644
index b063410..0000000
--- a/contrib/aeolus-configure.spec
+++ /dev/null
@@ -1,152 +0,0 @@
-%global aeolushome /usr/share/aeolus-configure
-%global pbuild %{_builddir}/%{name}-%{version}
-
-Summary:  Aeolus Configure Puppet Recipe
-Name:     aeolus-configure
-Version:  2.5.0
-Release:  0%{?extra_release}%{?dist}
-
-Group:    Applications/Internet
-License:  ASL 2.0
-URL:      http://aeolusproject.org
-
-# to build source tarball
-# git clone git://git.fedorahosted.org/aeolus/configure.git
-# cd configure
-# rake pkg
-# cp pkg/aeolus-configure-2.0.1.tgz ~/rpmbuild/SOURCES
-Source0:  %{name}-%{version}.tgz
-BuildArch:  noarch
-Requires:   puppet >= 2.6.6
-Requires:   rubygem(uuidtools)
-BuildRequires: rubygem(rspec-core)
-# To send a request to iwhd rest interface to
-# create buckets, eventually replace w/ an
-# iwhd client
-Requires:  curl
-Requires:  rubygem(curb)
-Requires:  rubygem(highline)
-
-%description
-Aeolus Configure Puppet Recipe
-
-%prep
-%setup -q
-
-%build
-
-%install
-%{__mkdir} -p %{buildroot}/%{aeolushome}/modules/aeolus %{buildroot}/%{_sbindir}
-%{__mkdir} -p %{buildroot}/%{_bindir}
-%{__mkdir} -p %{buildroot}%{_sysconfdir}/aeolus-configure/nodes
-%{__cp} -R %{pbuild}/conf/* %{buildroot}%{_sysconfdir}/aeolus-configure/nodes
-%{__mv} %{buildroot}%{_sysconfdir}/aeolus-configure/nodes/custom_template.tdl %{buildroot}%{_sysconfdir}/aeolus-configure/
-%{__cp} -R %{pbuild}/recipes/aeolus/* %{buildroot}/%{aeolushome}/modules/aeolus
-%{__cp} -R %{pbuild}/recipes/apache/ %{buildroot}/%{aeolushome}/modules/apache
-%{__cp} -R %{pbuild}/recipes/ntp/ %{buildroot}/%{aeolushome}/modules/ntp
-%{__cp} -R %{pbuild}/recipes/openssl/ %{buildroot}/%{aeolushome}/modules/openssl
-%{__cp} -R %{pbuild}/recipes/postgres/ %{buildroot}/%{aeolushome}/modules/postgres
-%{__cp} -R %{pbuild}/bin/aeolus-node %{buildroot}/%{aeolushome}/modules/aeolus/
-%{__cp} -R %{pbuild}/bin/aeolus-check-services %{buildroot}/%{_bindir}/
-%{__cp} -R %{pbuild}/bin/aeolus-restart-services %{buildroot}/%{_sbindir}/
-%{__cp} -R %{pbuild}/bin/aeolus-configure %{buildroot}/%{_sbindir}/
-%{__cp} -R %{pbuild}/bin/aeolus-cleanup %{buildroot}/%{_sbindir}/
-
-%files
-%doc COPYING
-%attr(0755, root, root) %{_sbindir}/aeolus-configure
-%attr(0755, root, root) %{_sbindir}/aeolus-cleanup
-%config(noreplace) %{_sysconfdir}/aeolus-configure/*
-%attr(0755, root, root) %{_bindir}/aeolus-check-services
-%attr(0755, root, root) %{_sbindir}/aeolus-restart-services
-%{aeolushome}
-
-%changelog
-* Thu Dec  1 2011 Steve Linabery <slinaber at redhat.com> - 2.4.0-1
-- ffc966c Regenerate conductor secret_token.rb file each time configure is executed
-- 4dfb1c3 Bump the version of aeolus-cli to 0.2.0
-- d8e6c40 Fix the collision in the /conductor/images/ path
-- fc84050 Log the image warehouse cleanup output
-- 1337d60 Redmine #2807 - Add ability to flush out iwhd in aeolus-cleaup
-- de3c009 Bump version following release of 2.3.0-1 on 2.3.x branch
-- fa3f661 BZ753258 - aeolus-configure overwrites contents in /etc/imagefactory/imagefactory.conf every time its executed
-- 43ad235 Ensure logout is called after all provider adds in ec2 profile.
-- f365b00 BZ752975 - multiple executions of aeolus-cleanup/configure not working as expected
-- 2b67daf Fix for Redmine #2680
-- 32f555a Document how to specify multiple profiles in aeolus-configure -h.
-- 7a0e110 Clean up rsyslog config file
-- dc67269 BZ 753273 - rsyslog configuration causes messages log to grow rapidly.
-- 0087203 BZ 753250: - aeolus-configure fails No such file or directory
-- 0af7031 update aeolus check/restart services scripts for f16 (jlaska's fix for BZ #747762 rebased)
-
-* Thu Nov 17 2011 Steve Linabery <slinaber at redhat.com> - 2.4.0-0
-- Bump version following release of 2.3.0-1 from 2.3.x branch
-
-* Wed Sep 14 2011 Richard Su <rwsu at redhat.com> 2.0.2-4
-- single deltacloud-core
-- rhevm and vsphere configurations moved to their own profiles
-- wait 1 sec after deltacloud-core service startup before providers are added
-
-* Tue Aug 30 2011 Maros Zatko <mzatko at redhat.com> 2.0.2-3
-- Added script for restarting running services
-
-* Tue Aug 16 2011 Maros Zatko <mzatko at redhat.com> 2.0.2-2
-- Added script for listing running services
-
-* Wed Aug 03 2011 Mo Morsi <mmorsi at redhat.com> 2.0.2-1
-- update to include profiles, interactive installer
-
-* Wed Jul 20 2011 Mo Morsi <mmorsi at redhat.com> 2.0.1-2
-- updates to conform to Fedora package guidelines
-
-* Tue Jul 19 2011 Mike Orazi <morazi at redhat.com> 2.0.1-1
-- vSphere configuration
-- RHEV configuration
-- warehouse sync, solr, and factory connector services removed
-- bug fixes
-
-* Wed May 18 2011 Mike Orazi <morazi at redhat.com> 2.0.1-0
-- Move using external nodes so changes to behavior can happen in etc
-
-* Wed May 18 2011 Chris Lalancette <clalance at redhat.com> - 2.0.0-11
-- Bump the release version
-
-* Tue Mar 22 2011 Angus Thomas <athomas at redhat.com> 2.0.0-5
-- Removed iwhd init script and config file
-
-* Wed Feb 17 2011 Mohammed Morsi <mmorsi at redhat.com> 2.0.0-3
-- renamed deltacloud-configure to aeolus-configure
-
-* Tue Feb 15 2011 Mohammed Morsi <mmorsi at redhat.com> 2.0.0-3
-- various fixes to recipe
-
-* Thu Jan 14 2011 Mohammed Morsi <mmorsi at redhat.com> 2.0.0-2
-- include openssl module
-
-
-* Mon Jan 10 2011 Mike Orazi <morazi at redhat.com> 2.0.0-1
-- Make this a drop in replacement for the old deltacloud-configure scripts
-
-* Wed Dec 22 2010 Mohammed Morsi <mmorsi at redhat.com> 0.0.4-1
-- Revamp deltacloud recipe to make it more puppetized,
-  use general purpose firewall, postgres, ntp modules,
-  and to fix many various things
-
-* Wed Sep 29 2010 Mohammed Morsi <mmorsi at redhat.com> 0.0.3-1
-- Renamed package from deltacloud appliance
-- to deltacloud recipe
-
-* Wed Sep 29 2010 Mohammed Morsi <mmorsi at redhat.com> 0.0.2-3
-- Include curl-devel for typhoeus gem
-
-* Wed Sep 29 2010 Mohammed Morsi <mmorsi at redhat.com> 0.0.2-2
-- Updated to pull in latest git changes
-
-* Fri Sep 17 2010 Mohammed Morsi <mmorsi at redhat.com> 0.0.2-1
-- Updated packages pulled in to latest versions
-- Various fixes
-- Added initial image warehouse bits
-
-* Thu Sep 02 2010 Mohammed Morsi <mmorsi at redhat.com> 0.0.1-1
-- Initial package
-
diff --git a/contrib/aeolus-configure.spec.in b/contrib/aeolus-configure.spec.in
new file mode 100644
index 0000000..5ca4753
--- /dev/null
+++ b/contrib/aeolus-configure.spec.in
@@ -0,0 +1,152 @@
+%global aeolushome /usr/share/aeolus-configure
+%global pbuild %{_builddir}/%{name}-%{version}
+
+Summary:  Aeolus Configure Puppet Recipe
+Name:     aeolus-configure
+Version:  @VERSION@
+Release:  0%{?extra_release}%{?dist}
+
+Group:    Applications/Internet
+License:  ASL 2.0
+URL:      http://aeolusproject.org
+
+# to build source tarball
+# git clone git://git.fedorahosted.org/aeolus/configure.git
+# cd configure
+# rake pkg
+# cp pkg/aeolus-configure-2.0.1.tgz ~/rpmbuild/SOURCES
+Source0:  %{name}-%{version}.tgz
+BuildArch:  noarch
+Requires:   puppet >= 2.6.6
+Requires:   rubygem(uuidtools)
+BuildRequires: rubygem(rspec-core)
+# To send a request to iwhd rest interface to
+# create buckets, eventually replace w/ an
+# iwhd client
+Requires:  curl
+Requires:  rubygem(curb)
+Requires:  rubygem(highline)
+
+%description
+Aeolus Configure Puppet Recipe
+
+%prep
+%setup -q
+
+%build
+
+%install
+%{__mkdir} -p %{buildroot}/%{aeolushome}/modules/aeolus %{buildroot}/%{_sbindir}
+%{__mkdir} -p %{buildroot}/%{_bindir}
+%{__mkdir} -p %{buildroot}%{_sysconfdir}/aeolus-configure/nodes
+%{__cp} -R %{pbuild}/conf/* %{buildroot}%{_sysconfdir}/aeolus-configure/nodes
+%{__mv} %{buildroot}%{_sysconfdir}/aeolus-configure/nodes/custom_template.tdl %{buildroot}%{_sysconfdir}/aeolus-configure/
+%{__cp} -R %{pbuild}/recipes/aeolus/* %{buildroot}/%{aeolushome}/modules/aeolus
+%{__cp} -R %{pbuild}/recipes/apache/ %{buildroot}/%{aeolushome}/modules/apache
+%{__cp} -R %{pbuild}/recipes/ntp/ %{buildroot}/%{aeolushome}/modules/ntp
+%{__cp} -R %{pbuild}/recipes/openssl/ %{buildroot}/%{aeolushome}/modules/openssl
+%{__cp} -R %{pbuild}/recipes/postgres/ %{buildroot}/%{aeolushome}/modules/postgres
+%{__cp} -R %{pbuild}/bin/aeolus-node %{buildroot}/%{aeolushome}/modules/aeolus/
+%{__cp} -R %{pbuild}/bin/aeolus-check-services %{buildroot}/%{_bindir}/
+%{__cp} -R %{pbuild}/bin/aeolus-restart-services %{buildroot}/%{_sbindir}/
+%{__cp} -R %{pbuild}/bin/aeolus-configure %{buildroot}/%{_sbindir}/
+%{__cp} -R %{pbuild}/bin/aeolus-cleanup %{buildroot}/%{_sbindir}/
+
+%files
+%doc COPYING
+%attr(0755, root, root) %{_sbindir}/aeolus-configure
+%attr(0755, root, root) %{_sbindir}/aeolus-cleanup
+%config(noreplace) %{_sysconfdir}/aeolus-configure/*
+%attr(0755, root, root) %{_bindir}/aeolus-check-services
+%attr(0755, root, root) %{_sbindir}/aeolus-restart-services
+%{aeolushome}
+
+%changelog
+* Thu Dec  1 2011 Steve Linabery <slinaber at redhat.com> - 2.4.0-1
+- ffc966c Regenerate conductor secret_token.rb file each time configure is executed
+- 4dfb1c3 Bump the version of aeolus-cli to 0.2.0
+- d8e6c40 Fix the collision in the /conductor/images/ path
+- fc84050 Log the image warehouse cleanup output
+- 1337d60 Redmine #2807 - Add ability to flush out iwhd in aeolus-cleaup
+- de3c009 Bump version following release of 2.3.0-1 on 2.3.x branch
+- fa3f661 BZ753258 - aeolus-configure overwrites contents in /etc/imagefactory/imagefactory.conf every time its executed
+- 43ad235 Ensure logout is called after all provider adds in ec2 profile.
+- f365b00 BZ752975 - multiple executions of aeolus-cleanup/configure not working as expected
+- 2b67daf Fix for Redmine #2680
+- 32f555a Document how to specify multiple profiles in aeolus-configure -h.
+- 7a0e110 Clean up rsyslog config file
+- dc67269 BZ 753273 - rsyslog configuration causes messages log to grow rapidly.
+- 0087203 BZ 753250: - aeolus-configure fails No such file or directory
+- 0af7031 update aeolus check/restart services scripts for f16 (jlaska's fix for BZ #747762 rebased)
+
+* Thu Nov 17 2011 Steve Linabery <slinaber at redhat.com> - 2.4.0-0
+- Bump version following release of 2.3.0-1 from 2.3.x branch
+
+* Wed Sep 14 2011 Richard Su <rwsu at redhat.com> 2.0.2-4
+- single deltacloud-core
+- rhevm and vsphere configurations moved to their own profiles
+- wait 1 sec after deltacloud-core service startup before providers are added
+
+* Tue Aug 30 2011 Maros Zatko <mzatko at redhat.com> 2.0.2-3
+- Added script for restarting running services
+
+* Tue Aug 16 2011 Maros Zatko <mzatko at redhat.com> 2.0.2-2
+- Added script for listing running services
+
+* Wed Aug 03 2011 Mo Morsi <mmorsi at redhat.com> 2.0.2-1
+- update to include profiles, interactive installer
+
+* Wed Jul 20 2011 Mo Morsi <mmorsi at redhat.com> 2.0.1-2
+- updates to conform to Fedora package guidelines
+
+* Tue Jul 19 2011 Mike Orazi <morazi at redhat.com> 2.0.1-1
+- vSphere configuration
+- RHEV configuration
+- warehouse sync, solr, and factory connector services removed
+- bug fixes
+
+* Wed May 18 2011 Mike Orazi <morazi at redhat.com> 2.0.1-0
+- Move using external nodes so changes to behavior can happen in etc
+
+* Wed May 18 2011 Chris Lalancette <clalance at redhat.com> - 2.0.0-11
+- Bump the release version
+
+* Tue Mar 22 2011 Angus Thomas <athomas at redhat.com> 2.0.0-5
+- Removed iwhd init script and config file
+
+* Wed Feb 17 2011 Mohammed Morsi <mmorsi at redhat.com> 2.0.0-3
+- renamed deltacloud-configure to aeolus-configure
+
+* Tue Feb 15 2011 Mohammed Morsi <mmorsi at redhat.com> 2.0.0-3
+- various fixes to recipe
+
+* Thu Jan 14 2011 Mohammed Morsi <mmorsi at redhat.com> 2.0.0-2
+- include openssl module
+
+
+* Mon Jan 10 2011 Mike Orazi <morazi at redhat.com> 2.0.0-1
+- Make this a drop in replacement for the old deltacloud-configure scripts
+
+* Wed Dec 22 2010 Mohammed Morsi <mmorsi at redhat.com> 0.0.4-1
+- Revamp deltacloud recipe to make it more puppetized,
+  use general purpose firewall, postgres, ntp modules,
+  and to fix many various things
+
+* Wed Sep 29 2010 Mohammed Morsi <mmorsi at redhat.com> 0.0.3-1
+- Renamed package from deltacloud appliance
+- to deltacloud recipe
+
+* Wed Sep 29 2010 Mohammed Morsi <mmorsi at redhat.com> 0.0.2-3
+- Include curl-devel for typhoeus gem
+
+* Wed Sep 29 2010 Mohammed Morsi <mmorsi at redhat.com> 0.0.2-2
+- Updated to pull in latest git changes
+
+* Fri Sep 17 2010 Mohammed Morsi <mmorsi at redhat.com> 0.0.2-1
+- Updated packages pulled in to latest versions
+- Various fixes
+- Added initial image warehouse bits
+
+* Thu Sep 02 2010 Mohammed Morsi <mmorsi at redhat.com> 0.0.1-1
+- Initial package
+
diff --git a/rake/rpmtask.rb b/rake/rpmtask.rb
index 0839131..5aa36d9 100644
--- a/rake/rpmtask.rb
+++ b/rake/rpmtask.rb
@@ -26,24 +26,38 @@ 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
@@ -85,14 +99,10 @@ 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/"
         cp @rpm_spec, "#{@topdir}/SPECS"
         sh "#{@rpmbuild_cmd} " +
            "--define '_topdir #{@topdir}' " +
-           "--define 'extra_release #{@include_extra_release ? extra_release : ''}' " +
            "-ba #{@rpm_spec}"
       end
     end
-- 
1.7.6.4




More information about the aeolus-devel mailing list