[PATCH aeolus-cli (rev 3)] Changes to build behavior in rpmtask.rb, Rakefile
Steve Linabery
slinaber at redhat.com
Thu Dec 22 21:03:03 UTC 2011
(revision 3 of patch)
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 | 5 +-
rake/rpmtask.rb | 31 +++++++++----
rubygem-aeolus-cli.spec | 113 --------------------------------------------
rubygem-aeolus-cli.spec.in | 113 ++++++++++++++++++++++++++++++++++++++++++++
4 files changed, 138 insertions(+), 124 deletions(-)
delete mode 100644 rubygem-aeolus-cli.spec
create mode 100644 rubygem-aeolus-cli.spec.in
diff --git a/Rakefile b/Rakefile
index f37a160..2d39510 100644
--- a/Rakefile
+++ b/Rakefile
@@ -23,10 +23,11 @@ require 'rake/rpmtask'
RPMBUILD_DIR = "#{File.expand_path('~')}/rpmbuild"
RPM_SPEC = "rubygem-aeolus-cli.spec"
+PKG_VERSION = "0.3.0"
spec = Gem::Specification.new do |s|
s.name = 'aeolus-cli'
- 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'
@@ -67,7 +68,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, {:suffix => '.in', :pkg_version => 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..94bd143 100644
--- a/rake/rpmtask.rb
+++ b/rake/rpmtask.rb
@@ -26,24 +26,41 @@ 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
+ # 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, args = {})
+ init(rpm_spec,args)
yield self if block_given?
define if block_given?
end
- def init(rpm_spec)
- @include_extra_release = true
+ def init(rpm_spec,args)
@rpm_spec = rpm_spec
+
+ if args[:suffix]
+ rpm_spec_in = @rpm_spec + args[:suffix]
+ @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}") : ''
+
+ if args[:pkg_version]
+ pkg_version = args[:pkg_version]
+ `sed -e "s|@VERSION@|#{pkg_version}|;s|^\\(Release:[^%]*\\)|\\1#{extra_release}|" #{rpm_spec_in} > #{@rpm_spec}`
+ else
+ `sed -e "s|^\\(Release:[^%]*\\)|\\1#{extra_release}|" #{rpm_spec_in} > #{@rpm_spec}`
+ end
+ end
# parse this out of the rpmbuild macros,
# not ideal but better than hardcoding this
@@ -94,16 +111,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-cli.spec b/rubygem-aeolus-cli.spec
deleted file mode 100644
index bf46aa5..0000000
--- a/rubygem-aeolus-cli.spec
+++ /dev/null
@@ -1,113 +0,0 @@
-%global gemdir %(ruby -rubygems -e 'puts Gem::dir' 2>/dev/null)
-%global gemname aeolus-cli
-%global geminstdir %{gemdir}/gems/%{gemname}-%{version}
-%global mandir %{_mandir}/man1
-%global rubyabi 1.8
-
-Summary: Command-line interface for working with the Aeolus cloud suite
-Name: rubygem-aeolus-cli
-Version: 0.3.0
-Release: 0%{?extra_release}%{?dist}
-Group: Development/Languages
-License: ASL 2.0
-URL: http://aeolusproject.org
-
-# The source for this packages was pulled from the upstream's git repo.
-# Use the following commands to generate the gem
-# git clone git://github.com/aeolusproject/aeolus-cli.git
-# cd aeolus-cli
-# rake gem
-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(activesupport)
-Requires: rubygem(activeresource)
-
-BuildRequires: ruby
-BuildRequires: rubygems
-BuildRequires: rubygem(rspec-core)
-
-BuildArch: noarch
-Provides: rubygem(%{gemname}) = %{version}
-
-%description
-CLI for Aeolus 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}/
-
-mkdir -p %{buildroot}/%{_bindir}
-mv %{buildroot}%{gemdir}/bin/* %{buildroot}/%{_bindir}
-find %{buildroot}%{geminstdir}/bin -type f | xargs chmod 755
-rmdir %{buildroot}%{gemdir}/bin
-rm -rf %{buildroot}%{gemdir}/gems/%{gemname}-%{version}/.yardoc
-
-mkdir -p %{buildroot}%{mandir}
-mv %{buildroot}%{geminstdir}/man/* %{buildroot}%{mandir}
-
-%files
-%doc %{geminstdir}/COPYING
-%{_bindir}/aeolus
-%{_bindir}/aeolus-image
-%dir %{geminstdir}
-%{geminstdir}/Rakefile
-%{geminstdir}/bin
-%{geminstdir}/examples
-%{geminstdir}/lib
-%{geminstdir}/man
-%{geminstdir}/spec
-%doc %{gemdir}/doc/%{gemname}-%{version}
-%{gemdir}/cache/%{gemname}-%{version}.gem
-%{gemdir}/specifications/%{gemname}-%{version}.gemspec
-%{mandir}/*
-
-%changelog
-* Thu Dec 1 2011 Steve Linabery <slinaber at redhat.com> - 0.3.0-0
-- Bump version
-
-* Thu Dec 1 2011 Steve Linabery <slinaber at redhat.com> - 0.2.0-1
-- 785c8be Change and refactor tests for refactored option parser use
-- 911d47c refactored option parser to support multiple same options
-- dd580f4 Set language in HTTP_ACCEPT_LANGUAGE header
-- 48bbaa0 RM 2803 - Add status checking on image builds and pushes - v2
-- 6907390 Added provider content cleanup output
-- d721dc0 added mention of .aeolus-cli into default help
-- 44aa00c added section explaining .aeolus-cli into manpage
-- 5db097e Added format since ARes changed default
-- f0df5bb added dependency on ActiveSupport and ActiveResource to specfile
-- 445347f bumped version in gem specification to reflect ver. in specfile
-- 97585c1 Utilize Conductor API Error Messaging
-
-* Mon Nov 21 2011 Maros Zatko <mzatko at redhat.com> 0.2.0-0
-- added dependency on ActiveSupport and ActiveResource
-
-* Wed Nov 16 2011 Steve Linabery <slinaber at redhat.com> 0.2.0-0
-- bump version and release for ongoing development
-
-* Wed Nov 9 2011 Martyn Taylor <mmorsi at redhat.com> - 0.0.1-4
-- Renamed Bin file to aeolus-cli
-
-* 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-cli.spec.in b/rubygem-aeolus-cli.spec.in
new file mode 100644
index 0000000..100d5c0
--- /dev/null
+++ b/rubygem-aeolus-cli.spec.in
@@ -0,0 +1,113 @@
+%global gemdir %(ruby -rubygems -e 'puts Gem::dir' 2>/dev/null)
+%global gemname aeolus-cli
+%global geminstdir %{gemdir}/gems/%{gemname}-%{version}
+%global mandir %{_mandir}/man1
+%global rubyabi 1.8
+
+Summary: Command-line interface for working with the Aeolus cloud suite
+Name: rubygem-aeolus-cli
+Version: @VERSION@
+Release: 0%{?extra_release}%{?dist}
+Group: Development/Languages
+License: ASL 2.0
+URL: http://aeolusproject.org
+
+# The source for this packages was pulled from the upstream's git repo.
+# Use the following commands to generate the gem
+# git clone git://github.com/aeolusproject/aeolus-cli.git
+# cd aeolus-cli
+# rake gem
+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(activesupport)
+Requires: rubygem(activeresource)
+
+BuildRequires: ruby
+BuildRequires: rubygems
+BuildRequires: rubygem(rspec-core)
+
+BuildArch: noarch
+Provides: rubygem(%{gemname}) = %{version}
+
+%description
+CLI for Aeolus 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}/
+
+mkdir -p %{buildroot}/%{_bindir}
+mv %{buildroot}%{gemdir}/bin/* %{buildroot}/%{_bindir}
+find %{buildroot}%{geminstdir}/bin -type f | xargs chmod 755
+rmdir %{buildroot}%{gemdir}/bin
+rm -rf %{buildroot}%{gemdir}/gems/%{gemname}-%{version}/.yardoc
+
+mkdir -p %{buildroot}%{mandir}
+mv %{buildroot}%{geminstdir}/man/* %{buildroot}%{mandir}
+
+%files
+%doc %{geminstdir}/COPYING
+%{_bindir}/aeolus
+%{_bindir}/aeolus-image
+%dir %{geminstdir}
+%{geminstdir}/Rakefile
+%{geminstdir}/bin
+%{geminstdir}/examples
+%{geminstdir}/lib
+%{geminstdir}/man
+%{geminstdir}/spec
+%doc %{gemdir}/doc/%{gemname}-%{version}
+%{gemdir}/cache/%{gemname}-%{version}.gem
+%{gemdir}/specifications/%{gemname}-%{version}.gemspec
+%{mandir}/*
+
+%changelog
+* Thu Dec 1 2011 Steve Linabery <slinaber at redhat.com> - 0.3.0-0
+- Bump version
+
+* Thu Dec 1 2011 Steve Linabery <slinaber at redhat.com> - 0.2.0-1
+- 785c8be Change and refactor tests for refactored option parser use
+- 911d47c refactored option parser to support multiple same options
+- dd580f4 Set language in HTTP_ACCEPT_LANGUAGE header
+- 48bbaa0 RM 2803 - Add status checking on image builds and pushes - v2
+- 6907390 Added provider content cleanup output
+- d721dc0 added mention of .aeolus-cli into default help
+- 44aa00c added section explaining .aeolus-cli into manpage
+- 5db097e Added format since ARes changed default
+- f0df5bb added dependency on ActiveSupport and ActiveResource to specfile
+- 445347f bumped version in gem specification to reflect ver. in specfile
+- 97585c1 Utilize Conductor API Error Messaging
+
+* Mon Nov 21 2011 Maros Zatko <mzatko at redhat.com> 0.2.0-0
+- added dependency on ActiveSupport and ActiveResource
+
+* Wed Nov 16 2011 Steve Linabery <slinaber at redhat.com> 0.2.0-0
+- bump version and release for ongoing development
+
+* Wed Nov 9 2011 Martyn Taylor <mmorsi at redhat.com> - 0.0.1-4
+- Renamed Bin file to aeolus-cli
+
+* 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